// File: attractivechaos[P]udb2/kbtree/test.c
// Function: test_int
uint32_t test_int(uint32_t n, uint32_t x0)
{
	uint32_t i, x, z = 0;
	kbtree_t(32) *h;
	h = kb_init(32, KB_DEFAULT_SIZE);
	for (i = 0, x = x0; i < n; ++i) {
		aux_t a, *p;
		x = hash32(x);
		a.key = get_key(n, x), a.cnt = 1;
		p = kb_getp(32, h, &a);
		if (p == 0) {
			kb_putp(32, h, &a);
			++z;
		} else z += ++p->cnt;
	}
	fprintf(stderr, "# unique keys: %d; checksum: %u\n", kb_size(h), z);
	x = kb_size(h);
	kb_destroy(32, h);
	return x;
}

// Assembly:
subq $0x58, %rsp
movl %edi, 0x54(%rsp)
movl %esi, 0x50(%rsp)
movl $0x0, 0x44(%rsp)
movl $0x200, %edi            # imm = 0x200
callq 0x1850
movq %rax, 0x38(%rsp)
movl $0x0, 0x4c(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x48(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x54(%rsp), %eax
jae 0x1677
movl 0x48(%rsp), %edi
callq 0x1250
movl %eax, 0x48(%rsp)
movl 0x54(%rsp), %edi
movl 0x48(%rsp), %esi
callq 0x12c0
movl %eax, 0x30(%rsp)
movl $0x1, 0x34(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1960
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x164f
movq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1a30
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x1665
movq 0x28(%rsp), %rcx
movl 0x4(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x4(%rcx)
addl 0x44(%rsp), %eax
movl %eax, 0x44(%rsp)
jmp 0x1667
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x15e3
movq 0x397a(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq 0x38(%rsp), %rax
movl 0x20(%rax), %edx
movl 0x44(%rsp), %ecx
leaq 0x19e1(%rip), %rsi      # 0x3075
movb $0x0, %al
callq 0x1060
movq 0x38(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x48(%rsp)
movl $0x8, 0x20(%rsp)
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x1827
movslq 0x20(%rsp), %rdi
movl $0x8, %esi
callq 0x1050
movq %rax, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rcx
movq 0x10(%rsp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rax
je 0x1825
movq 0x10(%rsp), %rax
movq %rax, %rcx
addq $-0x8, %rcx
movq %rcx, 0x10(%rsp)
movq -0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl (%rax), %eax
shll $0x1f, %eax
sarl $0x1f, %eax
cmpl $0x0, %eax
jne 0x1741
movq 0x18(%rsp), %rdi
callq 0x1030
jmp 0x16f9
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0x18(%rsp), %rcx
movl (%rcx), %ecx
sarl %ecx
cmpl %ecx, %eax
jg 0x1816
movq 0x18(%rsp), %rax
movq 0x38(%rsp), %rcx
movslq 0xc(%rcx), %rcx
addq %rcx, %rax
movslq 0x24(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x1804
movq 0x10(%rsp), %rax
movq 0x8(%rsp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movslq 0x20(%rsp), %rcx
cmpq %rcx, %rax
jne 0x17d6
movl 0x20(%rsp), %eax
shll %eax
movl %eax, 0x20(%rsp)
movq 0x8(%rsp), %rdi
movslq 0x20(%rsp), %rsi
shlq $0x3, %rsi
callq 0x1080
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl 0x20(%rsp), %ecx
sarl %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rax
movq 0x38(%rsp), %rcx
movslq 0xc(%rcx), %rcx
addq %rcx, %rax
movslq 0x24(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x10(%rsp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
jmp 0x1806
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x1749
movq 0x18(%rsp), %rdi
callq 0x1030
jmp 0x16f9
jmp 0x1827
movq 0x38(%rsp), %rdi
callq 0x1030
movq 0x8(%rsp), %rdi
callq 0x1030
movl 0x48(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)