// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]rbtree/test/bitmap.c
// Function: predraw
static int predraw(rbtree_t *tree, rbnode_t *n, void *state)
{
	draw_state_t *st = state;
	rbpoint_t *a = container_of(n, rbpoint_t, rbentry);
	if (n->parent == NULL) {
		st->minX = a->x = a->y = 0;
		st->maxValue = ptoi(n->key);
	}
	else {
		rbpoint_t *p = container_of(n->parent, rbpoint_t, rbentry);

		if (rbnode_is_right(n)) {
			a->x = p->x + 1;
			if (st->maxValue < ptoi(n->key))
				st->maxValue = ptoi(n->key);
		}
		else {
			a->x = p->x - 1;
			if (st->minX > a->x)
				st->minX = a->x;
		}
		a->y = p->y + 1;
	}

	if (st->draw_nil && ptoi(n->key) != NIL_KEY) {
		if (rbnode_is_nil(n->left)) {
			rbnil_t *nil = new_nil();
			if (nil == NULL)
				return -1;
			nil->base.rbentry.parent = n;
			n->left = &nil->base.rbentry;
			dllist_add(&st->nils, &nil->dlentry);
		}

		if (rbnode_is_nil(n->right)) {
			rbnil_t *nil = new_nil();
			if (nil == NULL)
				return -1;
			nil->base.rbentry.parent = n;
			n->right = &nil->base.rbentry;
			dllist_add(&st->nils, &nil->dlentry);
		}
	}


	return add_row(st, a->y, &a->dlentry);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq 0x20(%rsi), %rax
testq %rax, %rax
je 0x2142
movl 0x38(%rax), %ecx
cmpq %rbx, 0x18(%rax)
je 0x215c
leal -0x1(%rcx), %edx
movl %edx, 0x38(%rbx)
cmpl %ecx, (%r14)
jl 0x216d
movl %edx, (%r14)
jmp 0x216d
movq $0x0, 0x38(%rbx)
movl $0x0, (%r14)
movl (%rbx), %eax
movl %eax, 0x4(%r14)
xorl %r12d, %r12d
jmp 0x2178
incl %ecx
movl %ecx, 0x38(%rbx)
movl (%rbx), %ecx
cmpl %ecx, 0x4(%r14)
jge 0x216d
movl %ecx, 0x4(%r14)
movl 0x3c(%rax), %r12d
incl %r12d
movl %r12d, 0x3c(%rbx)
cmpl $0x0, 0x2c(%r14)
je 0x2226
cmpl $-0x1, (%rbx)
je 0x2226
cmpq $0x0, 0x10(%rbx)
jne 0x21d9
movl $0x1, %edi
movl $0x50, %esi
callq 0x10d0
testq %rax, %rax
je 0x229a
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, (%rax)
movq %rbx, 0x20(%rax)
movq %rax, 0x10(%rbx)
leaq 0x30(%r14), %rcx
movq %rax, %rdx
addq $0x40, %rdx
movq %rcx, 0x40(%rax)
movq 0x38(%r14), %rcx
movq %rcx, 0x48(%rax)
movq %rdx, (%rcx)
movq %rdx, 0x38(%r14)
cmpq $0x0, 0x18(%rbx)
jne 0x2226
movl $0x1, %edi
movl $0x50, %esi
callq 0x10d0
testq %rax, %rax
je 0x229a
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, (%rax)
movq %rbx, 0x20(%rax)
movq %rax, 0x18(%rbx)
leaq 0x30(%r14), %rcx
movq %rax, %rdx
addq $0x40, %rdx
movq %rcx, 0x40(%rax)
movq 0x38(%r14), %rcx
movq %rcx, 0x48(%rax)
movq %rdx, (%rcx)
movq %rdx, 0x38(%r14)
movl 0x28(%r14), %r13d
cmpl %r12d, %r13d
jle 0x2238
movq 0x20(%r14), %r15
jmp 0x22dc
leal 0x1(%r12), %ebp
movslq %ebp, %rdi
shlq $0x4, %rdi
callq 0x1110
testq %rax, %rax
je 0x229a
movq %rax, %r15
testl %r13d, %r13d
jle 0x22a1
movq 0x20(%r14), %rax
movq %r15, %rcx
movq %r13, %rdx
movq %rcx, 0x8(%rcx)
movq 0x8(%rax), %rsi
movq %rax, (%rcx)
movq %rcx, (%rsi)
movq %rcx, 0x8(%rax)
movq %rsi, 0x8(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdi
movq %rsi, (%rdi)
movq %rdi, 0x8(%rsi)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
addq $0x10, %rax
addq $0x10, %rcx
decq %rdx
jne 0x2260
jmp 0x22a4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x2302
xorl %r13d, %r13d
cmpl %r12d, %r13d
jg 0x22cb
movl %r13d, %edx
movl %ebp, %eax
subq %rdx, %rax
shlq $0x4, %rdx
movq %r15, %rcx
addq %rdx, %rcx
movq %rcx, (%rcx)
movq %rcx, 0x8(%rcx)
addq $0x10, %rcx
decq %rax
jne 0x22bb
movq 0x20(%r14), %rdi
callq 0x1030
movq %r15, 0x20(%r14)
movl %ebp, 0x28(%r14)
leaq 0x28(%rbx), %rax
movslq %r12d, %rcx
shlq $0x4, %rcx
leaq (%r15,%rcx), %rdx
movq %rdx, 0x28(%rbx)
movq 0x8(%r15,%rcx), %rdx
movq %rdx, 0x30(%rbx)
movq %rax, (%rdx)
movq %rax, 0x8(%r15,%rcx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq