// File: /workspace/github_c_makefile_star2_O1/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 0x1fde
movl 0x38(%rax), %ecx
cmpq %rbx, 0x18(%rax)
je 0x1ff5
leal -0x1(%rcx), %edx
movl %edx, 0x38(%rbx)
cmpl %ecx, (%r14)
jl 0x2006
movl %edx, (%r14)
jmp 0x2006
movq $0x0, 0x38(%rbx)
movl $0x0, (%r14)
movl (%rbx), %eax
movl %eax, 0x4(%r14)
jmp 0x200e
incl %ecx
movl %ecx, 0x38(%rbx)
movl (%rbx), %ecx
cmpl %ecx, 0x4(%r14)
jge 0x2006
movl %ecx, 0x4(%r14)
movl 0x3c(%rax), %eax
incl %eax
movl %eax, 0x3c(%rbx)
cmpl $0x0, 0x2c(%r14)
je 0x20ea
cmpl $-0x1, (%rbx)
je 0x20ea
cmpq $0x0, 0x10(%rbx)
jne 0x2086
movl $0x50, %edi
callq 0x1100
testq %rax, %rax
je 0x2058
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, (%rax)
jmp 0x205a
xorl %eax, %eax
testq %rax, %rax
je 0x2164
movq %rbx, 0x20(%rax)
movq %rax, 0x10(%rbx)
leaq 0x30(%r14), %rcx
leaq 0x40(%rax), %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 0x20ea
movl $0x50, %edi
callq 0x1100
testq %rax, %rax
je 0x20bc
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, (%rax)
jmp 0x20be
xorl %eax, %eax
testq %rax, %rax
je 0x2164
movq %rbx, 0x20(%rax)
movq %rax, 0x18(%rbx)
leaq 0x30(%r14), %rcx
leaq 0x40(%rax), %rdx
movq %rcx, 0x40(%rax)
movq 0x38(%r14), %rcx
movq %rcx, 0x48(%rax)
movq %rdx, (%rcx)
movq %rdx, 0x38(%r14)
movslq 0x3c(%rbx), %r12
movl 0x28(%r14), %ebp
cmpl %r12d, %ebp
jg 0x21a5
leaq 0x1(%r12), %r13
movq %r13, %rdi
shlq $0x4, %rdi
callq 0x1100
testq %rax, %rax
je 0x2164
movq %rax, %r15
testl %ebp, %ebp
jle 0x216b
movq 0x20(%r14), %rcx
xorl %eax, %eax
movq %r15, %rdx
movq %rdx, (%rdx)
movq %rdx, 0x8(%rdx)
movq 0x8(%rcx), %rsi
movq %rcx, (%rdx)
movq %rdx, (%rsi)
movq %rdx, 0x8(%rcx)
movq %rsi, 0x8(%rdx)
movq (%rcx), %rsi
movq 0x8(%rcx), %rdi
movq %rsi, (%rdi)
movq (%rcx), %rsi
movq %rdi, 0x8(%rsi)
movq %rcx, (%rcx)
movq %rcx, 0x8(%rcx)
incq %rax
addq $0x10, %rcx
addq $0x10, %rdx
cmpq %rax, %rbp
jne 0x2121
jmp 0x216d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x21d1
xorl %eax, %eax
cmpl %r12d, %eax
jg 0x2194
movl %eax, %edx
movl %r13d, %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 0x2184
movq 0x20(%r14), %rdi
callq 0x1030
movq %r15, 0x20(%r14)
movl %r13d, 0x28(%r14)
leaq 0x28(%rbx), %rax
movq 0x20(%r14), %rcx
shlq $0x4, %r12
leaq (%rcx,%r12), %rdx
movq %rdx, 0x28(%rbx)
movq 0x8(%rcx,%r12), %rdx
movq %rdx, 0x30(%rbx)
movq 0x8(%rcx,%r12), %rdx
movq %rax, (%rdx)
movq %rax, 0x8(%rcx,%r12)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq