def METHOD_NAME(generated_wasm_file, test_wasm_file, out_wasm_file, map_file):
    def read_wasm_file(wasm_file):
        out = subprocess.run(['eosio-wasm2wast', wasm_file], capture_output=True)
        generated_wast_string = out.stdout.decode('utf-8')
        if generated_wast_string:
            return generated_wast_string
        else:
            n = (' '.join(map_file.split('.')[0:2])).split('/')[1]
            raise CompileError(f'Failed to convert {wasm_file} to wast for {n}')
    def get_map(m_file):
        with open(m_file, 'r') as f:
            name_to_num_map = json.load(f)
            num_to_name_map = {v:k for k, v in name_to_num_map.items()}
            return num_to_name_map
    num_to_name_map = get_map(map_file)
    generated_wasm = GeneratedWASM()
    test_wasm = TestWASM()
    generated_wasm.read_wasm(read_wasm_file(generated_wasm_file))
    test_wasm.read_wasm(read_wasm_file(test_wasm_file))
    type_map = test_wasm.shift_types(generated_wasm.max_type)
    max_func_num = test_wasm.shift_imports(type_map, generated_wasm.max_import)
    max_func_num = generated_wasm.shift_base_funcs(max_func_num)
    num_to_name_map = {
        int(k) + generated_wasm.num_imports_base_functions + 1:
        v for k, v in num_to_name_map.items()
    }
    max_func_num = test_wasm.shift_funcs(type_map, max_func_num)
    test_wasm.shift_calls(type_map)
    exports_map = test_wasm.shift_exports()
    generated_wasm.create_imports_map()
    generated_wasm.shift_funcs(num_to_name_map, max_func_num)
    generated_wasm.shift_calls(num_to_name_map, exports_map)
    generated_wasm.shift_exports()
    test_wasm.shift_elems()
    test_wasm.shift_start()
    max_global = test_wasm.get_max_global()
    generated_wasm.shift_globals(max_global)
    with open(out_wasm_file, 'w') as f:
        f.write(write_merged_wasm(generated_wasm, test_wasm))