// File: amadvance[P]tommyds/check.c
// Function: test_trie_inplace
void test_trie_inplace(void)
{
	tommy_trie_inplace trie_inplace;
	struct object_trie_inplace* OBJ;
	struct object_trie_inplace DUP[2];
	unsigned i;
	const unsigned size = TOMMY_SIZE * 4;

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

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

	START("trie_inplace");
	tommy_trie_inplace_init(&trie_inplace);

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

	if (tommy_trie_inplace_memory_usage(&trie_inplace) < size * sizeof(tommy_trie_inplace_node))
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	if (tommy_trie_inplace_count(&trie_inplace) != size)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	/* insert duplicates */
	for(i=0;i<2;++i) {
		DUP[i].value = 0;
		tommy_trie_inplace_insert(&trie_inplace, &DUP[i].node, &DUP[i], DUP[i].value);
	}

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

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

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

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

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

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

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

	STOP();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movl $0x3d0900, -0x2c8(%rbp) # imm = 0x3D0900
movl $0x14fb1800, %edi       # imm = 0x14FB1800
callq 0x10b0
movq %rax, -0x210(%rbp)
movl $0x0, -0x2c4(%rbp)
cmpl $0x3d0900, -0x2c4(%rbp) # imm = 0x3D0900
jae 0x4419
movl -0x2c4(%rbp), %ecx
movq -0x210(%rbp), %rax
movl -0x2c4(%rbp), %edx
imulq $0x58, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x43e0
leaq 0x5ec4(%rip), %rdi      # 0xa2e4
callq 0x13e0
leaq -0x208(%rbp), %rdi
callq 0x72c0
movl $0x0, -0x2c4(%rbp)
cmpl $0x3d0900, -0x2c4(%rbp) # imm = 0x3D0900
jae 0x44a7
movq -0x210(%rbp), %rsi
movl -0x2c4(%rbp), %eax
imulq $0x58, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x210(%rbp), %rdx
movl -0x2c4(%rbp), %eax
imulq $0x58, %rax, %rax
addq %rax, %rdx
movq -0x210(%rbp), %rax
movl -0x2c4(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rcx
leaq -0x208(%rbp), %rdi
callq 0x7300
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x443b
leaq -0x208(%rbp), %rdi
callq 0x78c0
cmpq $0xf424000, %rax        # imm = 0xF424000
jae 0x44c0
callq 0x1040
leaq -0x208(%rbp), %rdi
callq 0x4760
cmpq $0x3d0900, %rax         # imm = 0x3D0900
je 0x44d9
callq 0x1040
movl $0x0, -0x2c4(%rbp)
cmpl $0x2, -0x2c4(%rbp)
jae 0x4571
movl -0x2c4(%rbp), %eax
movl %eax, %ecx
leaq -0x2c0(%rbp), %rax
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
movl -0x2c4(%rbp), %eax
leaq -0x2c0(%rbp), %rsi
imulq $0x58, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
movl -0x2c4(%rbp), %eax
leaq -0x2c0(%rbp), %rdx
imulq $0x58, %rax, %rax
addq %rax, %rdx
movl -0x2c4(%rbp), %eax
movl %eax, %ecx
leaq -0x2c0(%rbp), %rax
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rcx
leaq -0x208(%rbp), %rdi
callq 0x7300
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x44e3
movl $0x0, -0x2c4(%rbp)
cmpl $0x1e8480, -0x2c4(%rbp) # imm = 0x1E8480
jae 0x45c8
movq -0x210(%rbp), %rax
movl -0x2c4(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rsi
leaq -0x208(%rbp), %rdi
callq 0x4780
cmpq $0x0, %rax
jne 0x45b5
callq 0x1040
jmp 0x45b7
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x457b
leaq -0x2c0(%rbp), %rsi
addq $0x8, %rsi
leaq -0x208(%rbp), %rdi
callq 0x7730
movl $0x0, -0x2c4(%rbp)
cmpl $0x1e8480, -0x2c4(%rbp) # imm = 0x1E8480
jae 0x462a
movq -0x210(%rbp), %rsi
movl -0x2c4(%rbp), %eax
imulq $0x58, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
leaq -0x208(%rbp), %rdi
callq 0x7730
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x45e9
leaq -0x2c0(%rbp), %rsi
addq $0x58, %rsi
addq $0x8, %rsi
leaq -0x208(%rbp), %rdi
callq 0x7730
movl $0x0, -0x2c4(%rbp)
cmpl $0x1e8480, -0x2c4(%rbp) # imm = 0x1E8480
jae 0x469c
movq -0x210(%rbp), %rax
movl -0x2c4(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rsi
leaq -0x208(%rbp), %rdi
callq 0x7490
cmpq $0x0, %rax
je 0x4689
callq 0x1040
jmp 0x468b
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x464f
movl $0x0, -0x2c4(%rbp)
cmpl $0x1e8480, -0x2c4(%rbp) # imm = 0x1E8480
jae 0x46f3
movq -0x210(%rbp), %rax
movl -0x2c4(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rsi
leaq -0x208(%rbp), %rdi
callq 0x4780
cmpq $0x0, %rax
je 0x46e0
callq 0x1040
jmp 0x46e2
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x46a6
movl $0x0, -0x2c4(%rbp)
cmpl $0x1e8480, -0x2c4(%rbp) # imm = 0x1E8480
jae 0x4752
movq -0x210(%rbp), %rax
movl -0x2c4(%rbp), %ecx
addl $0x1e8480, %ecx         # imm = 0x1E8480
movl %ecx, %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rsi
leaq -0x208(%rbp), %rdi
callq 0x7490
cmpq $0x0, %rax
jne 0x473f
callq 0x1040
jmp 0x4741
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x46fd
callq 0x1460
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq