(module
(
import
"wasi_snapshot_preview1"
"fd_read"
(func $fd_read (param i32 i32 i32 i32) (result i32)))
(
import
"wasi_snapshot_preview1"
"fd_write"
(func $fd_write (param i32 i32 i32 i32) (result i32)))
(
import
"wasi_snapshot_preview1"
"path_open"
(func $path_open (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32)))
(memory (export
"memory"
)
1
)
(
global
$ret1 i32 (i32.const
1111
))
(data (i32.const
2222
)
"flag"
)
(
global
$fd_ptr i32 (i32.const
3333
))
(
global
$buf i32 (i32.const
4444
))
(
global
$ret2 i32 (i32.const
5555
))
(
global
$temp_store i32 (i32.const
6666
))
(func $main (export
"_start"
)
(local $errno i32)
(local $my_variable i32)
(i32.const
123
)
(i32.store (
global
.get $buf) (
global
.get $temp_store))
(i32.store (i32.add (
global
.get $buf) (i32.const
4
)) (i32.const
666
))
(local.
set
$my_variable)
(local.
set
$errno
(call $path_open
(i32.const
3
)
(i32.const
0x1
)
(i32.const
2222
)
(i32.const
10
)
(i32.const
0x0
)
(i64.const
2
)
(i64.const
2
)
(i32.const
0x0
)
(
global
.get $fd_ptr)))
(local.
set
$errno
(call $fd_read
(i32.load (
global
.get $fd_ptr))
(
global
.get $buf)
(local.get $my_variable)
(
global
.get $fdread_ret)))
(local.
set
$errno (call $fd_write
(i32.const
1
)
(
global
.get $buf)
(local.get $my_variable)
(
global
.get $fdwrite_ret)
))
)
)