// File: /workspace/github_cpp_makefile_star2_O2/amadvance[P]tommyds/check.c
// Function: test_trie
void test_trie(void)
{
	tommy_trie trie;
	tommy_allocator alloc;
	struct object_trie* OBJ;
	struct object_trie DUP[2];
	unsigned i;
	const unsigned size = TOMMY_SIZE * 4;

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

	for(i=0;i<size;++i)
		OBJ[i].value = i;

	START("trie");
	tommy_allocator_init(&alloc, TOMMY_TRIE_BLOCK_SIZE, TOMMY_TRIE_BLOCK_SIZE);
	tommy_trie_init(&trie, &alloc);

	/* insert */
	for(i=0;i<size;++i)
		tommy_trie_insert(&trie, &OBJ[i].node, &OBJ[i], OBJ[i].value);

	if (tommy_trie_memory_usage(&trie) < size * sizeof(tommy_trie_node))
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	if (tommy_allocator_memory_usage(&alloc) < trie.node_count * TOMMY_TRIE_BLOCK_SIZE)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	if (tommy_trie_count(&trie) != size)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	/* insert duplicate */
	for(i=0;i<2;++i) {
		DUP[i].value = 0;
		tommy_trie_insert(&trie, &DUP[i].node, &DUP[i], DUP[i].value);
	}

	/* search present */
	for(i=0;i<size/2;++i)
		if (tommy_trie_search(&trie, OBJ[i].value) == 0)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

	/* remove first duplicate */
	tommy_trie_remove_existing(&trie, &DUP[0].node);

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

	/* remove missing using the same bucket of the duplicate */
	if (tommy_trie_remove(&trie, 1) != 0)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	/* search missing using the same bucket of the duplicate */
	if (tommy_trie_search(&trie, 1) != 0)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	/* remove second duplicate */
	tommy_trie_remove_existing(&trie, &DUP[1].node);

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

	/* search missing */
	for(i=0;i<size/2;++i)
		if (tommy_trie_search(&trie, OBJ[i].value) != 0)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */

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

	tommy_allocator_done(&alloc);
	STOP();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl $0xd59f800, %edi        # imm = 0xD59F800
callq 0x10b0
movq %rax, %rbx
xorl %eax, %eax
movq %rbx, %rcx
cmpq $0x3d0900, %rax         # imm = 0x3D0900
je 0x2ce4
movl %eax, (%rcx)
incq %rax
addq $0x38, %rcx
jmp 0x2cd1
leaq 0x3610(%rip), %rdi      # 0x62fb
callq 0x127d
movq %rsp, %r15
pushq $0x40
popq %rdx
movq %r15, %rdi
movq %rdx, %rsi
callq 0x35a6
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x3e5d
movl $0x3d0900, %r12d        # imm = 0x3D0900
movq %rbx, %r15
subq $0x1, %r12
jb 0x2d38
leaq 0x8(%r15), %rsi
movslq (%r15), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x3e81
addq $0x38, %r15
jmp 0x2d1a
leaq 0x28(%rsp), %rdi
callq 0x4201
cmpq $0x7a11fff, %rax        # imm = 0x7A11FFF
jbe 0x2ed2
movq %rsp, %rdi
callq 0x36b3
movq 0x130(%rsp), %rcx
shlq $0x6, %rcx
cmpq %rcx, %rax
jb 0x2ed2
cmpq $0x3d0900, 0x128(%rsp) # imm = 0x3D0900
jne 0x2ed2
leaq 0x148(%rsp), %r15
xorl %r12d, %r12d
leaq 0x28(%rsp), %r14
cmpq $0x70, %r12
je 0x2db5
leaq (%rsp,%r12), %rdx
addq $0x140, %rdx            # imm = 0x140
andl $0x0, (%rdx)
leaq (%r15,%r12), %rsi
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x3e81
addq $0x38, %r12
jmp 0x2d8d
xorl %ecx, %ecx
leaq 0x28(%rsp), %r14
leaq 0x38(%rcx), %r15
cmpq $0x6acfc38, %r15        # imm = 0x6ACFC38
je 0x2de2
movslq (%rbx,%rcx), %rsi
movq %r14, %rdi
callq 0x2ef3
movq %r15, %rcx
testq %rax, %rax
jne 0x2dbc
jmp 0x2ed2
leaq 0x148(%rsp), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x411a
pushq $0x8
popq %r15
cmpq $0x6acfc08, %r15        # imm = 0x6ACFC08
je 0x2e16
leaq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x411a
addq $0x38, %r15
jmp 0x2dfb
leaq 0x28(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x3f9f
testq %rax, %rax
jne 0x2ed2
leaq 0x28(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x2ef3
testq %rax, %rax
jne 0x2ed2
leaq 0x180(%rsp), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x411a
xorl %ecx, %ecx
leaq 0x38(%rcx), %r15
cmpq $0x6acfc38, %r15        # imm = 0x6ACFC38
je 0x2e7c
movslq (%rbx,%rcx), %rsi
movq %r14, %rdi
callq 0x3f9f
movq %r15, %rcx
testq %rax, %rax
je 0x2e59
jmp 0x2ed2
xorl %ecx, %ecx
leaq 0x28(%rsp), %r14
leaq 0x38(%rcx), %r15
cmpq $0x6acfc38, %r15        # imm = 0x6ACFC38
je 0x2ea6
movslq (%rbx,%rcx), %rsi
movq %r14, %rdi
callq 0x2ef3
movq %r15, %rcx
testq %rax, %rax
je 0x2e83
jmp 0x2ed2
xorl %ecx, %ecx
leaq 0x28(%rsp), %r14
leaq 0x38(%rcx), %r15
cmpq $0x6acfc38, %r15        # imm = 0x6ACFC38
je 0x2ed7
movslq 0x6acfc00(%rbx,%rcx), %rsi
movq %r14, %rdi
callq 0x3f9f
movq %r15, %rcx
testq %rax, %rax
jne 0x2ead
callq 0x1040
movq %rsp, %rdi
callq 0x35dd
callq 0x12cf
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r14
popq %r15
retq