Skip to content

Instantly share code, notes, and snippets.

@devsnek
Created November 17, 2024 16:26
Show Gist options
  • Save devsnek/86fa6167f16fd7c313c64c7d4636052e to your computer and use it in GitHub Desktop.
Save devsnek/86fa6167f16fd7c313c64c7d4636052e to your computer and use it in GitHub Desktop.
(module
(type (;0;) (func (result f64)))
(import "js" "n" (global (;0;) f64))
(import "js" "memory" (memory (;0;) 1))
(func (;0;) (type 0) (result f64)
(local i32 i32 i32 i32 i32 i32 f64 f64)
global.get 0
i32.trunc_f64_s
global.set 1
global.get 1
i32.const 1
i32.sub
global.set 2
global.get 1
global.get 1
i32.mul
i32.const 3
i32.shl
global.set 3
global.get 3
i32.const 1
global.get 2
i32.shl
local.tee 0
global.get 2
i32.mul
i32.const 3
i32.shl
i32.add
global.set 4
local.get 0
i32.const 1
i32.sub
local.set 5
i32.const 1
local.set 3
loop ;; label = @1
local.get 3
local.get 5
i32.le_u
if ;; label = @2
i32.const 0
local.set 2
loop ;; label = @3
global.get 2
local.get 2
i32.ne
if ;; label = @4
local.get 3
i32.const 1
local.get 2
i32.shl
i32.xor
local.tee 4
local.get 3
i32.lt_u
if ;; label = @5
local.get 4
if ;; label = @6
i32.const -1
local.set 1
i32.const 0
local.set 0
loop ;; label = @7
global.get 2
local.get 0
i32.ne
if ;; label = @8
local.get 4
i32.const 1
local.get 0
i32.shl
i32.and
if ;; label = @9
local.get 1
i32.const -1
i32.eq
global.get 3
global.get 2
local.get 4
i32.mul
local.get 0
i32.add
i32.const 3
i32.shl
i32.add
f64.load
global.get 1
local.get 0
i32.mul
local.get 2
i32.add
i32.const 3
i32.shl
f64.load
f64.add
local.tee 7
local.get 6
f64.lt
i32.or
if ;; label = @10
local.get 7
local.set 6
local.get 0
local.set 1
end
end
local.get 0
i32.const 1
i32.add
local.set 0
br 1 (;@7;)
end
end
else
global.get 1
global.get 2
i32.mul
local.get 2
i32.add
i32.const 3
i32.shl
f64.load
local.set 6
global.get 2
local.set 1
end
global.get 3
global.get 2
local.get 3
i32.mul
local.get 2
i32.add
local.tee 0
i32.const 3
i32.shl
i32.add
local.get 6
f64.store
global.get 4
local.get 0
i32.const 2
i32.shl
i32.add
local.get 1
i32.store
end
local.get 2
i32.const 1
i32.add
local.set 2
br 1 (;@3;)
end
end
local.get 3
i32.const 1
i32.add
local.set 3
br 1 (;@1;)
end
end
global.get 2
if ;; label = @1
i32.const -1
local.set 1
i32.const 0
local.set 0
loop ;; label = @2
global.get 2
local.get 0
i32.ne
if ;; label = @3
local.get 1
i32.const -1
i32.eq
global.get 3
global.get 2
local.get 5
i32.mul
local.get 0
i32.add
i32.const 3
i32.shl
i32.add
f64.load
global.get 2
global.get 1
local.get 0
i32.mul
i32.add
i32.const 3
i32.shl
f64.load
f64.add
local.tee 7
local.get 6
f64.lt
i32.or
if ;; label = @4
local.get 7
local.set 6
local.get 0
local.set 1
end
local.get 0
i32.const 1
i32.add
local.set 0
br 1 (;@2;)
end
end
else
global.get 2
local.set 1
end
local.get 1
f64.convert_i32_s)
(global (;1;) (mut i32) (i32.const 0))
(global (;2;) (mut i32) (i32.const 0))
(global (;3;) (mut i32) (i32.const 0))
(global (;4;) (mut i32) (i32.const 0))
(export "doHK" (func 0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment