

def llvm37_to_34_ir(ir):
    '\n    Convert LLVM 3.7 IR for LLVM 3.4.\n    '

    def parse_out_leading_type(s):
        par_level = 0
        pos = 0
        while True:
            m = re_type_tok.search(s, pos)
            if (m is None):
                raise RuntimeError(('failed parsing leading type: %s' % (s,)))
                break
            pos = m.end()
            tok = m.group(0)
            if (tok == ','):
                if (par_level == 0):
                    break
            elif (tok in '{[('):
                par_level += 1
            elif (tok in ')]}'):
                par_level -= 1
        return s[pos:].lstrip()
    buf = []
    for line in ir.splitlines():
        orig = line
        if re_metadata_def.match(line):
            if (None is re_metadata_correct_usage.search(line)):
                line = line.replace('!{', 'metadata !{')
                line = line.replace('!"', 'metadata !"')
        if ('getelementptr ' in line):
            m = re_getelementptr.search(line)
            if (m is None):
                raise RuntimeError(('failed parsing getelementptr: %s' % (line,)))
            pos = m.end()
            line = (line[:pos] + parse_out_leading_type(line[pos:]))
        if ('load ' in line):
            m = re_load.search(line)
            if (m is None):
                raise RuntimeError(('failed parsing load: %s' % (line,)))
            pos = m.end()
            line = (line[:pos] + parse_out_leading_type(line[pos:]))
        if ('call ' in line):
            line = re_call.sub('\\1*\\2', line)
        line = re_annotations.sub('', line)
        buf.append(line)
    return '\n'.join(buf)

dataset/ETHPy150Open numba/numba/numba/cuda/cudadrv/nvvm.py llvm37_to_34_ir/original