// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl $0x3567e00, %edi        # imm = 0x3567E00
callq 0x10b0
movq %rax, %r12
xorl %ecx, %ecx
movl $0x3d090, %esi          # imm = 0x3D090
xorl %edi, %edi
movl %ecx, %eax
xorl %edx, %edx
divl %esi
cmpq $0x3567e00, %rdi        # imm = 0x3567E00
je 0x261f
movl %edx, (%r12,%rdi)
addq $0x38, %rdi
incl %ecx
jmp 0x2604
leaq 0x3c9d(%rip), %rdi      # 0x62c3
callq 0x127d
movl $0xf4240, %r13d         # imm = 0xF4240
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x122b
movq %rax, 0x10(%rsp)
leal (%rax,%rax,4), %eax
movl %eax, (%rsp)
xorl %ebx, %ebx
leaq 0x20(%rsp), %r15
cmpl (%rsp), %ebx
ja 0x278d
movl %ebx, %ebp
cmovel %r13d, %ebp
movq %r15, %rdi
callq 0x4718
movq %r12, %r14
movq %rbp, 0x8(%rsp)
subq $0x1, %rbp
jb 0x268a
leaq 0x8(%r14), %rsi
movslq (%r14), %rcx
movq %r15, %rdi
movq %r14, %rdx
callq 0x4750
addq $0x38, %r14
jmp 0x266c
movl (%rsp), %eax
cmpl %eax, %ebx
cmovel %r13d, %eax
movl %eax, (%rsp)
movq %r15, %rdi
callq 0x48fc
movq 0x8(%rsp), %rbx
leaq (,%rbx,8), %rcx
cmpq %rcx, %rax
jb 0x2906
cmpq %rbx, 0x38(%rsp)
jne 0x2906
andl $0x0, 0x100874a(%rip)   # 0x100ae10
movq %r15, %rdi
leaq -0x8ea(%rip), %rsi      # 0x1de6
callq 0x486c
cmpl %ebx, 0x1008735(%rip)   # 0x100ae10
jne 0x2906
movl %ebx, %r13d
shrl %r13d
decl %ebx
movl %ebx, %r14d
movq %r13, %rbp
subq $0x1, %rbp
jb 0x2711
movl %r14d, %eax
imulq $0x38, %rax, %rax
leaq (%r12,%rax), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x47a4
decl %r14d
jmp 0x26ef
movq %r13, %r14
leaq -0x144(%rip), %rbp      # 0x25d7
subq $0x1, %r14
jb 0x276c
movl %ebx, %eax
imulq $0x38, %rax, %rax
leaq (%r12,%rax), %rdx
movslq (%r12,%rax), %rcx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x47f8
decl %ebx
testq %rax, %rax
je 0x271b
jmp 0x2906
decq %r13
movl %r13d, %eax
imulq $0x38, %rax, %rax
leaq (%r12,%rax), %rdx
movslq (%r12,%rax), %rcx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x47f8
testq %rax, %rax
je 0x2906
testq %r13, %r13
jne 0x2746
movq %r15, %rdi
callq 0x4748
movq 0x8(%rsp), %rax
incl %eax
movl %eax, %ebx
movl $0xf4240, %r13d         # imm = 0xF4240
jmp 0x264d
callq 0x12cf
leaq 0x3b38(%rip), %rdi      # 0x62d1
callq 0x127d
movq 0x10(%rsp), %rax
shrl $0x4, %eax
movq %rax, 0x10(%rsp)
movq %r12, 0x8(%rsp)
leaq 0x8(%r12), %rax
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
movl $0xf4240, %ebp          # imm = 0xF4240
leaq 0x20(%rsp), %r12
cmpl 0x10(%rsp), %r14d
ja 0x28f2
movl %r14d, %r15d
cmovel %ebp, %r15d
movq %r12, %rdi
callq 0x4718
movq 0x8(%rsp), %rbx
movq %r15, (%rsp)
subq $0x1, %r15
jb 0x2808
leaq 0x8(%rbx), %rsi
movslq (%rbx), %rcx
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4750
addq $0x38, %rbx
jmp 0x27ea
movq 0x10(%rsp), %rax
cmpl %eax, %r14d
cmovel %ebp, %eax
movq %rax, 0x10(%rsp)
andl $0x0, 0x10085f1(%rip)   # 0x100ae10
movq %r12, %rdi
leaq -0xa3c(%rip), %rsi      # 0x1ded
leaq 0x10085e0(%rip), %rdx   # 0x100ae10
callq 0x48ad
movq (%rsp), %rax
cmpl %eax, 0x10085d1(%rip)   # 0x100ae10
jne 0x2906
imulq $0x38, %rax, %r13
movq 0x8(%rsp), %rbx
addq %rbx, %r13
pushq $-0x1
popq %rbp
movq 0x18(%rsp), %r14
xorl %r15d, %r15d
addq %r15, %rax
cmpq $0xf4240, %rax          # imm = 0xF4240
jae 0x28a2
leaq 0x8(%r13), %rsi
movslq (%r13), %rcx
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r13, %rdx
callq 0x4750
movq %r12, %rdi
movq %r14, %rsi
callq 0x47a4
incq %r15
addq $0x38, %r13
addq $0x38, %r14
addq $0x38, %rbx
incq %rbp
movq (%rsp), %rax
jmp 0x285c
leaq 0x20(%rsp), %r12
leaq -0x2d7(%rip), %r15      # 0x25d7
incq %rbp
cmpq $0xf423f, %rbp          # imm = 0xF423F
ja 0x28d9
leaq 0x38(%rbx), %r14
movslq (%rbx), %rcx
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x47f8
movq %r14, %rbx
testq %rax, %rax
jne 0x28ae
jmp 0x2906
movq %r12, %rdi
callq 0x4748
movq (%rsp), %r14
incl %r14d
movl $0xf4240, %ebp          # imm = 0xF4240
jmp 0x27c7
callq 0x12cf
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1040