// File: /workspace/github_cpp_makefile_star2_O1/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 0x340f
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x58de
movl $0xf4240, %r12d         # imm = 0xF4240
movq %rbx, %r15
leaq 0x8(%r15), %rsi
movslq (%r15), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x599e
addq $0x38, %r15
decq %r12
jne 0x344e
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 0x3809
leaq 0x20(%rsp), %rdi
callq 0x5952
movq $-0x20, %rax
leaq 0x794d(%rip), %rcx      # 0xae10
incb 0x20(%rax,%rcx)
addq $0x20, %rax
cmpq $0xffffe0, %rax         # imm = 0xFFFFE0
jb 0x34c3
movl $0x0, 0x7923(%rip)      # 0xae00
leaq 0x3dfb(%rip), %rax      # 0x72df
movq %rax, 0x1007925(%rip)   # 0x100ae10
callq 0x12e3
movq %rax, 0x1007921(%rip)   # 0x100ae18
movl $0x1388, %eax           # imm = 0x1388
xorl %ebp, %ebp
leaq 0x20(%rsp), %r14
leaq -0x4ca(%rip), %r12      # 0x3040
cmpl %eax, %ebp
movl $0xf4240, %ecx          # imm = 0xF4240
cmovel %ecx, %eax
movl %eax, 0x10(%rsp)
cmovel %ecx, %ebp
movq %r14, %rdi
callq 0x58de
movl %ebp, %eax
movq %rax, 0x8(%rsp)
testl %ebp, %ebp
je 0x3552
movq 0x8(%rsp), %r15
movq %rbx, %r13
leaq 0x8(%r13), %rsi
movslq (%r13), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x599e
addq $0x38, %r13
decq %r15
jne 0x3536
movq %r14, %rdi
callq 0x5f29
movq 0x8(%rsp), %rdx
leaq (,%rdx,8), %rcx
cmpq %rcx, %rax
jb 0x3809
cmpq %rdx, 0x248(%rsp)
jne 0x3809
movl $0x0, 0x1007898(%rip)   # 0x100ae20
movq %r14, %rdi
leaq -0x1264(%rip), %rsi     # 0x232e
callq 0x5e5b
cmpl %ebp, 0x1007883(%rip)   # 0x100ae20
jne 0x3809
movl %ebp, %eax
shrl %eax
movl %eax, 0x8(%rsp)
cmpl $0x2, %ebp
jb 0x35d8
movl 0x8(%rsp), %r15d
leal -0x1(%rbp), %r13d
movl %r13d, %eax
imulq $0x38, %rax, %rax
leaq (%rbx,%rax), %rsi
addq $0x8, %rsi
movq %r14, %rdi
callq 0x5bb0
decl %r13d
decq %r15
jne 0x35b9
cmpl $0x2, %ebp
jb 0x3611
movl 0x8(%rsp), %r15d
leal -0x1(%rbp), %r13d
movl %r13d, %eax
imulq $0x38, %rax, %rax
leaq (%rbx,%rax), %rdx
movslq (%rbx,%rax), %rcx
movq %r14, %rdi
movq %r12, %rsi
callq 0x5d8f
testq %rax, %rax
jne 0x3809
decl %r13d
decq %r15
jne 0x35e6
cmpl $0x2, %ebp
jb 0x3644
movl 0x8(%rsp), %r15d
leal -0x1(%r15), %eax
imulq $0x38, %rax, %rax
leaq (%rbx,%rax), %rdx
movslq (%rbx,%rax), %rcx
movq %r14, %rdi
movq %r12, %rsi
callq 0x5d8f
testq %rax, %rax
je 0x3809
decq %r15
jne 0x361b
movq %r14, %rdi
callq 0x5952
incl %ebp
movl 0x10(%rsp), %eax
cmpl %eax, %ebp
jbe 0x350a
callq 0x1312
movq $-0x20, %rax
leaq 0x77a3(%rip), %rcx      # 0xae10
incb 0x20(%rax,%rcx)
addq $0x20, %rax
cmpq $0xffffe0, %rax         # imm = 0xFFFFE0
jb 0x366d
movl $0x0, 0x7779(%rip)      # 0xae00
leaq 0x3c5f(%rip), %rax      # 0x72ed
movq %rax, 0x100777b(%rip)   # 0x100ae10
callq 0x12e3
movq %rax, 0x1007777(%rip)   # 0x100ae18
leaq 0x8(%rbx), %rax
movq %rax, 0x18(%rsp)
movl $0x3e, %ecx
xorl %r13d, %r13d
leaq 0x20(%rsp), %r14
leaq -0x67e(%rip), %r12      # 0x3040
cmpl %ecx, %r13d
movl $0xf4240, %eax          # imm = 0xF4240
cmovel %eax, %ecx
movl %ecx, 0x8(%rsp)
cmovel %eax, %r13d
movq %r14, %rdi
callq 0x58de
movl $0x0, %r15d
testl %r13d, %r13d
je 0x3713
movl %r13d, %r12d
movq %rbx, %rbp
xorl %r15d, %r15d
leaq 0x8(%rbp), %rsi
movslq (%rbp), %rcx
movq %r14, %rdi
movq %rbp, %rdx
callq 0x599e
incq %r15
addq $0x38, %rbp
cmpq %r15, %r12
jne 0x36ed
leaq -0x6d3(%rip), %r12      # 0x3040
movl $0x0, 0x1007703(%rip)   # 0x100ae20
movq %r14, %rdi
leaq -0x13f2(%rip), %rsi     # 0x2335
leaq 0x10076f2(%rip), %rdx   # 0x100ae20
callq 0x5ebb
movq %r13, 0x10(%rsp)
cmpl %r13d, 0x10076e1(%rip)  # 0x100ae20
jne 0x3809
xorl %r13d, %r13d
cmpl $0xf423f, %r15d         # imm = 0xF423F
ja 0x379e
movl %r15d, %eax
movl $0xf4240, %r12d         # imm = 0xF4240
subl %r15d, %r12d
imulq $0x38, %rax, %r15
movq 0x18(%rsp), %rbp
xorl %r13d, %r13d
leaq (%r15,%rbp), %rsi
leaq (%r15,%rbp), %rdx
addq $-0x8, %rdx
movslq (%rdx), %rcx
movq %r14, %rdi
callq 0x599e
movq %r14, %rdi
movq %rbp, %rsi
callq 0x5bb0
incq %r13
addq $0x38, %rbp
cmpq %r13, %r12
jne 0x3769
leaq -0x75e(%rip), %r12      # 0x3040
cmpl $0xf423f, %r13d         # imm = 0xF423F
ja 0x37d3
movl %r13d, %eax
imulq $0x38, %rax, %r15
leaq (%rbx,%r15), %rdx
movslq (%rbx,%r15), %rcx
movq %r14, %rdi
movq %r12, %rsi
callq 0x5d8f
testq %rax, %rax
je 0x3809
addq $0x38, %r15
cmpq $0x3567e00, %r15        # imm = 0x3567E00
jne 0x37ae
movq %r14, %rdi
callq 0x5952
movq 0x10(%rsp), %rdx
leal 0x1(%rdx), %eax
movl 0x8(%rsp), %ecx
cmpl %ecx, %edx
movl %eax, %r13d
jb 0x36be
callq 0x1312
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1040