# Path: symsynd/utils.py
# def parse_addr(x):
#     if x is None:
#         return 0
#     if isinstance(x, int_types):
#         return x
#     if isinstance(x, basestring):
#         if x[:2] == '0x':
#             return int(x[2:], 16)
#         return int(x)
#     raise ValueError('Unsupported address format %r' % (x,))


from symsynd.utils import parse_addr
        return (addr & -2) + 2
    else:
        return addr + 1


def get_ip_register(registers, cpu_name):
    rv = None
    if registers:
        if cpu_name[:3] == 'arm':
            rv = registers.get('pc')
        elif cpu_name == 'x86_64':
            rv = registers.get('rip')
    if rv is not None:
        return parse_addr(rv)


def round_to_instruction_end(addr, cpu_name):
    if cpu_name.startswith('arm64'):
        return (addr & -4) + 3
    elif cpu_name.startswith('arm'):
        return (addr & -2) + 1
    return addr


def find_best_instruction(addr, cpu_name, meta=None):
    """Given an instruction and meta information this attempts to find
    the best instruction for the frame.  In some circumstances we can
    fix it up a bit to improve the accuracy.  For more information see
    `symbolize_frame`.
    """

# Path: symsynd/utils.py
# def parse_addr(x):
#     if x is None:
#         return 0
#     if isinstance(x, int_types):
#         return x
#     if isinstance(x, basestring):
#         if x[:2] == '0x':
#             return int(x[2:], 16)
#         return int(x)
#     raise ValueError('Unsupported address format %r' % (x,))


# Path: symsynd/heuristics.py
from symsynd.utils import parse_addr

        return (addr & -2) + 2
    else:
        return addr + 1


def get_ip_register(registers, cpu_name):
    rv = None
    if registers:
        if cpu_name[:3] == 'arm':
            rv = registers.get('pc')
        elif cpu_name == 'x86_64':
            rv = registers.get('rip')
    if rv is not None:
        return parse_addr(rv)


def round_to_instruction_end(addr, cpu_name):
    if cpu_name.startswith('arm64'):
        return (addr & -4) + 3
    elif cpu_name.startswith('arm'):
        return (addr & -2) + 1
    return addr


def find_best_instruction(addr, cpu_name, meta=None):
    """Given an instruction and meta information this attempts to find
    the best instruction for the frame.  In some circumstances we can
    fix it up a bit to improve the accuracy.  For more information see
    `symbolize_frame`.
    """

    addr = rv = parse_addr(addr)