// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rsi), %r15
leaq 0x8(%rdi), %r12
movq %rsi, %rax
cmpq %r12, %r15
je 0x2d47
cmpq %r12, 0x10(%r14)
je 0x2d47
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a86
movq 0x8(%rax), %r15
cmpq %r12, %r15
jne 0x2d50
movq 0x10(%rax), %r15
movq (%rax), %rcx
andq $-0x2, %rcx
movq (%r15), %rdx
andl $0x1, %edx
orq %rcx, %rdx
movq %rdx, (%r15)
movq (%rax), %rcx
movq %rcx, %rsi
andq $-0x2, %rsi
movq %rbx, %rdx
cmpq %rsi, %r12
je 0x2d85
leaq 0x8(%rsi), %rdi
leaq 0x10(%rsi), %rdx
cmpq %rax, 0x8(%rsi)
cmoveq %rdi, %rdx
movq %r15, (%rdx)
andl $0x1, %ecx
cmpq %r14, %rax
je 0x2e01
movq (%r14), %rdx
andq $-0x2, %rdx
orq %rcx, %rdx
movq %rdx, (%rax)
movq (%r14), %rdx
andq $-0x2, %rdx
movq %rbx, %rsi
cmpq %rdx, %r12
je 0x2dbc
leaq 0x8(%rdx), %rdi
leaq 0x10(%rdx), %rsi
cmpq %r14, 0x8(%rdx)
cmoveq %rdi, %rsi
movq %rax, (%rsi)
movq 0x8(%r14), %rdx
movq %rdx, 0x8(%rax)
movq %rax, %rsi
andq $-0x2, %rsi
movq (%rdx), %rdi
andl $0x1, %edi
orq %rsi, %rdi
movq %rdi, (%rdx)
movq 0x10(%r14), %rdx
movq %rdx, 0x10(%rax)
movq (%rdx), %rdi
andl $0x1, %edi
orq %rsi, %rdi
movq %rdi, (%rdx)
movq (%rax), %rdx
andq $-0x2, %rdx
movq (%r14), %rsi
andl $0x1, %esi
orq %rdx, %rsi
movq %rsi, (%rax)
testq %rcx, %rcx
jne 0x2fa9
movq (%r15), %rax
cmpq (%rbx), %r15
je 0x2fa2
movl %eax, %ecx
andl $0x1, %ecx
jne 0x2fa2
movq 0x8(%rax), %rsi
cmpq %rsi, %r15
je 0x2e9d
movq (%rsi), %rcx
testb $0x1, %cl
je 0x2e61
andq $-0x2, %rcx
movq %rcx, (%rsi)
movq (%r15), %rax
andq $-0x2, %rax
orq $0x1, (%rax)
movq (%r15), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2b2d
movq (%r15), %rax
movq %rax, %rcx
andq $-0x2, %rcx
movq 0x8(%rcx), %rsi
movq 0x8(%rsi), %rcx
testb $0x1, (%rcx)
jne 0x2f01
movq 0x10(%rsi), %rax
movq (%rax), %rcx
testb $0x1, %cl
je 0x2ef2
andq $-0x2, %rcx
movq %rcx, (%rax)
orb $0x1, (%rsi)
movq %rbx, %rdi
callq 0x2ab7
movq (%r15), %rax
andq $-0x2, %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsi), %rcx
jmp 0x2f05
movq 0x10(%rax), %rsi
movq (%rsi), %rcx
testb $0x1, %cl
je 0x2ed8
andq $-0x2, %rcx
movq %rcx, (%rsi)
movq (%r15), %rax
andq $-0x2, %rax
orq $0x1, (%rax)
movq (%r15), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2ab7
movq (%r15), %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 0x2f3d
orb $0x1, (%rsi)
movq (%r15), %r15
andq $-0x2, %r15
jmp 0x2e0a
andq $-0x2, %rax
movq (%rsi), %rdx
andq $-0x2, %rdx
movq (%rax), %rax
andl $0x1, %eax
orq %rdx, %rax
movq %rax, (%rsi)
movq (%r15), %rax
andq $-0x2, %rax
andq $-0x2, (%rax)
andb $-0x2, (%rcx)
movq (%r15), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2b2d
movq (%rbx), %r15
jmp 0x2e0a
testb $0x1, %r8b
jne 0x2f66
andq $-0x2, %rdi
movq %rdi, (%rdx)
orb $0x1, (%rsi)
movq %rbx, %rdi
callq 0x2b2d
movq (%r15), %rax
andq $-0x2, %rax
movq 0x10(%rax), %rsi
movq 0x10(%rsi), %rcx
jmp 0x2f6a
andq $-0x2, %rax
movq (%rsi), %rdx
andq $-0x2, %rdx
movq (%rax), %rax
andl $0x1, %eax
orq %rdx, %rax
movq %rax, (%rsi)
movq (%r15), %rax
andq $-0x2, %rax
andq $-0x2, (%rax)
andb $-0x2, (%rcx)
movq (%r15), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2ab7
movq (%rbx), %r15
jmp 0x2e0a
andq $-0x2, %rax
movq %rax, (%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq