def METHOD_NAME(wat2wasm, wasm2wat, out_dir, filename, verbose, stdout):
    basename = os.path.basename(filename)
    basename_noext = os.path.splitext(basename)[0]
    wasm1_file = os.path.join(out_dir, basename_noext + '-1.wasm')
    wat2_file = os.path.join(out_dir, basename_noext + '-2.wat')
    wasm3_file = os.path.join(out_dir, basename_noext + '-3.wasm')
    try:
        wat2wasm.RunWithArgs('-o', wasm1_file, filename)
    except Error:
        # if the file doesn't parse properly, just skip it (it may be a "bad-*"
        # test)
        return (SKIPPED, None)
    try:
        wasm2wat.RunWithArgs('-o', wat2_file, wasm1_file)
        wat2wasm.RunWithArgs('-o', wasm3_file, wat2_file)
    except Error as e:
        return (ERROR, str(e))
    if stdout:
        with open(wat2_file) as f:
            sys.stdout.write(f.read())
        return (OK, '')
    else:
        return FilesAreEqual(wasm1_file, wasm3_file, verbose)