def parse_int(arg):
    """
    Parse an integer of an unknown base.
    The supported bases are 2, 8, 10 and 16.
    """
    arg = arg.lower()
    base = 10
    if arg.startswith('0x'):
        base = 16
    elif arg.startswith('0b'):
        base = 2
    elif arg.startswith('0o'):
        base = 8
    
    return int(arg, base)