// File: /workspace/github_cpp_makefile_star2_O3/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 0x10c0
movq %rax, %rbx
xorl %eax, %eax
movq %rbx, %rcx
movl %eax, (%rcx)
incq %rax
addq $0x38, %rcx
cmpq $0x3d0900, %rax         # imm = 0x3D0900
jne 0x37d3
movq $-0x20, %rax
leaq 0x861e(%rip), %rcx      # 0xbe10
incb 0x20(%rax,%rcx)
addq $0x20, %rax
cmpq $0xffffe0, %rax         # imm = 0xFFFFE0
jb 0x37f2
movl $0x0, 0x85f4(%rip)      # 0xbe00
leaq 0x3ae8(%rip), %rax      # 0x72fb
movq %rax, 0x10085f6(%rip)   # 0x100be10
callq 0x12e3
movq %rax, 0x10085f2(%rip)   # 0x100be18
leaq 0x8(%rsp), %r15
movl $0x40, %esi
movl $0x40, %edx
movq %r15, %rdi
callq 0x40a3
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4e59
movl $0x3d0900, %r12d        # imm = 0x3D0900
movq %rbx, %r15
leaq 0x8(%r15), %rsi
movslq (%r15), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x4e7e
addq $0x38, %r15
decq %r12
jne 0x3859
leaq 0xa0(%rsp), %rdi
callq 0x52b6
cmpq $0x7a11fff, %rax        # imm = 0x7A11FFF
jbe 0x3a4b
leaq 0x8(%rsp), %rdi
callq 0x41bb
movq 0x1a8(%rsp), %rcx
shlq $0x6, %rcx
cmpq %rcx, %rax
jb 0x3a4b
cmpq $0x3d0900, 0x1a0(%rsp) # imm = 0x3D0900
jne 0x3a4b
xorl %r15d, %r15d
leaq 0x38(%rsp), %rsi
movl %r15d, -0x8(%rsi)
leaq 0xa0(%rsp), %r14
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x4e7e
leaq 0x68(%rsp), %rdx
movl %r15d, (%rdx)
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x4e7e
movslq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x5249
testq %rax, %rax
je 0x3a4b
cmpq $0x0, 0x10(%rax)
je 0x3a4b
addq $0x38, %r15
cmpq $0x6acfc00, %r15        # imm = 0x6ACFC00
jne 0x38f8
leaq 0x38(%rsp), %rsi
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0x51c9
movl $0x8, %r15d
leaq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x51c9
addq $0x38, %r15
cmpq $0x6acfc08, %r15        # imm = 0x6ACFC08
jne 0x3940
leaq 0xa0(%rsp), %rdi
movl $0x1, %esi
callq 0x5022
testq %rax, %rax
jne 0x3a4b
leaq 0xa0(%rsp), %rdi
movl $0x1, %esi
callq 0x5249
testq %rax, %rax
je 0x3996
cmpq $0x0, 0x10(%rax)
jne 0x3a4b
leaq 0x70(%rsp), %rsi
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0x51c9
xorl %r15d, %r15d
movslq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x5022
testq %rax, %rax
jne 0x3a4b
addq $0x38, %r15
cmpq $0x6acfc00, %r15        # imm = 0x6ACFC00
jne 0x39ae
xorl %r15d, %r15d
leaq 0xa0(%rsp), %r14
movslq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x5249
testq %rax, %rax
je 0x39f3
cmpq $0x0, 0x10(%rax)
jne 0x3a4b
addq $0x38, %r15
cmpq $0x6acfc00, %r15        # imm = 0x6ACFC00
jne 0x39db
xorl %r15d, %r15d
leaq 0xa0(%rsp), %r14
movslq 0x6acfc00(%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x5022
testq %rax, %rax
je 0x3a4b
addq $0x38, %r15
cmpq $0x6acfc00, %r15        # imm = 0x6ACFC00
jne 0x3a0b
leaq 0x8(%rsp), %rdi
callq 0x40df
callq 0x1312
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x1040