// File: /workspace/github_c_makefile_star2_O2/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 0x1f28
movl 0x38(%rax), %ecx
cmpq %rbx, 0x18(%rax)
je 0x1f39
leal -0x1(%rcx), %edx
movl %edx, 0x38(%rbx)
cmpl %ecx, (%r14)
jl 0x1f4a
movl %edx, (%r14)
jmp 0x1f4a
andq $0x0, 0x38(%rbx)
andl $0x0, (%r14)
movl (%rbx), %eax
movl %eax, 0x4(%r14)
jmp 0x1f52
incl %ecx
movl %ecx, 0x38(%rbx)
movl (%rbx), %ecx
cmpl %ecx, 0x4(%r14)
jge 0x1f4a
movl %ecx, 0x4(%r14)
movl 0x3c(%rax), %eax
incl %eax
movl %eax, 0x3c(%rbx)
cmpl $0x0, 0x2c(%r14)
pushq $-0x1
popq %rbp
je 0x1fd7
cmpl $-0x1, (%rbx)
je 0x1fd7
cmpq $0x0, 0x10(%rbx)
jne 0x1f9c
callq 0x29f6
testq %rax, %rax
je 0x20ba
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 0x1fd7
callq 0x29f6
testq %rax, %rax
je 0x20ba
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)
movslq 0x3c(%rbx), %r12
movl 0x28(%r14), %r13d
cmpl %r12d, %r13d
jle 0x1fed
movq 0x20(%r14), %r15
jmp 0x2097
movq %r12, %rdi
incq %rdi
movq %rdi, (%rsp)
shlq $0x4, %rdi
callq 0x1110
testq %rax, %rax
je 0x20ba
movq %rax, %r15
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
movq %r13, %rcx
shlq $0x4, %rcx
cmpq %rax, %rcx
je 0x2067
leaq (%r15,%rax), %rdx
movq %rdx, 0x8(%r15,%rax)
movq 0x20(%r14), %rsi
leaq (%rsi,%rax), %rdi
movq 0x8(%rsi,%rax), %r8
movq %rdi, (%r15,%rax)
movq %rdx, (%r8)
movq %rdx, 0x8(%rsi,%rax)
movq %r8, 0x8(%r15,%rax)
movq (%rsi,%rax), %rdx
movq 0x8(%rsi,%rax), %r8
movq %rdx, (%r8)
movq %r8, 0x8(%rdx)
movq %rdi, (%rsi,%rax)
movq %rdi, 0x8(%rsi,%rax)
addq $0x10, %rax
jmp 0x201c
movq %r15, %rax
addq %rcx, %rax
cmpq %r12, %r13
jg 0x2082
movq %rax, (%rax)
movq %rax, 0x8(%rax)
incq %r13
addq $0x10, %rax
jmp 0x206d
movq 0x20(%r14), %rdi
callq 0x1030
movq %r15, 0x20(%r14)
movq (%rsp), %rax
movl %eax, 0x28(%r14)
leaq 0x28(%rbx), %rax
shlq $0x4, %r12
leaq (%r15,%r12), %rcx
movq %rcx, 0x28(%rbx)
movq 0x8(%r15,%r12), %rcx
movq %rcx, 0x30(%rbx)
movq %rax, (%rcx)
movq %rax, 0x8(%r15,%r12)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq