// File: /workspace/github_cpp_makefile_star2_O2/amadvance[P]tommyds/check.c
// Function: test_hashlin
void test_hashlin(void)
{
	tommy_hashlin hashlin;
	struct object_hash* HASH;
	unsigned i, j, n;
	unsigned limit;
	const unsigned size = TOMMY_SIZE;
	const unsigned module = TOMMY_SIZE / 4;
	tommy_hashlin_node* bucket;

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

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

	tommy_hashlin_init(&hashlin);

	/* insert */
	for(i=0;i<size;++i)
		tommy_hashlin_insert(&hashlin, &HASH[i].node, &HASH[i], HASH[i].value);

	/* get the bucket of the last element */
	bucket = tommy_hashlin_bucket(&hashlin, module - 1);
	if (bucket == 0)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	/* deinitialize without removing elements to force deallocation */
	tommy_hashlin_done(&hashlin);

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

		tommy_hashlin_init(&hashlin);

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

		if (tommy_hashlin_memory_usage(&hashlin) < n * sizeof(void*))
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

		if (tommy_hashlin_count(&hashlin) != n)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

		the_count = 0;
		tommy_hashlin_foreach(&hashlin, 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_hashlin_remove_existing(&hashlin, &HASH[n-i-1].node);

		/* remove missing */
		for(i=0;i<n/2;++i)
			if (tommy_hashlin_remove(&hashlin, 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_hashlin_remove(&hashlin, search_callback, &HASH[n/2-i-1], HASH[n/2-i-1].value) == 0)
				/* LCOV_EXCL_START */
				abort();
				/* LCOV_EXCL_STOP */

		tommy_hashlin_done(&hashlin);
	}
	STOP();

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

		tommy_hashlin_init(&hashlin);

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

		the_count = 0;
		tommy_hashlin_foreach_arg(&hashlin, 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_hashlin_insert(&hashlin, &HASH[i].node, &HASH[i], HASH[i].value);

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

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

		tommy_hashlin_done(&hashlin);
	}
	STOP();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl $0x3567e00, %edi        # imm = 0x3567E00
callq 0x10b0
movq %rax, %r14
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 0x294d
movl %edx, (%r14,%rdi)
addq $0x38, %rdi
incl %ecx
jmp 0x2932
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x490d
movl $0xf4240, %r15d         # imm = 0xF4240
movq %r14, 0x8(%rsp)
subq $0x1, %r15
jb 0x2983
leaq 0x8(%r14), %rsi
movslq (%r14), %rcx
movq %rbx, %rdi
movq %r14, %rdx
callq 0x49be
addq $0x38, %r14
jmp 0x2965
movl $0x3d08f, %eax          # imm = 0x3D08F
movq 0x238(%rsp), %rcx
andq %rax, %rcx
andq 0x228(%rsp), %rax
cmpq 0x240(%rsp), %rcx
cmovaeq %rcx, %rax
movq %rax, %rcx
orq $0x1, %rcx
bsrq %rcx, %rcx
shll $0x3, %ecx
movq 0x20(%rsp,%rcx), %rcx
cmpq $0x0, (%rcx,%rax,8)
je 0x2cac
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x497a
leaq 0x3906(%rip), %rdi      # 0x62df
callq 0x127d
movl $0xf4240, %ebp          # imm = 0xF4240
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x122b
movq %rax, 0x18(%rsp)
leal (%rax,%rax,4), %eax
movl %eax, (%rsp)
xorl %ebx, %ebx
leaq -0x42a(%rip), %r13      # 0x25d7
movq 0x8(%rsp), %r14
cmpl (%rsp), %ebx
ja 0x2b45
movl %ebx, %r12d
cmovel %ebp, %r12d
movq %r15, %rdi
callq 0x490d
movq %r12, 0x10(%rsp)
subq $0x1, %r12
jb 0x2a41
leaq 0x8(%r14), %rsi
movslq (%r14), %rcx
movq %r15, %rdi
movq %r14, %rdx
callq 0x49be
addq $0x38, %r14
jmp 0x2a23
movl (%rsp), %eax
cmpl %eax, %ebx
cmovel %ebp, %eax
movl %eax, (%rsp)
movq %r15, %rdi
callq 0x4e41
movq 0x10(%rsp), %rbx
leaq (,%rbx,8), %rcx
cmpq %rcx, %rax
jb 0x2cac
cmpq %rbx, 0x248(%rsp)
jne 0x2cac
andl $0x0, 0x1008391(%rip)   # 0x100ae10
movq %r15, %rdi
leaq -0xca3(%rip), %rsi      # 0x1de6
callq 0x4d79
cmpl %ebx, 0x100837c(%rip)   # 0x100ae10
jne 0x2cac
movl %ebx, %ebp
shrl %ebp
decl %ebx
movl %ebx, %r12d
movq %rbp, %r14
subq $0x1, %r14
jb 0x2acd
movl %r12d, %eax
imulq $0x38, %rax, %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x4b94
decl %r12d
jmp 0x2aa6
movq %rbp, %r12
movq 0x8(%rsp), %r14
subq $0x1, %r12
jb 0x2b25
movl %ebx, %eax
imulq $0x38, %rax, %rax
leaq (%r14,%rax), %rdx
movslq (%r14,%rax), %rcx
movq %r15, %rdi
movq %r13, %rsi
callq 0x4d04
decl %ebx
testq %rax, %rax
je 0x2ad5
jmp 0x2cac
decq %rbp
movl %ebp, %eax
imulq $0x38, %rax, %rax
leaq (%r14,%rax), %rdx
movslq (%r14,%rax), %rcx
movq %r15, %rdi
movq %r13, %rsi
callq 0x4d04
testq %rax, %rax
je 0x2cac
testq %rbp, %rbp
jne 0x2b00
movq %r15, %rdi
callq 0x497a
movq 0x10(%rsp), %rax
incl %eax
movl %eax, %ebx
movl $0xf4240, %ebp          # imm = 0xF4240
jmp 0x2a06
callq 0x12cf
leaq 0x379c(%rip), %rdi      # 0x62ed
callq 0x127d
movq 0x18(%rsp), %r13
shrl $0x4, %r13d
leaq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
movl $0xf4240, %ebp          # imm = 0xF4240
leaq 0x20(%rsp), %r15
cmpl %r13d, %r14d
ja 0x2c95
movl %r14d, %r12d
cmovel %ebp, %r12d
movq %r15, %rdi
callq 0x490d
movq 0x8(%rsp), %rbx
movq %r12, (%rsp)
subq $0x1, %r12
jb 0x2bb4
leaq 0x8(%rbx), %rsi
movslq (%rbx), %rcx
movq %r15, %rdi
movq %rbx, %rdx
callq 0x49be
addq $0x38, %rbx
jmp 0x2b96
cmpl %r13d, %r14d
cmovel %ebp, %r13d
movq %r13, 0x18(%rsp)
andl $0x0, 0x1008249(%rip)   # 0x100ae10
movq %r15, %rdi
leaq -0xde4(%rip), %rsi      # 0x1ded
leaq 0x1008238(%rip), %rdx   # 0x100ae10
callq 0x4dd6
movq (%rsp), %rax
cmpl %eax, 0x1008229(%rip)   # 0x100ae10
jne 0x2cac
imulq $0x38, %rax, %r13
movq 0x8(%rsp), %rbx
addq %rbx, %r13
pushq $-0x1
popq %rbp
movq 0x10(%rsp), %r14
xorl %r12d, %r12d
addq %r12, %rax
cmpq $0xf4240, %rax          # imm = 0xF4240
jae 0x2c45
leaq 0x8(%r13), %rsi
movslq (%r13), %rcx
movq %r15, %rdi
movq %r13, %rdx
callq 0x49be
movq %r15, %rdi
movq %r14, %rsi
callq 0x4b94
incq %r12
addq $0x38, %r13
addq $0x38, %r14
addq $0x38, %rbx
incq %rbp
movq (%rsp), %rax
jmp 0x2c04
movq 0x18(%rsp), %r13
leaq -0x67a(%rip), %r12      # 0x25d7
incq %rbp
cmpq $0xf423f, %rbp          # imm = 0xF423F
ja 0x2c7c
leaq 0x38(%rbx), %r14
movslq (%rbx), %rcx
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x4d04
movq %r14, %rbx
testq %rax, %rax
jne 0x2c51
jmp 0x2cac
movq %r15, %rdi
callq 0x497a
movq (%rsp), %r14
incl %r14d
movl $0xf4240, %ebp          # imm = 0xF4240
jmp 0x2b75
callq 0x12cf
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1040