// File: /workspace/github_c_makefile_star2_O0/glk[P]critbit/critbit-test.c
// Function: test_benchmark_rbtree
static void
test_benchmark_rbtree(void)
{
	struct rbtree tree;
	struct element find, *el, *test_data_el;
	int cnt;
	int i;

	RB_INIT(&tree);

	for (cnt = 0; test_data[cnt]; ) {
		cnt++;
	}
	test_data_el = malloc(cnt * sizeof(*test_data_el));

	int loopcnt = loopcnt_init;
	struct timeval tstart, tend;

        gettimeofday(&tstart, NULL);

again:
	for (i = 0; i < cnt; ++i) {
		el = &test_data_el[i];
		el->k = test_data[i];
		RB_INSERT(rbtree, &tree, el);
	}

	for (i = cnt - 1; i >= 0; i--) {
		find.k = test_data[i];
		el = RB_FIND(rbtree, &tree, &find);
		if (el == NULL)
			abort();
	}

	for (i = 3; i < cnt; i += 5) {
		find.k = test_data[i];
		el = RB_FIND(rbtree, &tree, &find);
		if (el == NULL)
			abort();
		el = RB_REMOVE(rbtree, &tree, el);
	}

	for (i = 2; i < cnt; i += 3) {
		find.k = test_data[i];
		el = RB_FIND(rbtree, &tree, &find);
	}

	for (i = 0; i < cnt; i ++) {
		find.k = test_data[i];
		el = RB_FIND(rbtree, &tree, &find);
		if (el != NULL)
			RB_REMOVE(rbtree, &tree, el);
	}

	if (loopcnt-- > 0)
		goto again;
        gettimeofday(&tend, NULL);

	benchmark_result("rbtree", loopcnt_init, &tstart, &tend);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq $0x0, -0x8(%rbp)
movl $0x0, -0x64(%rbp)
movslq -0x64(%rbp), %rcx
leaq 0xb85b(%rip), %rax      # 0x1a070
cmpq $0x0, (%rax,%rcx,8)
je 0xe827
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xe80a
movslq -0x64(%rbp), %rax
imulq $0x48, %rax, %rdi
callq 0xd0b0
movq %rax, -0x60(%rbp)
movl $0x3e8, -0x6c(%rbp)     # imm = 0x3E8
leaq -0x80(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xd070
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0xe89d
movq -0x60(%rbp), %rax
movslq -0x68(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movslq -0x68(%rbp), %rcx
leaq 0xb7f7(%rip), %rax      # 0x1a070
movq (%rax,%rcx,8), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rsi
leaq -0x8(%rbp), %rdi
callq 0xf920
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xe853
movl -0x64(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x68(%rbp)
jl 0xe8e9
movslq -0x68(%rbp), %rcx
leaq 0xb7b9(%rip), %rax      # 0x1a070
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
leaq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xfa30
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0xe8dc
callq 0xd040
jmp 0xe8de
movl -0x68(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xe8a6
movl $0x3, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0xe944
movslq -0x68(%rbp), %rcx
leaq 0xb76d(%rip), %rax      # 0x1a070
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
leaq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xfa30
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0xe928
callq 0xd040
movq -0x58(%rbp), %rsi
leaq -0x8(%rbp), %rdi
callq 0xfab0
movq %rax, -0x58(%rbp)
movl -0x68(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x68(%rbp)
jmp 0xe8f0
movl $0x2, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0xe982
movslq -0x68(%rbp), %rcx
leaq 0xb712(%rip), %rax      # 0x1a070
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
leaq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xfa30
movq %rax, -0x58(%rbp)
movl -0x68(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x68(%rbp)
jmp 0xe94b
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0xe9d6
movslq -0x68(%rbp), %rcx
leaq 0xb6d4(%rip), %rax      # 0x1a070
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
leaq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xfa30
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xe9c9
movq -0x58(%rbp), %rsi
leaq -0x8(%rbp), %rdi
callq 0xfab0
jmp 0xe9cb
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xe989
movl -0x6c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x6c(%rbp)
cmpl $0x0, %eax
jle 0xe9eb
jmp 0xe84c
leaq -0x90(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xd070
leaq 0x9004(%rip), %rdi      # 0x17a06
movl $0x3e8, %esi            # imm = 0x3E8
leaq -0x80(%rbp), %rdx
leaq -0x90(%rbp), %rcx
callq 0xec30
addq $0x90, %rsp
popq %rbp
retq