// File: /workspace/github_c_makefile_star2_O3/rsa9000[P]regfanalysistools/rbtree.c
// Function: rbtree_delete
void rbtree_delete(struct rbtree *t, struct rbtree_head *node)
{
	struct rbtree_head *r;	/* Replacement node */
	struct rbtree_head *c;	/* Child node */
	int need_fixup = 0;

	if (node->left == &t->rbt_nil || node->right == &t->rbt_nil)
		r = node;
	else
		r = rbtree_successor(t, node);

	if (r->left != &t->rbt_nil)
		c = r->left;
	else
		c = r->right;

	rbt_set_p(c, rbt_get_p(r));

	if (rbt_get_p(r) == &t->rbt_nil) {
		t->rbt_root = c;
	} else {
		if (rbt_get_p(r)->left == r)
			rbt_get_p(r)->left = c;
		else
			rbt_get_p(r)->right = c;
	}

	need_fixup = rbt_is_black(r);

	if (r != node) {
		rbt_set_p(r, rbt_get_p(node));
		if (rbt_get_p(node) == &t->rbt_nil) {
			t->rbt_root = r;
		} else {
			if (rbt_get_p(node)->left == node)
				rbt_get_p(node)->left = r;
			else
				rbt_get_p(node)->right = r;
		}
		r->left = node->left;
		rbt_set_p(node->left, r);
		r->right = node->right;
		rbt_set_p(node->right, r);
		rbt_copy_color(r, node);
	}

	if (need_fixup)
		__rbtree_delete_fixup(t, c);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rsi), %r14
leaq 0x8(%rdi), %rcx
cmpq %rcx, %r14
je 0x30a6
movq 0x10(%rsi), %rdx
movq %rsi, %rax
cmpq %rcx, %rdx
je 0x30a9
movq %rdx, %r14
movq %r14, %rax
movq 0x8(%r14), %r14
cmpq %r14, %rcx
jne 0x3098
jmp 0x30a9
movq %rsi, %rax
cmpq %rcx, %r14
jne 0x30b2
movq 0x10(%rax), %r14
movq (%rax), %rdx
andq $-0x2, %rdx
movq (%r14), %rdi
andl $0x1, %edi
orq %rdx, %rdi
movq %rdi, (%r14)
movq (%rax), %rdx
movq %rdx, %r8
andq $-0x2, %r8
movq %rbx, %rdi
cmpq %r8, %rcx
je 0x30e7
leaq 0x8(%r8), %r9
leaq 0x10(%r8), %rdi
cmpq %rax, 0x8(%r8)
cmoveq %r9, %rdi
movq %r14, (%rdi)
andl $0x1, %edx
cmpq %rsi, %rax
je 0x3165
movq (%rsi), %rdi
andq $-0x2, %rdi
orq %rdx, %rdi
movq %rdi, (%rax)
movq (%rsi), %rdi
andq $-0x2, %rdi
movq %rbx, %r8
cmpq %rdi, %rcx
je 0x311e
leaq 0x8(%rdi), %rcx
leaq 0x10(%rdi), %r8
cmpq %rsi, 0x8(%rdi)
cmoveq %rcx, %r8
movq %rax, (%r8)
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rax)
movq %rax, %rdi
andq $-0x2, %rdi
movq (%rcx), %r8
andl $0x1, %r8d
orq %rdi, %r8
movq %r8, (%rcx)
movq 0x10(%rsi), %rcx
movq %rcx, 0x10(%rax)
movq (%rcx), %r8
andl $0x1, %r8d
orq %rdi, %r8
movq %r8, (%rcx)
movq (%rax), %rcx
andq $-0x2, %rcx
movq (%rsi), %rsi
andl $0x1, %esi
orq %rcx, %rsi
movq %rsi, (%rax)
testq %rdx, %rdx
jne 0x3305
cmpq %r14, (%rbx)
je 0x3301
movq (%r14), %rax
testb $0x1, %al
jne 0x3301
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x31fe
movq (%rsi), %rcx
testb $0x1, %cl
je 0x31c2
andq $-0x2, %rcx
movq %rcx, (%rsi)
movq (%r14), %rax
andq $-0x2, %rax
orq $0x1, (%rax)
movq (%r14), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2e6d
movq (%r14), %rax
movq %rax, %rcx
andq $-0x2, %rcx
movq 0x8(%rcx), %rsi
movq 0x8(%rsi), %rcx
testb $0x1, (%rcx)
jne 0x3262
movq 0x10(%rsi), %rax
movq (%rax), %rcx
testb $0x1, %cl
je 0x3253
andq $-0x2, %rcx
movq %rcx, (%rax)
orb $0x1, (%rsi)
movq %rbx, %rdi
callq 0x2df7
movq (%r14), %rax
andq $-0x2, %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsi), %rcx
jmp 0x3266
movq 0x10(%rax), %rsi
movq (%rsi), %rcx
testb $0x1, %cl
je 0x3239
andq $-0x2, %rcx
movq %rcx, (%rsi)
movq (%r14), %rax
andq $-0x2, %rax
orq $0x1, (%rax)
movq (%r14), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2df7
movq (%r14), %rax
movq %rax, %rcx
andq $-0x2, %rcx
movq 0x10(%rcx), %rsi
movq 0x8(%rsi), %rdx
movq 0x10(%rsi), %rcx
movq (%rdx), %rdi
movq (%rcx), %r8
movl %r8d, %r9d
orl %edi, %r9d
testb $0x1, %r9b
jne 0x3298
orb $0x1, (%rsi)
movq (%r14), %r14
andq $-0x2, %r14
jmp 0x32f8
andq $-0x2, %rax
movq (%rsi), %rdx
andq $-0x2, %rdx
movq (%rax), %rax
andl $0x1, %eax
orq %rdx, %rax
movq %rax, (%rsi)
movq (%r14), %rax
andq $-0x2, %rax
andq $-0x2, (%rax)
andb $-0x2, (%rcx)
movq (%r14), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2e6d
jmp 0x32f5
testb $0x1, %r8b
jne 0x32c1
andq $-0x2, %rdi
movq %rdi, (%rdx)
orb $0x1, (%rsi)
movq %rbx, %rdi
callq 0x2e6d
movq (%r14), %rax
andq $-0x2, %rax
movq 0x10(%rax), %rsi
movq 0x10(%rsi), %rcx
jmp 0x32c5
andq $-0x2, %rax
movq (%rsi), %rdx
andq $-0x2, %rdx
movq (%rax), %rax
andl $0x1, %eax
orq %rdx, %rax
movq %rax, (%rsi)
movq (%r14), %rax
andq $-0x2, %rax
andq $-0x2, (%rax)
andb $-0x2, (%rcx)
movq (%r14), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2df7
movq (%rbx), %r14
cmpq (%rbx), %r14
jne 0x3177
andb $-0x2, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq