// File: amadvance[P]tommyds/check.c
// Function: test_hashdyn
void test_hashdyn(void)
{
	tommy_hashdyn hashdyn;
	struct object_hash* HASH;
	unsigned i, j, n;
	unsigned limit;
	const unsigned size = TOMMY_SIZE;
	const unsigned module = TOMMY_SIZE / 4;

	HASH = malloc(size * sizeof(struct object_hash));

	for(i=0;i<size;++i)
		HASH[i].value = i % module;

	START("hashdyn stack");
	limit = 5 * isqrt(size);
	for(n=0;n<=limit;++n) {
		/* last iteration is full size */
		if (n == limit)
			n = limit = size;

		tommy_hashdyn_init(&hashdyn);

		/* insert */
		for(i=0;i<n;++i)
			tommy_hashdyn_insert(&hashdyn, &HASH[i].node, &HASH[i], HASH[i].value);

		if (tommy_hashdyn_memory_usage(&hashdyn) < n * sizeof(void*))
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

		if (tommy_hashdyn_count(&hashdyn) != n)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

		the_count = 0;
		tommy_hashdyn_foreach(&hashdyn, count_callback);
		if (the_count != n)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

		/* remove in backward order */
		for(i=0;i<n/2;++i)
			tommy_hashdyn_remove_existing(&hashdyn, &HASH[n-i-1].node);

		/* remove missing */
		for(i=0;i<n/2;++i)
			if (tommy_hashdyn_remove(&hashdyn, search_callback, &HASH[n-i-1], HASH[n-i-1].value) != 0)
				/* LCOV_EXCL_START */
				abort();
				/* LCOV_EXCL_STOP */

		/* remove search */
		for(i=0;i<n/2;++i)
			if (tommy_hashdyn_remove(&hashdyn, search_callback, &HASH[n/2-i-1], HASH[n/2-i-1].value) == 0)
				/* LCOV_EXCL_START */
				abort();
				/* LCOV_EXCL_STOP */

		tommy_hashdyn_done(&hashdyn);
	}
	STOP();

	START("hashdyn queue");
	limit = isqrt(size) / 16;
	for(n=0;n<=limit;++n) {
		/* last iteration is full size */
		if (n == limit)
			n = limit = size;

		tommy_hashdyn_init(&hashdyn);

		/* insert first run */
		for(j=0,i=0;i<n;++i)
			tommy_hashdyn_insert(&hashdyn, &HASH[i].node, &HASH[i], HASH[i].value);

		the_count = 0;
		tommy_hashdyn_foreach_arg(&hashdyn, count_arg_callback, &the_count);
		if (the_count != n)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

		/* insert all the others */
		for(;i<size;++i,++j) {
			/* insert one */
			tommy_hashdyn_insert(&hashdyn, &HASH[i].node, &HASH[i], HASH[i].value);

			/* remove one */
			tommy_hashdyn_remove_existing(&hashdyn, &HASH[j].node);
		}

		for(;j<size;++j)
			if (tommy_hashdyn_remove(&hashdyn, search_callback, &HASH[j], HASH[j].value) == 0)
				/* LCOV_EXCL_START */
				abort();
				/* LCOV_EXCL_STOP */

		tommy_hashdyn_done(&hashdyn);
	}
	STOP();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0xf4240, -0x44(%rbp)   # imm = 0xF4240
movl $0x3d090, -0x48(%rbp)   # imm = 0x3D090
movl $0x3567e00, %edi        # imm = 0x3567E00
callq 0x10b0
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0xf4240, -0x34(%rbp)   # imm = 0xF4240
jae 0x341b
movl -0x34(%rbp), %eax
movl $0x3d090, %ecx          # imm = 0x3D090
xorl %edx, %edx
divl %ecx
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x33eb
leaq 0x6e85(%rip), %rdi      # 0xa2a7
callq 0x13e0
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x1310
imull $0x5, %eax, %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
ja 0x3647
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jne 0x3460
movl $0xf4240, -0x40(%rbp)   # imm = 0xF4240
movl $0xf4240, -0x3c(%rbp)   # imm = 0xF4240
leaq -0x28(%rbp), %rdi
callq 0x7e60
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x34bd
movq -0x30(%rbp), %rsi
movl -0x34(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x30(%rbp), %rdx
movl -0x34(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rcx
leaq -0x28(%rbp), %rdi
callq 0x7f00
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3470
leaq -0x28(%rbp), %rdi
callq 0x8290
movl -0x3c(%rbp), %ecx
shlq $0x3, %rcx
cmpq %rcx, %rax
jae 0x34d7
callq 0x1040
leaq -0x28(%rbp), %rdi
callq 0x3810
movl -0x3c(%rbp), %ecx
cmpq %rcx, %rax
je 0x34ed
callq 0x1040
movl $0x0, 0x100b919(%rip)   # 0x100ee10
leaq -0x28(%rbp), %rdi
leaq -0xec2(%rip), %rsi      # 0x2640
callq 0x8160
movl 0x100b903(%rip), %eax   # 0x100ee10
cmpl -0x3c(%rbp), %eax
je 0x3517
callq 0x1040
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x3c(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0x3558
movq -0x30(%rbp), %rsi
movl -0x3c(%rbp), %eax
subl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
leaq -0x28(%rbp), %rdi
callq 0x7fd0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x351e
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x3c(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0x35c2
movq -0x30(%rbp), %rdx
movl -0x3c(%rbp), %eax
subl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl -0x34(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rcx
leaq -0x28(%rbp), %rdi
leaq -0x205(%rip), %rsi      # 0x33a0
callq 0x8090
cmpq $0x0, %rax
je 0x35b5
callq 0x1040
jmp 0x35b7
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x355f
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x3c(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0x3630
movq -0x30(%rbp), %rdx
movl -0x3c(%rbp), %eax
shrl %eax
subl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
shrl %ecx
subl -0x34(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rcx
leaq -0x28(%rbp), %rdi
leaq -0x273(%rip), %rsi      # 0x33a0
callq 0x8090
cmpq $0x0, %rax
jne 0x3623
callq 0x1040
jmp 0x3625
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x35c9
leaq -0x28(%rbp), %rdi
callq 0x7ee0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x343e
callq 0x1460
leaq 0x6c62(%rip), %rdi      # 0xa2b5
callq 0x13e0
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x1310
shrl $0x4, %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
ja 0x3803
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jne 0x3691
movl $0xf4240, -0x40(%rbp)   # imm = 0xF4240
movl $0xf4240, -0x3c(%rbp)   # imm = 0xF4240
leaq -0x28(%rbp), %rdi
callq 0x7e60
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x36f5
movq -0x30(%rbp), %rsi
movl -0x34(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x30(%rbp), %rdx
movl -0x34(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rcx
leaq -0x28(%rbp), %rdi
callq 0x7f00
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x36a8
movl $0x0, 0x100b711(%rip)   # 0x100ee10
leaq -0x28(%rbp), %rdi
leaq -0x10aa(%rip), %rsi     # 0x2660
leaq 0x100b6ff(%rip), %rdx   # 0x100ee10
callq 0x81f0
movl 0x100b6f4(%rip), %eax   # 0x100ee10
cmpl -0x3c(%rbp), %eax
je 0x3726
callq 0x1040
jmp 0x3728
cmpl $0xf4240, -0x34(%rbp)   # imm = 0xF4240
jae 0x379a
movq -0x30(%rbp), %rsi
movl -0x34(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x30(%rbp), %rdx
movl -0x34(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rcx
leaq -0x28(%rbp), %rdi
callq 0x7f00
movq -0x30(%rbp), %rsi
movl -0x38(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
leaq -0x28(%rbp), %rdi
callq 0x7fd0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x3728
jmp 0x379c
cmpl $0xf4240, -0x38(%rbp)   # imm = 0xF4240
jae 0x37ec
movq -0x30(%rbp), %rdx
movl -0x38(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rcx
leaq -0x28(%rbp), %rdi
leaq -0x42f(%rip), %rsi      # 0x33a0
callq 0x8090
cmpq $0x0, %rax
jne 0x37df
callq 0x1040
jmp 0x37e1
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x379c
leaq -0x28(%rbp), %rdi
callq 0x7ee0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x366f
callq 0x1460
addq $0x50, %rsp
popq %rbp
retq
nop