// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x3d090, -0x28(%rbp)   # imm = 0x3D090
movl $0xd59f80, %edi         # imm = 0xD59F80
callq 0x10b0
movq %rax, -0x20(%rbp)
leaq 0x8064(%rip), %rdi      # 0xa1e8
callq 0x13e0
leaq -0x18(%rbp), %rdi
leaq -0xfd4(%rip), %rsi      # 0x11c0
callq 0x6490
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x21c7
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x21a0
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x2225
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
leaq -0x18(%rbp), %rdi
callq 0x64d0
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
je 0x2218
callq 0x1040
jmp 0x221a
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x21ce
leaq -0x18(%rbp), %rdi
callq 0x6a80
cmpq $0x7a1200, %rax         # imm = 0x7A1200
jae 0x223b
callq 0x1040
leaq -0x18(%rbp), %rdi
callq 0x2620
cmpq $0x3d090, %rax          # imm = 0x3D090
je 0x2251
callq 0x1040
movl $0x0, 0x100cbb5(%rip)   # 0x100ee10
leaq -0x18(%rbp), %rdi
leaq 0x3da(%rip), %rsi       # 0x2640
callq 0x6950
cmpl $0x3d090, 0x100cb9b(%rip) # imm = 0x3D090
je 0x227c
callq 0x1040
movl $0x0, 0x100cb8a(%rip)   # 0x100ee10
leaq -0x18(%rbp), %rdi
leaq 0x3cf(%rip), %rsi       # 0x2660
leaq 0x100cb78(%rip), %rdx   # 0x100ee10
callq 0x69e0
cmpl $0x3d090, 0x100cb69(%rip) # imm = 0x3D090
je 0x22ae
callq 0x1040
movl $0x0, -0x24(%rbp)
cmpl $0x1e848, -0x24(%rbp)   # imm = 0x1E848
jae 0x2316
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0x67a0
cmpq $0x0, %rax
jne 0x22e0
callq 0x1040
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
leaq -0x18(%rbp), %rdi
leaq -0x1139(%rip), %rsi     # 0x11c0
callq 0x6890
cmpq $0x0, %rax
jne 0x2309
callq 0x1040
jmp 0x230b
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x22b5
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x235c
movl -0x24(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
addq $0x8, %rsi
leaq -0x18(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x64d0
leaq -0x60(%rbp), %rcx
cmpq %rcx, %rax
jne 0x234f
callq 0x1040
jmp 0x2351
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x231d
movl $0x0, -0x24(%rbp)
cmpl $0x1e848, -0x24(%rbp)   # imm = 0x1E848
jae 0x2392
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
leaq -0x18(%rbp), %rdi
callq 0x68f0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2363
movl $0x0, -0x24(%rbp)
cmpl $0x1e848, -0x24(%rbp)   # imm = 0x1E848
jae 0x23d1
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0x6640
cmpq $0x0, %rax
je 0x23c4
callq 0x1040
jmp 0x23c6
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2399
movl $0x0, -0x24(%rbp)
cmpl $0x1e848, -0x24(%rbp)   # imm = 0x1E848
jae 0x2439
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0x67a0
cmpq $0x0, %rax
je 0x2403
callq 0x1040
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
leaq -0x18(%rbp), %rdi
leaq -0x125c(%rip), %rsi     # 0x11c0
callq 0x6890
cmpq $0x0, %rax
je 0x242c
callq 0x1040
jmp 0x242e
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x23d8
movl $0x0, -0x24(%rbp)
cmpl $0x1e848, -0x24(%rbp)   # imm = 0x1E848
jae 0x247f
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
addl $0x1e848, %eax          # imm = 0x1E848
movl %eax, %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0x6640
cmpq $0x0, %rax
jne 0x2472
callq 0x1040
jmp 0x2474
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2440
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x24b2
movl $0x3d090, %ecx          # imm = 0x3D090
subl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2486
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x2510
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
leaq -0x18(%rbp), %rdi
callq 0x64d0
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
je 0x2503
callq 0x1040
jmp 0x2505
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x24b9
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x2546
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
leaq -0x18(%rbp), %rdi
callq 0x68f0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2517
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x257b
movl -0x24(%rbp), %edi
callq 0x1820
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x254d
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x25d9
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdx
leaq -0x18(%rbp), %rdi
callq 0x64d0
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
je 0x25cc
callq 0x1040
jmp 0x25ce
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2582
movl $0x0, -0x24(%rbp)
cmpl $0x3d090, -0x24(%rbp)   # imm = 0x3D090
jae 0x260f
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
leaq -0x18(%rbp), %rdi
callq 0x68f0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x25e0
callq 0x1460
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)