// File: /workspace/github_c_makefile_star2_O1/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
leaq 0x8(%rdi), %rdx
movq %rsi, %rax
cmpq %rdx, 0x8(%rsi)
je 0x30bb
movq 0x10(%rsi), %rcx
movq %rsi, %rax
cmpq %rdx, %rcx
je 0x30bb
movq %rcx, %rax
movq 0x8(%rcx), %rcx
cmpq %rcx, %rdx
jne 0x30af
movq 0x8(%rax), %r14
cmpq %rdx, %r14
jne 0x30c8
movq 0x10(%rax), %r14
movq (%rax), %rcx
andq $-0x2, %rcx
movq (%r14), %rdi
andl $0x1, %edi
orq %rcx, %rdi
movq %rdi, (%r14)
movq (%rax), %rcx
movq %rcx, %r8
andq $-0x2, %r8
movq %rbx, %rdi
cmpq %r8, %rdx
je 0x30fd
leaq 0x8(%r8), %r9
leaq 0x10(%r8), %rdi
cmpq %rax, 0x8(%r8)
cmoveq %r9, %rdi
movq %r14, (%rdi)
andl $0x1, %ecx
cmpq %rsi, %rax
je 0x3183
movq (%rsi), %rdi
andq $-0x2, %rdi
orq %rcx, %rdi
movq %rdi, (%rax)
movq (%rsi), %rdi
andq $-0x2, %rdi
movq %rbx, %r8
cmpq %rdi, %rdx
je 0x3134
leaq 0x8(%rdi), %rdx
leaq 0x10(%rdi), %r8
cmpq %rsi, 0x8(%rdi)
cmoveq %rdx, %r8
movq %rax, (%r8)
movq 0x8(%rsi), %rdx
movq %rdx, 0x8(%rax)
movq %rax, %rdx
andq $-0x2, %rdx
movq 0x8(%rsi), %rdi
movq (%rdi), %r8
andl $0x1, %r8d
orq %rdx, %r8
movq %r8, (%rdi)
movq 0x10(%rsi), %rdi
movq %rdi, 0x10(%rax)
movq 0x10(%rsi), %rdi
movq (%rdi), %r8
andl $0x1, %r8d
orq %rdx, %r8
movq %r8, (%rdi)
movq (%rax), %rdx
andq $-0x2, %rdx
movq (%rsi), %rsi
andl $0x1, %esi
orq %rdx, %rsi
movq %rsi, (%rax)
testq %rcx, %rcx
jne 0x3321
cmpq %r14, (%rbx)
je 0x331d
movq (%r14), %rax
testb $0x1, %al
jne 0x331d
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x3257
movq (%rsi), %rax
testb $0x1, %al
je 0x31e0
andq $-0x2, %rax
movq %rax, (%rsi)
movq (%r14), %rax
andq $-0x2, %rax
orq $0x1, (%rax)
movq (%r14), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2e95
movq (%r14), %rax
andq $-0x2, %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsi), %rax
testb $0x1, (%rax)
jne 0x3216
movq 0x10(%rsi), %rax
movq (%rax), %rcx
testb $0x1, %cl
je 0x32a3
andq $-0x2, %rcx
movq %rcx, (%rax)
orb $0x1, (%rsi)
movq %rbx, %rdi
callq 0x2e1f
movq (%r14), %rax
andq $-0x2, %rax
movq 0x8(%rax), %rsi
movq (%rsi), %rax
andq $-0x2, %rax
movq (%r14), %rcx
andq $-0x2, %rcx
movq (%rcx), %rcx
andl $0x1, %ecx
orq %rax, %rcx
movq %rcx, (%rsi)
movq (%r14), %rax
andq $-0x2, %rax
andq $-0x2, (%rax)
movq 0x8(%rsi), %rax
andq $-0x2, (%rax)
movq (%r14), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2e95
jmp 0x3311
movq 0x10(%rax), %rsi
movq (%rsi), %rax
testb $0x1, %al
je 0x328e
andq $-0x2, %rax
movq %rax, (%rsi)
movq (%r14), %rax
andq $-0x2, %rax
orq $0x1, (%rax)
movq (%r14), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2e1f
movq (%r14), %rax
andq $-0x2, %rax
movq 0x10(%rax), %rsi
movq 0x8(%rsi), %rax
movq (%rax), %rcx
testb $0x1, %cl
jne 0x32af
movq 0x10(%rsi), %rdx
testb $0x1, (%rdx)
jne 0x32af
orb $0x1, (%rsi)
movq (%r14), %r14
andq $-0x2, %r14
jmp 0x3314
movq 0x10(%rsi), %rdx
testb $0x1, (%rdx)
jne 0x32d5
andq $-0x2, %rcx
movq %rcx, (%rax)
orb $0x1, (%rsi)
movq %rbx, %rdi
callq 0x2e95
movq (%r14), %rax
andq $-0x2, %rax
movq 0x10(%rax), %rsi
movq (%rsi), %rax
andq $-0x2, %rax
movq (%r14), %rcx
andq $-0x2, %rcx
movq (%rcx), %rcx
andl $0x1, %ecx
orq %rax, %rcx
movq %rcx, (%rsi)
movq (%r14), %rax
andq $-0x2, %rax
andq $-0x2, (%rax)
movq 0x10(%rsi), %rax
andq $-0x2, (%rax)
movq (%r14), %rsi
andq $-0x2, %rsi
movq %rbx, %rdi
callq 0x2e1f
movq (%rbx), %r14
cmpq (%rbx), %r14
jne 0x3195
andb $-0x2, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq