Minor optimizations to array sorting

...to get a handle on the code
This commit is contained in:
dcodeIO 2018-04-08 01:53:22 +02:00
parent ac2281b14b
commit 0f49e054d2
5 changed files with 317 additions and 402 deletions

2
dist/asc.js vendored

File diff suppressed because one or more lines are too long

2
dist/asc.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -2,93 +2,77 @@ import { Array } from "../array";
/** Obtains the default comparator for the specified type. */
export function defaultComparator<T>(): (a: T, b: T) => i32 {
return (a: T, b: T): i32 => (<i32>(a > b) - <i32>(a < b)); // compiles to a constant function index
return (a: T, b: T): i32 => (<i32>(a > b) - <i32>(a < b)); // compiles to a constant table index
}
/** Sorts an Array with the 'Insertion Sort' algorithm. */
export function insertionSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
var a: T, b: T, j: i32;
const typeShift = alignof<T>();
const shiftT = alignof<T>();
var memory = arr.__memory;
for (let i: i32 = 0, len: i32 = arr.length; i < len; i++) {
a = load<T>(arr.__memory + (i << typeShift)); // a = <T>arr[i];
j = i - 1;
let a = load<T>(memory + (i << shiftT)); // a = arr[i]
let j = i - 1;
while (j >= 0) {
b = load<T>(arr.__memory + (j << typeShift)); // b = <T>arr[j];
let b = load<T>(memory + (j << shiftT)); // b = arr[j]
if (comparator(a, b) < 0) {
store<T>(arr.__memory + ((j + 1) << typeShift), b); // arr[j + 1] = b;
j--;
store<T>(memory + ((j-- + 1) << shiftT), b); // arr[j + 1] = b
} else break;
}
store<T>(arr.__memory + ((j + 1) << typeShift), a); // arr[j + 1] = a;
store<T>(memory + ((j + 1) << shiftT), a); // arr[j + 1] = a
}
return arr;
}
/** Sorts an Array with the 'Weak Heap Sort' algorithm. */
export function weakHeapSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
const shiftT = alignof<T>();
const shift32 = alignof<i32>();
var length = arr.length;
var bitsetSize = (length + 31) >> 5 << shift32;
var bitset = allocate_memory(bitsetSize); // indexed in 32-bit chunks below
set_memory(bitset, 0, bitsetSize);
// see: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf
var len: i32 = arr.length;
var i: i32, j: i32, y: i32, p: i32, a: T, b: T;
const typeShift = alignof<T>();
const intShift = alignof<i32>();
var blen = (len + 31) >> 5;
var bitset = allocate_memory(blen << intShift);
set_memory(bitset, 0, blen << intShift);
for (i = len - 1; i > 0; i--) {
j = i;
while ((j & 1) == ((load<i32>(bitset + ((j >> 6) << intShift)) >> ((j >> 1) & 31)) & 1)) {
j >>= 1;
}
p = j >> 1;
a = load<T>(arr.__memory + (p << typeShift)); // a = <T>arr[p];
b = load<T>(arr.__memory + (i << typeShift)); // b = <T>arr[i];
var memory = arr.__memory;
for (let i = length - 1; i > 0; i--) {
let j = i;
while ((j & 1) == (load<i32>(bitset + (j >> 6 << shift32)) >> (j >> 1 & 31) & 1)) j >>= 1;
let p = j >> 1;
let a = load<T>(memory + (p << shiftT)); // a = arr[p]
let b = load<T>(memory + (i << shiftT)); // b = arr[i]
if (comparator(a, b) < 0) {
store<i32>(
bitset + ((i >> 5) << intShift),
load<i32>(bitset + ((i >> 5) << intShift)) ^ (1 << (i & 31))
bitset + (i >> 5 << shift32),
load<i32>(bitset + (i >> 5 << shift32)) ^ (1 << (i & 31))
);
store<T>(arr.__memory + (i << typeShift), a); // arr[i] = a;
store<T>(arr.__memory + (p << typeShift), b); // arr[p] = b;
store<T>(memory + (i << shiftT), a); // arr[i] = a
store<T>(memory + (p << shiftT), b); // arr[p] = b
}
}
for (i = len - 1; i >= 2; i--) {
/*
a = <T>arr[0];
arr[0] = <T>arr[i];
arr[i] = a;
*/
a = load<T>(arr.__memory, 0);
store<T>(arr.__memory, load<T>(arr.__memory + (i << typeShift)), 0);
store<T>(arr.__memory + (i << typeShift), a);
for (let i = length - 1; i >= 2; i--) {
let a = load<T>(memory, 0); // a = arr[0]
store<T>(memory, load<T>(memory + (i << shiftT)), 0); // arr[0] = arr[1]
store<T>(memory + (i << shiftT), a); // arr[1] = a
let x = 1;
while ((y = (x << 1) + ((load<i32>(bitset + ((x >> 5) << intShift)) >> (x & 31)) & 1)) < i) {
x = y;
}
let x = 1, y: i32;
while ((y = (x << 1) + ((load<i32>(bitset + (x >> 5 << shift32)) >> (x & 31)) & 1)) < i) x = y;
while (x > 0) {
a = load<T>(arr.__memory, 0); // a = <T>arr[0];
b = load<T>(arr.__memory + (x << typeShift)); // b = <T>arr[x];
a = load<T>(memory, 0); // a = arr[0]
let b = load<T>(memory + (x << shiftT)); // b = arr[x]
if (comparator(a, b) < 0) {
store<i32>(
bitset + ((x >> 5) << intShift),
load<i32>(bitset + ((x >> 5) << intShift)) ^ (1 << (x & 31))
bitset + (x >> 5 << shift32),
load<i32>(bitset + (x >> 5 << shift32)) ^ (1 << (x & 31))
);
store<T>(arr.__memory + (x << typeShift), a); // arr[x] = a;
store<T>(arr.__memory, b, 0); // arr[0] = b;
store<T>(memory + (x << shiftT), a); // arr[x] = a
store<T>(memory, b, 0); // arr[0] = b
}
x >>= 1;
}
@ -96,14 +80,8 @@ export function weakHeapSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32):
free_memory(bitset);
/*
let t = <T>arr[1];
arr[1] = <T>arr[0];
arr[0] = t;
*/
var t = load<T>(arr.__memory, sizeof<T>());
store<T>(arr.__memory, load<T>(arr.__memory, 0), sizeof<T>());
store<T>(arr.__memory, t, 0);
var t = load<T>(memory, sizeof<T>()); // t = arr[1]
store<T>(memory, load<T>(memory, 0), sizeof<T>()); // arr[1] = arr[0]
store<T>(memory, t, 0); // arr[0] = t
return arr;
}

View File

@ -3893,7 +3893,14 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(set_local $6
(local $7 i32)
(local $8 i32)
(set_local $4
(i32.load
(get_local $0)
)
)
(set_local $7
(call $~lib/array/Array<i32>#get:length
(get_local $0)
)
@ -3901,26 +3908,24 @@
(loop $continue|0
(if
(i32.lt_s
(get_local $3)
(get_local $6)
(get_local $2)
(get_local $7)
)
(block
(set_local $4
(set_local $5
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $4)
(i32.shl
(get_local $3)
(get_local $2)
(i32.const 2)
)
)
)
)
(set_local $2
(set_local $3
(i32.sub
(get_local $3)
(get_local $2)
(i32.const 1)
)
)
@ -3928,18 +3933,16 @@
(loop $continue|1
(if
(i32.ge_s
(get_local $2)
(get_local $3)
(i32.const 0)
)
(block
(set_local $5
(set_local $6
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $4)
(i32.shl
(get_local $2)
(get_local $3)
(i32.const 2)
)
)
@ -3951,33 +3954,33 @@
(br_if $break|1
(i32.ge_s
(call_indirect (type $iii)
(get_local $4)
(get_local $5)
(get_local $6)
(get_local $1)
)
(i32.const 0)
)
)
(set_local $3
(i32.sub
(tee_local $8
(get_local $3)
)
(i32.const 1)
)
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $4)
(i32.shl
(i32.add
(get_local $2)
(get_local $8)
(i32.const 1)
)
(i32.const 2)
)
)
(get_local $5)
)
(set_local $2
(i32.sub
(get_local $2)
(i32.const 1)
)
(get_local $6)
)
(br $continue|1)
)
@ -3986,22 +3989,20 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $4)
(i32.shl
(i32.add
(get_local $2)
(get_local $3)
(i32.const 1)
)
(i32.const 2)
)
)
(get_local $4)
(get_local $5)
)
(set_local $3
(set_local $2
(i32.add
(get_local $3)
(get_local $2)
(i32.const 1)
)
)
@ -4018,14 +4019,15 @@
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
(call $~lib/memory/set_memory
(tee_local $5
(tee_local $6
(call $~lib/allocator/arena/allocate_memory
(i32.shl
(tee_local $2
(tee_local $2
(i32.shl
(i32.shr_s
(i32.add
(tee_local $7
(tee_local $8
(call $~lib/array/Array<i32>#get:length
(get_local $0)
)
@ -4034,48 +4036,50 @@
)
(i32.const 5)
)
(i32.const 2)
)
(i32.const 2)
)
)
)
(i32.const 0)
(i32.shl
(get_local $2)
(i32.const 2)
)
(get_local $2)
)
(set_local $3
(i32.load
(get_local $0)
)
)
(set_local $4
(i32.sub
(get_local $7)
(get_local $8)
(i32.const 1)
)
)
(loop $continue|0
(if
(i32.gt_s
(get_local $3)
(get_local $4)
(i32.const 0)
)
(block
(set_local $2
(get_local $3)
(set_local $5
(get_local $4)
)
(loop $continue|1
(if
(i32.eq
(i32.and
(get_local $2)
(get_local $5)
(i32.const 1)
)
(i32.and
(i32.shr_s
(i32.load
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $2)
(get_local $5)
(i32.const 6)
)
(i32.const 2)
@ -4084,7 +4088,7 @@
)
(i32.and
(i32.shr_s
(get_local $2)
(get_local $5)
(i32.const 1)
)
(i32.const 31)
@ -4094,9 +4098,9 @@
)
)
(block
(set_local $2
(set_local $5
(i32.shr_s
(get_local $2)
(get_local $5)
(i32.const 1)
)
)
@ -4104,16 +4108,14 @@
)
)
)
(set_local $4
(set_local $2
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(tee_local $2
(tee_local $5
(i32.shr_s
(get_local $2)
(get_local $5)
(i32.const 1)
)
)
@ -4122,14 +4124,12 @@
)
)
)
(set_local $6
(set_local $7
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $3)
(get_local $4)
(i32.const 2)
)
)
@ -4142,8 +4142,8 @@
)
(i32.lt_s
(call_indirect (type $iii)
(get_local $4)
(get_local $6)
(get_local $2)
(get_local $7)
(get_local $1)
)
(i32.const 0)
@ -4152,10 +4152,10 @@
(block
(i32.store
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $3)
(get_local $4)
(i32.const 5)
)
(i32.const 2)
@ -4164,10 +4164,10 @@
(i32.xor
(i32.load
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $3)
(get_local $4)
(i32.const 5)
)
(i32.const 2)
@ -4177,7 +4177,7 @@
(i32.shl
(i32.const 1)
(i32.and
(get_local $3)
(get_local $4)
(i32.const 31)
)
)
@ -4185,33 +4185,29 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $3)
(get_local $4)
(i32.const 2)
)
)
(get_local $4)
(get_local $2)
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $2)
(get_local $5)
(i32.const 2)
)
)
(get_local $6)
(get_local $7)
)
)
)
(set_local $3
(set_local $4
(i32.sub
(get_local $3)
(get_local $4)
(i32.const 1)
)
)
@ -4219,37 +4215,31 @@
)
)
)
(set_local $3
(set_local $4
(i32.sub
(get_local $7)
(get_local $8)
(i32.const 1)
)
)
(loop $continue|2
(if
(i32.ge_s
(get_local $3)
(get_local $4)
(i32.const 2)
)
(block
(set_local $4
(set_local $7
(i32.load
(i32.load
(get_local $0)
)
(get_local $3)
)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $3)
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $3)
(get_local $4)
(i32.const 2)
)
)
@ -4257,15 +4247,13 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $3)
(get_local $4)
(i32.const 2)
)
)
(get_local $4)
(get_local $7)
)
(set_local $2
(i32.const 1)
@ -4273,7 +4261,7 @@
(loop $continue|3
(if
(i32.lt_s
(tee_local $4
(tee_local $5
(i32.add
(i32.shl
(get_local $2)
@ -4283,7 +4271,7 @@
(i32.shr_s
(i32.load
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $2)
@ -4302,11 +4290,11 @@
)
)
)
(get_local $3)
(get_local $4)
)
(block
(set_local $2
(get_local $4)
(get_local $5)
)
(br $continue|3)
)
@ -4319,19 +4307,15 @@
(i32.const 0)
)
(block
(set_local $4
(set_local $7
(i32.load
(i32.load
(get_local $0)
)
(get_local $3)
)
)
(set_local $6
(set_local $5
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $2)
(i32.const 2)
@ -4346,8 +4330,8 @@
)
(i32.lt_s
(call_indirect (type $iii)
(get_local $4)
(get_local $6)
(get_local $7)
(get_local $5)
(get_local $1)
)
(i32.const 0)
@ -4356,7 +4340,7 @@
(block
(i32.store
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $2)
@ -4368,7 +4352,7 @@
(i32.xor
(i32.load
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $2)
@ -4389,21 +4373,17 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $2)
(i32.const 2)
)
)
(get_local $4)
(get_local $7)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $6)
(get_local $3)
(get_local $5)
)
)
)
@ -4417,9 +4397,9 @@
)
)
)
(set_local $3
(set_local $4
(i32.sub
(get_local $3)
(get_local $4)
(i32.const 1)
)
)
@ -4428,29 +4408,21 @@
)
)
(call $~lib/allocator/arena/free_memory
(get_local $5)
(get_local $6)
)
(set_local $1
(i32.load offset=4
(i32.load
(get_local $0)
)
(get_local $3)
)
)
(i32.store offset=4
(get_local $3)
(i32.load
(get_local $0)
)
(i32.load
(i32.load
(get_local $0)
)
(get_local $3)
)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $3)
(get_local $1)
)
(get_local $0)

