// File: /workspace/github_cpp_makefile_star2_O3/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 0x10c0
movq %rax, %rbx
xorl %eax, %eax
xorl %ecx, %ecx
movl %eax, %edx
imulq $0x431bde83, %rdx, %rdx # imm = 0x431BDE83
shrq $0x30, %rdx
imull $0x3d090, %edx, %edx    # imm = 0x3D090
movl %eax, %esi
subl %edx, %esi
movl %esi, (%rbx,%rcx)
addq $0x38, %rcx
incl %eax
cmpq $0x3567e00, %rcx        # imm = 0x3567E00
jne 0x33ba
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x5a59
movl $0xf4240, %r12d         # imm = 0xF4240
movq %rbx, %r15
leaq 0x8(%r15), %rsi
movslq (%r15), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x5b76
addq $0x38, %r15
decq %r12
jne 0x33f9
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 0x37ae
leaq 0x20(%rsp), %rdi
callq 0x5b2a
movq $-0x20, %rax
leaq 0x89a2(%rip), %rcx      # 0xbe10
incb 0x20(%rax,%rcx)
addq $0x20, %rax
cmpq $0xffffe0, %rax         # imm = 0xFFFFE0
jb 0x346e
movl $0x0, 0x8978(%rip)      # 0xbe00
leaq 0x3e50(%rip), %rax      # 0x72df
movq %rax, 0x100897a(%rip)   # 0x100be10
callq 0x12e3
movq %rax, 0x1008976(%rip)   # 0x100be18
movl $0x1388, %ebp           # imm = 0x1388
xorl %r15d, %r15d
leaq 0x20(%rsp), %r14
cmpl %ebp, %r15d
movl $0xf4240, %eax          # imm = 0xF4240
cmovel %eax, %ebp
cmovel %eax, %r15d
movq %r14, %rdi
callq 0x5a59
testl %r15d, %r15d
movq %r15, 0x8(%rsp)
je 0x34f7
movl %r15d, %r15d
movq %r15, %r12
movq %rbx, %r13
leaq 0x8(%r13), %rsi
movslq (%r13), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x5b76
addq $0x38, %r13
decq %r12
jne 0x34d9
jmp 0x34fa
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x6243
leaq (,%r15,8), %rcx
cmpq %rcx, %rax
jb 0x37ae
movl %ebp, (%rsp)
cmpq %r15, 0x248(%rsp)
jne 0x37ae
movl $0x0, 0x10088f2(%rip)   # 0x100be20
movq %r14, %rdi
leaq -0x1240(%rip), %rsi     # 0x22f8
callq 0x6175
movq 0x8(%rsp), %r15
cmpl %r15d, 0x10088d7(%rip)  # 0x100be20
jne 0x37ae
cmpl $0x2, %r15d
jb 0x35f9
movl %r15d, %eax
shrl %eax
movl %eax, %r12d
leal -0x1(%r15), %ebp
movq %r12, %r13
movl %ebp, %r15d
movl %r15d, %eax
imulq $0x38, %rax, %rax
leaq (%rbx,%rax), %rsi
addq $0x8, %rsi
movq %r14, %rdi
callq 0x5d74
decl %r15d
decq %r13
jne 0x356b
movq %r12, %r13
movq 0x8(%rsp), %r15
cmpl $0x2, %r15d
jb 0x35f9
movl %ebp, %eax
imulq $0x38, %rax, %rax
leaq (%rbx,%rax), %rdx
movslq (%rbx,%rax), %rcx
movq %r14, %rdi
leaq -0x5ad(%rip), %rsi      # 0x3003
callq 0x5f4f
testq %rax, %rax
jne 0x37ae
decl %ebp
decq %r13
jne 0x3598
cmpl $0x2, %r15d
jb 0x35f9
leal -0x1(%r12), %eax
imulq $0x38, %rax, %rax
leaq (%rbx,%rax), %rdx
movslq (%rbx,%rax), %rcx
movq %r14, %rdi
leaq -0x5e3(%rip), %rsi      # 0x3003
callq 0x5f4f
testq %rax, %rax
je 0x37ae
decq %r12
jne 0x35cb
movq %r14, %rdi
callq 0x5b2a
incl %r15d
movl (%rsp), %ebp
cmpl %ebp, %r15d
jbe 0x34af
callq 0x1312
movq $-0x20, %rax
leaq 0x87ed(%rip), %rcx      # 0xbe10
incb 0x20(%rax,%rcx)
addq $0x20, %rax
cmpq $0xffffe0, %rax         # imm = 0xFFFFE0
jb 0x3623
movl $0x0, 0x87c3(%rip)      # 0xbe00
leaq 0x3ca9(%rip), %rax      # 0x72ed
movq %rax, 0x10087c5(%rip)   # 0x100be10
callq 0x12e3
movq %rax, 0x10087c1(%rip)   # 0x100be18
leaq 0x8(%rbx), %rax
movq %rax, 0x18(%rsp)
movl $0x3e, %r12d
xorl %r15d, %r15d
leaq 0x20(%rsp), %r14
leaq -0x672(%rip), %r13      # 0x3003
cmpl %r12d, %r15d
movl $0xf4240, %eax          # imm = 0xF4240
cmovel %eax, %r12d
cmovel %eax, %r15d
movq %r14, %rdi
callq 0x5a59
movl %r15d, %eax
movq %rax, (%rsp)
movq %r15, 0x8(%rsp)
testl %r15d, %r15d
je 0x36c1
movq (%rsp), %r15
movq %rbx, %rbp
leaq 0x8(%rbp), %rsi
movslq (%rbp), %rcx
movq %r14, %rdi
movq %rbp, %rdx
callq 0x5b76
addq $0x38, %rbp
decq %r15
jne 0x36a5
movl $0x0, 0x1008755(%rip)   # 0x100be20
movq %r14, %rdi
leaq -0x13d6(%rip), %rsi     # 0x22ff
leaq 0x1008744(%rip), %rdx   # 0x100be20
callq 0x61d5
movq 0x8(%rsp), %rbp
cmpl %ebp, 0x1008734(%rip)   # 0x100be20
jne 0x37ae
xorl %eax, %eax
cmpl $0xf423f, %ebp          # imm = 0xF423F
ja 0x3755
movl %r12d, 0x14(%rsp)
movl $0xf4240, %r12d         # imm = 0xF4240
subl %ebp, %r12d
imulq $0x38, (%rsp), %r15
movq %r12, (%rsp)
movq 0x18(%rsp), %rbp
leaq (%r15,%rbp), %rsi
leaq (%r15,%rbp), %rdx
addq $-0x8, %rdx
movslq (%rdx), %rcx
movq %r14, %rdi
callq 0x5b76
movq %r14, %rdi
movq %rbp, %rsi
callq 0x5d74
addq $0x38, %rbp
decq %r12
jne 0x3718
movq 0x8(%rsp), %rbp
testl %ebp, %ebp
movl 0x14(%rsp), %r12d
movq (%rsp), %rax
je 0x3780
movl %eax, %eax
imulq $0x38, %rax, %r15
leaq (%rbx,%r15), %rdx
movslq (%rbx,%r15), %rcx
movq %r14, %rdi
movq %r13, %rsi
callq 0x5f4f
testq %rax, %rax
je 0x37ae
addq $0x38, %r15
cmpq $0x3567e00, %r15        # imm = 0x3567E00
jne 0x375b
movq %r14, %rdi
callq 0x5b2a
leal 0x1(%rbp), %eax
cmpl %r12d, %ebp
movl %eax, %r15d
jb 0x3675
callq 0x1312
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1040