(module
  (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32)))
  (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32)))
  (data (i32.const 48) "\04\00\00\00true")
  (data (i32.const 56) "\05\00\00\00false")
  (data (i32.const 64) "\01\00\00\00-")
  (func $alloc (param $n i32) (result i32) (local $p i32) (local $limit i32)
    (local.set $p (global.get $hp))
    (global.set $hp (i32.and (i32.add (i32.add (local.get $p) (local.get $n)) (i32.const 7)) (i32.const -8)))
    (local.set $limit (i32.mul (memory.size) (i32.const 65536)))
    (if (i32.gt_u (global.get $hp) (local.get $limit))
      (then
        (if (i32.eq (memory.grow (i32.add (i32.shr_u (i32.sub (global.get $hp) (local.get $limit)) (i32.const 16)) (i32.const 1))) (i32.const -1))
          (then (unreachable)))))
    (local.get $p))
  (memory (export "memory") 2)
  (global $hp (mut i32) (i32.const 72))
  (func $spiralMain (result i32)
    (local $v0 i32)
    (local $t1 i32)
    (local $t2 i32)
    (local $v1 i32)
    (local $v2 i32)
    (local $v3 i32)
    (local.set $t1 (i32.const 1))
    (local.set $t2 (call $alloc (i32.add (i32.const 8) (i32.mul (local.get $t1) (i32.const 8)))))
    (i32.store (local.get $t2) (local.get $t1))
    (local.set $v0 (local.get $t2))
    (local.set $v1 (i32.const 200))
    (i32.store offset=8 (i32.add (local.get $v0) (i32.mul (i32.const 0) (i32.const 8))) (local.get $v1))
    (local.set $v2 (i32.load offset=8 (i32.add (local.get $v0) (i32.mul (i32.const 0) (i32.const 8)))))
    (local.set $v3 (i32.eq (local.get $v2) (i32.const 200)))
    (if (local.get $v3)
        (then
            (return (i32.const 0))
        )
        (else
            (return (i32.const 1))
        ))
    (unreachable)
  )
  (func $_start (export "_start")
    (call $proc_exit (call $spiralMain)))
)
