// File: /workspace/github_cpp_makefile_star2_O2/amadvance[P]tommyds/check.c
// Function: test_tree
void test_tree(void)
{
	tommy_tree tree;
	struct object_tree* OBJ;
	unsigned i;
	const unsigned size = TOMMY_SIZE / 4;

	OBJ = malloc(size * sizeof(struct object_tree));

	START("tree");
	tommy_tree_init(&tree, &compare);

	/* forward order */
	for(i=0;i<size;++i)
		OBJ[i].value = i;

	/* insert */
	for(i=0;i<size;++i)
		if (tommy_tree_insert(&tree, &OBJ[i].node, &OBJ[i]) != &OBJ[i])
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

	if (tommy_tree_memory_usage(&tree) < size * sizeof(tommy_tree_node))
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	if (tommy_tree_count(&tree) != size)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	the_count = 0;
	tommy_tree_foreach(&tree, count_callback);
	if (the_count != size)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	the_count = 0;
	tommy_tree_foreach_arg(&tree, count_arg_callback, &the_count);
	if (the_count != size)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	/* search present */
	for(i=0;i<size/2;++i) {
		if (tommy_tree_search(&tree, &OBJ[i]) == 0)
				/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
		if (tommy_tree_search_compare(&tree, &compare, &OBJ[i]) == 0)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
	}

	/* insert existing */
	for(i=0;i<size;++i) {
		struct object_tree EXTRA;
		EXTRA.value = i;
		if (tommy_tree_insert(&tree, &EXTRA.node, &EXTRA) == &EXTRA)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
	}

	/* remove existing */
	for(i=0;i<size/2;++i)
		tommy_tree_remove_existing(&tree, &OBJ[i].node);

	/* remove missing */
	for(i=0;i<size/2;++i)
		if (tommy_tree_remove(&tree, &OBJ[i]) != 0)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

	/* search missing */
	for(i=0;i<size/2;++i) {
		if (tommy_tree_search(&tree, &OBJ[i]) != 0)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
		if (tommy_tree_search_compare(&tree, &compare, &OBJ[i]) != 0)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
	}

	/* remove present */
	for(i=0;i<size/2;++i)
		if (tommy_tree_remove(&tree, &OBJ[size/2+i]) == 0)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

	/* reverse order */
	for(i=0;i<size;++i)
		OBJ[i].value = size - i;

	/* insert */
	for(i=0;i<size;++i)
		if (tommy_tree_insert(&tree, &OBJ[i].node, &OBJ[i]) != &OBJ[i])
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

	/* remove all */
	for(i=0;i<size;++i)
		tommy_tree_remove_existing(&tree, &OBJ[i].node);

	/* random order */
	for(i=0;i<size;++i)
		OBJ[i].value = tommy_inthash_u32(i);

	/* insert */
	for(i=0;i<size;++i)
		if (tommy_tree_insert(&tree, &OBJ[i].node, &OBJ[i]) != &OBJ[i])
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

	/* remove all */
	for(i=0;i<size;++i)
		tommy_tree_remove_existing(&tree, &OBJ[i].node);

	STOP();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl $0xd59f80, %edi         # imm = 0xD59F80
callq 0x10b0
movq %rax, %rbx
movq %rax, %r14
leaq 0x4756(%rip), %rdi      # 0x6204
callq 0x127d
leaq -0x8fe(%rip), %rsi      # 0x11bc
leaq 0x8(%rsp), %rdi
callq 0x3b99
xorl %eax, %eax
movq %r14, %rcx
cmpq $0x3d090, %rax          # imm = 0x3D090
je 0x1adc
movl %eax, (%rcx)
incq %rax
addq $0x38, %rcx
jmp 0x1ac9
movl $0x3d091, %r12d         # imm = 0x3D091
leaq 0x8(%rsp), %r15
movq %r14, %rdx
decq %r12
je 0x1b10
leaq 0x38(%rdx), %r13
leaq -0x38(%r13), %rbp
leaq 0x8(%rdx), %rsi
movq %r15, %rdi
callq 0x3ba7
movq %r13, %rdx
cmpq %rax, %rbp
je 0x1aea
jmp 0x1da9
leaq 0x8(%rsp), %rdi
callq 0x3e54
cmpq $0x7a11ff, %rax         # imm = 0x7A11FF
jbe 0x1da9
cmpq $0x3d090, 0x18(%rsp)    # imm = 0x3D090
jne 0x1da9
andl $0x0, 0x10092d4(%rip)   # 0x100ae10
leaq 0x2a3(%rip), %rsi       # 0x1de6
leaq 0x8(%rsp), %rdi
callq 0x3dd7
cmpl $0x3d090, 0x10092b9(%rip) # imm = 0x3D090
jne 0x1da9
andl $0x0, 0x10092ac(%rip)   # 0x100ae10
leaq 0x10092a5(%rip), %rdx   # 0x100ae10
leaq 0x27b(%rip), %rsi       # 0x1ded
leaq 0x8(%rsp), %rdi
callq 0x3e0c
cmpl $0x3d090, 0x100928a(%rip) # imm = 0x3D090
jne 0x1da9
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
leaq -0x9df(%rip), %r12      # 0x11bc
leaq 0x38(%r13), %rbp
cmpq $0x6acff8, %rbp         # imm = 0x6ACFF8
je 0x1bda
addq %rbx, %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x3d33
testq %rax, %rax
je 0x1da9
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x3d89
movq %rbp, %r13
testq %rax, %rax
jne 0x1b9b
jmp 0x1da9
xorl %ebp, %ebp
leaq 0x28(%rsp), %r15
leaq 0x8(%rsp), %r12
leaq 0x20(%rsp), %r13
cmpl $0x3d090, %ebp          # imm = 0x3D090
je 0x1c12
movl %ebp, 0x20(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3ba7
cmpq %r13, %rax
je 0x1da9
incl %ebp
jmp 0x1beb
pushq $0x8
popq %r12
leaq 0x8(%rsp), %r15
cmpq $0x6acfc8, %r12         # imm = 0x6ACFC8
je 0x1c36
leaq (%rbx,%r12), %rsi
movq %r15, %rdi
callq 0x3da7
addq $0x38, %r12
jmp 0x1c1b
xorl %esi, %esi
leaq 0x8(%rsp), %r15
leaq 0x38(%rsi), %r12
cmpq $0x6acff8, %r12         # imm = 0x6ACFF8
je 0x1c62
addq %rbx, %rsi
movq %r15, %rdi
callq 0x3c64
movq %r12, %rsi
testq %rax, %rax
je 0x1c3d
jmp 0x1da9
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
leaq -0xab5(%rip), %r12      # 0x11bc
leaq 0x38(%r13), %rbp
cmpq $0x6acff8, %rbp         # imm = 0x6ACFF8
je 0x1cb0
addq %rbx, %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x3d33
testq %rax, %rax
jne 0x1da9
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x3d89
movq %rbp, %r13
testq %rax, %rax
je 0x1c71
jmp 0x1da9
leaq 0x6acfc0(%rbx), %r12
xorl %esi, %esi
leaq 0x8(%rsp), %r15
leaq 0x38(%rsi), %r13
cmpq $0x6acff8, %r13         # imm = 0x6ACFF8
je 0x1ce3
addq %r12, %rsi
movq %r15, %rdi
callq 0x3c64
movq %r13, %rsi
testq %rax, %rax
jne 0x1cbe
jmp 0x1da9
movl $0x3d090, %edx          # imm = 0x3D090
movq %r14, %rax
movl $0x3d090, %ecx          # imm = 0x3D090
subq $0x1, %rcx
jb 0x1d01
movl %edx, (%rax)
addq $0x38, %rax
movq %rcx, %rdx
jmp 0x1cf0
movl $0x3d091, %r12d         # imm = 0x3D091
leaq 0x8(%rsp), %r15
movq %r14, %rdx
decq %r12
je 0x1d32
leaq 0x38(%rdx), %r13
leaq -0x38(%r13), %rbp
leaq 0x8(%rdx), %rsi
movq %r15, %rdi
callq 0x3ba7
movq %r13, %rdx
cmpq %rax, %rbp
je 0x1d0f
jmp 0x1da9
pushq $0x8
popq %r12
leaq 0x8(%rsp), %r15
cmpq $0xd59f88, %r12         # imm = 0xD59F88
je 0x1d56
leaq (%rbx,%r12), %rsi
movq %r15, %rdi
callq 0x3da7
addq $0x38, %r12
jmp 0x1d3b
xorl %r15d, %r15d
movq %r14, %r12
cmpq $0x3d090, %r15          # imm = 0x3D090
je 0x1d7a
movl %r15d, %edi
callq 0x1529
movl %eax, (%r12)
incq %r15
addq $0x38, %r12
jmp 0x1d5c
movl $0x3d091, %r12d         # imm = 0x3D091
leaq 0x8(%rsp), %r15
decq %r12
je 0x1dae
leaq 0x38(%r14), %r13
leaq -0x38(%r13), %rbp
leaq 0x8(%r14), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x3ba7
movq %r13, %r14
cmpq %rax, %rbp
je 0x1d85
callq 0x1040
pushq $0x8
popq %r15
leaq 0x8(%rsp), %r14
cmpq $0xd59f88, %r15         # imm = 0xD59F88
je 0x1dd2
leaq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x3da7
addq $0x38, %r15
jmp 0x1db7
callq 0x12cf
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq