def break_wasm(name):
    wat = run_process([os.path.join(building.get_binaryen_bin(), 'wasm-dis'), name], stdout=PIPE).stdout
    lines = wat.splitlines()
    wat = None
    for i in range(len(lines)):
        if ('(func $foo_end ' in lines[i]):
            j = (i + 1)
            while ('(local ' in lines[j]):
                j += 1
            lines[j] = ('(unreachable)' + lines[j])
            wat = '\n'.join(lines)
            break
    if (wat is None):
        shutil.copyfile(name, (name + '.orig'))
        return False
    with open('wat.wat', 'w') as f:
        f.write(wat)
    shutil.move(name, (name + '.orig'))
    run_process([os.path.join(building.get_binaryen_bin(), 'wasm-as'), 'wat.wat', '-o', name, '-g'])
    return True
def break_wasm(name):
    wat = run_process([os.path.join(building.get_binaryen_bin(), 'wasm-dis'), name], stdout=PIPE).stdout
    lines = wat.splitlines()
    wat = None
    for i in range(len(lines)):
        if ('(func $foo_end ' in lines[i]):
            j = (i + 1)
            while ('(local ' in lines[j]):
                j += 1
            lines[j] = ('(unreachable)' + lines[j])
            wat = '\n'.join(lines)
            break
    if (wat is None):
        shutil.copyfile(name, (name + '.orig'))
        return False
    with open('wat.wat', 'w') as f:
        f.write(wat)
    shutil.move(name, (name + '.orig'))
    run_process([os.path.join(building.get_binaryen_bin(), 'wasm-as'), 'wat.wat', '-o', name, '-g'])
    return True