import re


def parse_dependencies_from_ldd_output(content):
    """Takes the output of `ldd` as a string or list of lines and parses the dependencies."""
    if type(content) == str:
        content = content.split('\n')

    dependencies = []
    for line in content:
        # This first one is a special case of invoking the linker as `ldd`.
        if re.search('^\s*(/.*?)\s*=>\s*ldd\s*\(', line):
            # We'll exclude this because it's the hardcoded INTERP path, and it would be
            # impossible to get the full path from this command output.
            continue
        match = re.search('=>\s*(/.*?)\s*\(', line)
        match = match or re.search('\s*(/.*?)\s*\(', line)
        if match:
            dependencies.append(match.group(1))

    return dependencies