View File

@ -4473,14 +4473,20 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
(nop)
(nop)
(set_local $2
(i32.load
(get_local $0)
)
)
(block $break|0
(block
(set_local $5
(set_local $3
(i32.const 0)
)
(set_local $6
(set_local $4
(call $~lib/array/Array<i32>#get:length
(get_local $0)
)
@ -4489,27 +4495,25 @@
(loop $continue|0
(if
(i32.lt_s
(get_local $5)
(get_local $6)
(get_local $3)
(get_local $4)
)
(block
(block
(set_local $2
(set_local $5
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $2)
(i32.shl
(get_local $5)
(get_local $3)
(i32.const 2)
)
)
)
)
(set_local $4
(set_local $6
(i32.sub
(get_local $5)
(get_local $3)
(i32.const 1)
)
)
@ -4517,19 +4521,17 @@
(loop $continue|1
(if
(i32.ge_s
(get_local $4)
(get_local $6)
(i32.const 0)
)
(block
(block
(set_local $3
(set_local $7
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $2)
(i32.shl
(get_local $4)
(get_local $6)
(i32.const 2)
)
)
@ -4542,35 +4544,36 @@
(i32.const 2)
)
(call_indirect (type $iii)
(get_local $2)
(get_local $3)
(get_local $5)
(get_local $7)
(get_local $1)
)
)
(i32.const 0)
)
(block
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(i32.shl
(i32.add
(get_local $4)
(i32.const 1)
(i32.store
(i32.add
(get_local $2)
(i32.shl
(i32.add
(block (result i32)
(set_local $8
(get_local $6)
)
(set_local $6
(i32.sub
(get_local $8)
(i32.const 1)
)
)
(get_local $8)
)
(i32.const 2)
(i32.const 1)
)
)
(get_local $3)
)
(set_local $4
(i32.sub
(get_local $4)
(i32.const 1)
(i32.const 2)
)
)
(get_local $7)
)
(br $break|1)
)
@ -4582,23 +4585,21 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $2)
(i32.shl
(i32.add
(get_local $4)
(get_local $6)
(i32.const 1)
)
(i32.const 2)
)
)
(get_local $2)
(get_local $5)
)
)
(set_local $5
(set_local $3
(i32.add
(get_local $5)
(get_local $3)
(i32.const 1)
)
)
@ -4622,42 +4623,42 @@
(local $9 i32)
(local $10 i32)
(local $11 i32)
(local $12 i32)
(nop)
(nop)
(set_local $2
(call $~lib/array/Array<i32>#get:length
(get_local $0)
)
)
(nop)
(nop)
(nop)
(set_local $9
(i32.shr_s
(i32.add
(get_local $2)
(i32.const 31)
)
(i32.const 5)
)
)
(set_local $10
(call $~lib/allocator/arena/allocate_memory
(i32.shl
(get_local $9)
(i32.const 2)
)
)
)
(call $~lib/memory/set_memory
(get_local $10)
(i32.const 0)
(set_local $3
(i32.shl
(get_local $9)
(i32.shr_s
(i32.add
(get_local $2)
(i32.const 31)
)
(i32.const 5)
)
(i32.const 2)
)
)
(set_local $4
(call $~lib/allocator/arena/allocate_memory
(get_local $3)
)
)
(call $~lib/memory/set_memory
(get_local $4)
(i32.const 0)
(get_local $3)
)
(set_local $5
(i32.load
(get_local $0)
)
)
(block $break|0
(set_local $3
(set_local $6
(i32.sub
(get_local $2)
(i32.const 1)
@ -4666,30 +4667,30 @@
(loop $continue|0
(if
(i32.gt_s
(get_local $3)
(get_local $6)
(i32.const 0)
)
(block
(block
(set_local $4
(get_local $3)
(set_local $7
(get_local $6)
)
(block $break|1
(loop $continue|1
(if
(i32.eq
(i32.and
(get_local $4)
(get_local $7)
(i32.const 1)
)
(i32.and
(i32.shr_s
(i32.load
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $4)
(get_local $7)
(i32.const 6)
)
(i32.const 2)
@ -4698,7 +4699,7 @@
)
(i32.and
(i32.shr_s
(get_local $4)
(get_local $7)
(i32.const 1)
)
(i32.const 31)
@ -4708,12 +4709,10 @@
)
)
(block
(block
(set_local $4
(i32.shr_s
(get_local $4)
(i32.const 1)
)
(set_local $7
(i32.shr_s
(get_local $7)
(i32.const 1)
)
)
(br $continue|1)
@ -4721,33 +4720,29 @@
)
)
)
(set_local $6
(set_local $8
(i32.shr_s
(get_local $4)
(get_local $7)
(i32.const 1)
)
)
(set_local $7
(set_local $9
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $6)
(get_local $8)
(i32.const 2)
)
)
)
)
(set_local $8
(set_local $10
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $3)
(get_local $6)
(i32.const 2)
)
)
@ -4760,8 +4755,8 @@
(i32.const 2)
)
(call_indirect (type $iii)
(get_local $7)
(get_local $8)
(get_local $9)
(get_local $10)
(get_local $1)
)
)
@ -4770,10 +4765,10 @@
(block
(i32.store
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $3)
(get_local $6)
(i32.const 5)
)
(i32.const 2)
@ -4782,10 +4777,10 @@
(i32.xor
(i32.load
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $3)
(get_local $6)
(i32.const 5)
)
(i32.const 2)
@ -4795,7 +4790,7 @@
(i32.shl
(i32.const 1)
(i32.and
(get_local $3)
(get_local $6)
(i32.const 31)
)
)
@ -4803,34 +4798,30 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(i32.shl
(get_local $3)
(i32.const 2)
)
)
(get_local $7)
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $6)
(i32.const 2)
)
)
(get_local $8)
(get_local $9)
)
(i32.store
(i32.add
(get_local $5)
(i32.shl
(get_local $8)
(i32.const 2)
)
)
(get_local $10)
)
)
)
)
(set_local $3
(set_local $6
(i32.sub
(get_local $3)
(get_local $6)
(i32.const 1)
)
)
@ -4840,7 +4831,7 @@
)
)
(block $break|2
(set_local $3
(set_local $6
(i32.sub
(get_local $2)
(i32.const 1)
@ -4849,29 +4840,23 @@
(loop $continue|2
(if
(i32.ge_s
(get_local $3)
(get_local $6)
(i32.const 2)
)
(block
(block
(set_local $7
(set_local $10
(i32.load
(i32.load
(get_local $0)
)
(get_local $5)
)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $5)
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $3)
(get_local $6)
(i32.const 2)
)
)
@ -4879,37 +4864,35 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $3)
(get_local $6)
(i32.const 2)
)
)
(get_local $7)
(get_local $10)
)
(set_local $11
(set_local $9
(i32.const 1)
)
(block $break|3
(loop $continue|3
(if
(i32.lt_s
(tee_local $5
(tee_local $8
(i32.add
(i32.shl
(get_local $11)
(get_local $9)
(i32.const 1)
)
(i32.and
(i32.shr_s
(i32.load
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $11)
(get_local $9)
(i32.const 5)
)
(i32.const 2)
@ -4917,7 +4900,7 @@
)
)
(i32.and
(get_local $11)
(get_local $9)
(i32.const 31)
)
)
@ -4925,13 +4908,11 @@
)
)
)
(get_local $3)
(get_local $6)
)
(block
(block
(set_local $11
(get_local $5)
)
(set_local $9
(get_local $8)
)
(br $continue|3)
)
@ -4942,26 +4923,22 @@
(loop $continue|4
(if
(i32.gt_s
(get_local $11)
(get_local $9)
(i32.const 0)
)
(block
(block
(set_local $7
(set_local $10
(i32.load
(i32.load
(get_local $0)
)
(get_local $5)
)
)
(set_local $8
(set_local $7
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $11)
(get_local $9)
(i32.const 2)
)
)
@ -4974,8 +4951,8 @@
(i32.const 2)
)
(call_indirect (type $iii)
(get_local $10)
(get_local $7)
(get_local $8)
(get_local $1)
)
)
@ -4984,10 +4961,10 @@
(block
(i32.store
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $11)
(get_local $9)
(i32.const 5)
)
(i32.const 2)
@ -4996,10 +4973,10 @@
(i32.xor
(i32.load
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $11)
(get_local $9)
(i32.const 5)
)
(i32.const 2)
@ -5009,7 +4986,7 @@
(i32.shl
(i32.const 1)
(i32.and
(get_local $11)
(get_local $9)
(i32.const 31)
)
)
@ -5017,27 +4994,23 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $11)
(get_local $9)
(i32.const 2)
)
)
(get_local $7)
(get_local $10)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $8)
(get_local $5)
(get_local $7)
)
)
)
(set_local $11
(set_local $9
(i32.shr_s
(get_local $11)
(get_local $9)
(i32.const 1)
)
)
@ -5048,9 +5021,9 @@
)
)
)
(set_local $3
(set_local $6
(i32.sub
(get_local $3)
(get_local $6)
(i32.const 1)
)
)
@ -5060,30 +5033,22 @@
)
)
(call $~lib/allocator/arena/free_memory
(get_local $10)
(get_local $4)
)
(set_local $12
(set_local $11
(i32.load offset=4
(i32.load
(get_local $0)
)
(get_local $5)
)
)
(i32.store offset=4
(get_local $5)
(i32.load
(get_local $0)
)
(i32.load
(i32.load
(get_local $0)
)
(get_local $5)
)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $12)
(get_local $5)
(get_local $11)
)
(return
(get_local $0)