def to_python_case(name):
    """Convert "GetLLVMFunctionID" to a more pythonic "get_llvm_function_id" """
    if name.isupper():
        return name.lower()
    result = ''
    for prev, cur, next in zip('a' + name[:-1], name, name[1:] + 'a'):
        if prev.islower() and cur.isupper() or next.islower() and cur.isupper(
            ):
            result += '_'
        result += cur.lower()
    if name[-2:].isupper():
        result = result[:-2] + result[-1:]
    return result[1:]
