Skip to content

Instantly share code, notes, and snippets.

@axic
Created February 19, 2017 22:37
Show Gist options
  • Save axic/660089577bd269e1f0e9665474fb2b89 to your computer and use it in GitHub Desktop.
Save axic/660089577bd269e1f0e9665474fb2b89 to your computer and use it in GitHub Desktop.
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ij (func (param i64) (result i32)))
(type $FUNCSIG$vj (func (param i64)))
(import "env" "malloc" (func $malloc (param i64) (result i32)))
(import "env" "rf_stdlib_print_int64" (func $rf_stdlib_print_int64 (param i64)))
(import "env" "rf_stdlib_print_string" (func $rf_stdlib_print_string (param i32)))
(import "env" "rf_stdlib_print_uint64" (func $rf_stdlib_print_uint64 (param i64)))
(table 0 anyfunc)
(memory $0 1)
(data (i32.const 16) "\05\00\00\00 \00\00\00")
(data (i32.const 32) "false")
(data (i32.const 40) "\04\00\00\000\00\00\00")
(data (i32.const 48) "true")
(data (i32.const 64) "\00\00\00\00@\00\00\00")
(data (i32.const 80) "false")
(data (i32.const 88) "\05\00\00\00P\00\00\00")
(data (i32.const 96) "hello")
(data (i32.const 104) "\05\00\00\00`\00\00\00")
(data (i32.const 112) "true")
(data (i32.const 120) "\04\00\00\00p\00\00\00")
(export "memory" (memory $0))
(export "print" (func $print))
(export "main" (func $main))
(func $print (param $0 i32)
(local $1 i32)
(local $2 i64)
(local $3 i32)
(local $4 i32)
(set_local $3
(tee_local $4
(i32.load offset=4
(i32.const 0)
)
)
)
(block $label$0
(block $label$1
(block $label$2
(br_if $label$2
(i32.eqz
(tee_local $1
(i32.load
(get_local $0)
)
)
)
)
(br_if $label$1
(i32.ne
(get_local $1)
(i32.const 1)
)
)
(i32.store offset=4
(i32.const 0)
(tee_local $4
(i32.add
(get_local $4)
(i32.const -16)
)
)
)
(i64.store
(get_local $4)
(tee_local $2
(i64.load
(i32.add
(get_local $0)
(i32.const 12)
)
)
)
)
(call $rf_stdlib_print_uint64
(get_local $2)
)
(br $label$0)
)
(i32.store offset=4
(i32.const 0)
(tee_local $4
(i32.add
(get_local $4)
(i32.const -16)
)
)
)
(i64.store
(get_local $4)
(tee_local $2
(i64.load
(i32.add
(get_local $0)
(i32.const 4)
)
)
)
)
(call $rf_stdlib_print_int64
(get_local $2)
)
(br $label$0)
)
(i32.store offset=4
(i32.const 0)
(tee_local $4
(i32.add
(get_local $4)
(i32.const -16)
)
)
)
(i64.store align=4
(get_local $4)
(i64.load align=4
(i32.add
(get_local $0)
(i32.const 20)
)
)
)
(call $rf_stdlib_print_string
(get_local $4)
)
)
(i32.store offset=4
(i32.const 0)
(get_local $3)
)
)
(func $main (result i32)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(i32.store offset=4
(i32.const 0)
(tee_local $5
(i32.sub
(i32.load offset=4
(i32.const 0)
)
(i32.const 48)
)
)
)
(set_local $0
(call $malloc
(i64.const 4)
)
)
(i32.store
(i32.add
(tee_local $4
(get_local $5)
)
(i32.const 32)
)
(i32.load offset=104
(i32.const 0)
)
)
(i32.store
(i32.add
(get_local $4)
(i32.const 36)
)
(i32.load offset=108
(i32.const 0)
)
)
(i64.store offset=8
(get_local $4)
(i64.const 124554051584)
)
(i32.store offset=24
(get_local $4)
(i32.const 1)
)
(block $label$0
(block $label$1
(br_if $label$1
(i32.eqz
(i32.load offset=8
(get_local $4)
)
)
)
(i32.store
(get_local $0)
(i32.const 0)
)
(br $label$0)
)
(i32.store offset=4
(i32.const 0)
(tee_local $5
(tee_local $3
(i32.add
(get_local $5)
(i32.const -16)
)
)
)
)
(i32.store
(get_local $3)
(tee_local $1
(i32.load offset=12
(get_local $4)
)
)
)
(i32.store
(get_local $0)
(get_local $1)
)
)
(block $label$2
(block $label$3
(br_if $label$3
(i32.ne
(i32.load offset=24
(get_local $4)
)
(i32.const 1)
)
)
(i32.store offset=4
(i32.const 0)
(tee_local $5
(tee_local $1
(i32.add
(tee_local $3
(get_local $5)
)
(i32.const -16)
)
)
)
)
(i32.store
(get_local $1)
(tee_local $2
(i32.load
(i32.add
(get_local $4)
(i32.const 32)
)
)
)
)
(i32.store
(i32.add
(get_local $3)
(i32.const -12)
)
(tee_local $3
(i32.load
(i32.add
(get_local $4)
(i32.const 36)
)
)
)
)
(i32.store
(get_local $4)
(get_local $2)
)
(i32.store offset=4
(get_local $4)
(get_local $3)
)
(br $label$2)
)
(i64.store
(get_local $4)
(i64.load offset=64
(i32.const 0)
)
)
)
(i32.store offset=4
(i32.const 0)
(tee_local $3
(i32.add
(tee_local $5
(get_local $5)
)
(i32.const -32)
)
)
)
(i32.store
(get_local $3)
(i32.const 2)
)
(i32.store
(i32.add
(get_local $5)
(i32.const -12)
)
(i32.load
(get_local $4)
)
)
(i32.store
(i32.add
(get_local $5)
(i32.const -8)
)
(i32.load offset=4
(get_local $4)
)
)
(call $print
(get_local $3)
)
(i32.store offset=44
(get_local $4)
(tee_local $5
(i32.load
(get_local $0)
)
)
)
(i32.store offset=4
(i32.const 0)
(i32.add
(get_local $4)
(i32.const 48)
)
)
(get_local $5)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment