// File: /workspace/github_cpp_makefile_star2_O1/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 0x382e
movq $-0x20, %rax
leaq 0x75c3(%rip), %rcx      # 0xae10
incb 0x20(%rax,%rcx)
addq $0x20, %rax
cmpq $0xffffe0, %rax         # imm = 0xFFFFE0
jb 0x384d
movl $0x0, 0x7599(%rip)      # 0xae00
leaq 0x3a8d(%rip), %rax      # 0x72fb
movq %rax, 0x100759b(%rip)   # 0x100ae10
callq 0x12e3
movq %rax, 0x1007597(%rip)   # 0x100ae18
movq %rsp, %r15
movl $0x40, %esi
movl $0x40, %edx
movq %r15, %rdi
callq 0x40e5
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4caa
movl $0x3d0900, %r12d        # imm = 0x3D0900
movq %rbx, %r15
leaq 0x8(%r15), %rsi
movslq (%r15), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x4cda
addq $0x38, %r15
decq %r12
jne 0x38af
leaq 0x28(%rsp), %rdi
callq 0x50f3
cmpq $0x7a11fff, %rax        # imm = 0x7A11FFF
jbe 0x3a95
movq %rsp, %rdi
callq 0x41fd
movq 0x130(%rsp), %rcx
shlq $0x6, %rcx
cmpq %rcx, %rax
jb 0x3a95
cmpq $0x3d0900, 0x128(%rsp) # imm = 0x3D0900
jne 0x3a95
leaq 0x148(%rsp), %r15
xorl %r12d, %r12d
leaq 0x28(%rsp), %r14
leaq (%rsp,%r12), %rdx
addq $0x140, %rdx            # imm = 0x140
movl $0x0, (%rdx)
leaq (%r15,%r12), %rsi
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x4cda
addq $0x38, %r12
cmpq $0x38, %r12
je 0x391f
xorl %r15d, %r15d
leaq 0x28(%rsp), %r14
movslq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x5086
testq %rax, %rax
je 0x3a95
cmpq $0x0, 0x10(%rax)
je 0x3a95
addq $0x38, %r15
cmpq $0x6acfc00, %r15        # imm = 0x6ACFC00
jne 0x3950
leaq 0x148(%rsp), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x5006
movl $0x8, %r15d
leaq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x5006
addq $0x38, %r15
cmpq $0x6acfc08, %r15        # imm = 0x6ACFC08
jne 0x3998
leaq 0x28(%rsp), %rdi
movl $0x1, %esi
callq 0x4e7e
testq %rax, %rax
jne 0x3a95
leaq 0x28(%rsp), %rdi
movl $0x1, %esi
callq 0x5086
testq %rax, %rax
je 0x39e8
cmpq $0x0, 0x10(%rax)
jne 0x3a95
leaq 0x180(%rsp), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x5006
xorl %r15d, %r15d
movslq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x4e7e
testq %rax, %rax
jne 0x3a95
addq $0x38, %r15
cmpq $0x6acfc00, %r15        # imm = 0x6ACFC00
jne 0x3a00
xorl %r15d, %r15d
leaq 0x28(%rsp), %r14
movslq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x5086
testq %rax, %rax
je 0x3a42
cmpq $0x0, 0x10(%rax)
jne 0x3a95
addq $0x38, %r15
cmpq $0x6acfc00, %r15        # imm = 0x6ACFC00
jne 0x3a2a
xorl %r15d, %r15d
leaq 0x28(%rsp), %r14
movslq 0x6acfc00(%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x4e7e
testq %rax, %rax
je 0x3a95
addq $0x38, %r15
cmpq $0x6acfc00, %r15        # imm = 0x6ACFC00
jne 0x3a57
movq %rsp, %rdi
callq 0x4121
callq 0x1312
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x1040