// File: /workspace/github_cpp_makefile_star2_O3/roberty65[P]bServer/common/src/rbtree.c
// Function: rb_erase
void rb_erase(struct rb_node *node, struct rb_root *root)
{
	struct rb_node *child, *parent;
	int color;

	if (!node->rb_left)
		child = node->rb_right;
	else if (!node->rb_right)
		child = node->rb_left;
	else
	{
		struct rb_node *old = node, *left;

		node = node->rb_right;
		while ((left = node->rb_left) != 0 /*NULL*/)
			node = left;
		child = node->rb_right;
		parent = rb_parent(node);
		color = rb_color(node);

		if (child)
			rb_set_parent(child, parent);
		if (parent == old) {
			parent->rb_right = child;
			parent = node;
		} else
			parent->rb_left = child;

		node->rb_parent_color = old->rb_parent_color;
		node->rb_right = old->rb_right;
		node->rb_left = old->rb_left;

		if (rb_parent(old))
		{
			if (rb_parent(old)->rb_left == old)
				rb_parent(old)->rb_left = node;
			else
				rb_parent(old)->rb_right = node;
		} else
			root->rb_node = node;

		rb_set_parent(old->rb_left, node);
		if (old->rb_right)
			rb_set_parent(old->rb_right, node);
		goto color;
	}

	parent = rb_parent(node);
	color = rb_color(node);

	if (child)
		rb_set_parent(child, parent);
	if (parent)
	{
		if (parent->rb_left == node)
			parent->rb_left = child;
		else
			parent->rb_right = child;
	}
	else
		root->rb_node = child;

 color:
	if (color == RB_BLACK)
		__rb_erase_color(child, parent, root);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq 0x8(%rdi), %r8
movq 0x10(%rdi), %rsi
testq %rsi, %rsi
je 0x7ddf
testq %r8, %r8
je 0x7df3
movq %r8, %rax
movq %rax, %rdx
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x7da4
movq (%rdx), %rcx
movq 0x8(%rdx), %r14
movq %rcx, %rax
andq $-0x4, %rax
testq %r14, %r14
je 0x7dd0
movq (%r14), %r9
andl $0x3, %r9d
orq %rax, %r9
movq %r9, (%r14)
cmpq %rdi, %rax
je 0x7e0e
movq %r14, 0x10(%rax)
movq 0x10(%rdi), %rsi
jmp 0x7e19
movq (%rdi), %rcx
movq %rcx, %rax
andq $-0x4, %rax
testq %r8, %r8
je 0x7e6b
movq %r8, %rsi
jmp 0x7dfd
movq (%rdi), %rcx
movq %rcx, %rax
andq $-0x4, %rax
movq (%rsi), %rdx
andl $0x3, %edx
orq %rax, %rdx
movq %rdx, (%rsi)
movq %rsi, %r14
jmp 0x7e6e
movq %r14, 0x8(%rax)
movq 0x8(%rdi), %r8
movq %rdx, %rax
movq (%rdi), %r9
movq %r9, (%rdx)
movq %r8, 0x8(%rdx)
movq %rsi, 0x10(%rdx)
movq %rbx, %rsi
andq $-0x4, %r9
je 0x7e40
leaq 0x10(%r9), %r8
leaq 0x8(%r9), %rsi
cmpq %rdi, 0x10(%r9)
cmoveq %r8, %rsi
movq %rdx, (%rsi)
movq 0x10(%rdi), %rsi
movq (%rsi), %r8
andl $0x3, %r8d
orq %rdx, %r8
movq %r8, (%rsi)
movq 0x8(%rdi), %rsi
testq %rsi, %rsi
je 0x7e8a
movq (%rsi), %rdi
andl $0x3, %edi
orq %rdx, %rdi
movq %rdi, (%rsi)
jmp 0x7e8a
xorl %r14d, %r14d
testq %rax, %rax
je 0x7e7f
cmpq %rdi, 0x10(%rax)
je 0x7e86
movq %r14, 0x8(%rax)
jmp 0x7e8a
movq %r14, (%rbx)
xorl %eax, %eax
jmp 0x7e8a
movq %r14, 0x10(%rax)
testb $0x1, %cl
je 0x800c
movq %r14, %rcx
movq %rax, %r14
testq %rcx, %rcx
je 0x7ea9
movq (%rcx), %rax
testb $0x1, %al
je 0x8005
cmpq (%rbx), %rcx
je 0x7ffd
movq 0x10(%r14), %rdi
cmpq %rcx, %rdi
je 0x7f01
movq (%rdi), %rax
testb $0x1, %al
jne 0x7edc
orq $0x1, %rax
movq %rax, (%rdi)
andb $-0x2, (%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7d2e
movq 0x10(%r14), %rdi
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x7eee
testb $0x1, (%rax)
je 0x7f7c
movq 0x8(%rdi), %rcx
testq %rcx, %rcx
je 0x7f49
movq (%rcx), %rdx
testb $0x1, %dl
jne 0x7f49
jmp 0x7f58
movq 0x8(%r14), %rdi
movq (%rdi), %rax
testb $0x1, %al
jne 0x7f26
orq $0x1, %rax
movq %rax, (%rdi)
andb $-0x2, (%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7cd4
movq 0x8(%r14), %rdi
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x7f37
movq (%rcx), %rdx
testb $0x1, %dl
je 0x7fa8
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x7f49
testb $0x1, (%rax)
je 0x7fd0
andb $-0x2, (%rdi)
movq (%r14), %rax
andq $-0x4, %rax
jmp 0x7e93
testq %rax, %rax
je 0x7f62
testb $0x1, (%rax)
je 0x7f7c
orq $0x1, %rdx
movq %rdx, (%rcx)
andb $-0x2, (%rdi)
movq %rbx, %rsi
callq 0x7cd4
movq 0x10(%r14), %rdi
movq 0x10(%rdi), %rax
movq (%r14), %rcx
andl $0x1, %ecx
movq (%rdi), %rdx
andq $-0x2, %rdx
orq %rcx, %rdx
movq %rdx, (%rdi)
orb $0x1, (%r14)
testq %rax, %rax
je 0x7f9b
orb $0x1, (%rax)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7d2e
jmp 0x7ffa
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x7fb6
testb $0x1, (%rax)
je 0x7fd0
orq $0x1, %rdx
movq %rdx, (%rcx)
andb $-0x2, (%rdi)
movq %rbx, %rsi
callq 0x7d2e
movq 0x8(%r14), %rdi
movq 0x8(%rdi), %rax
movq (%r14), %rcx
andl $0x1, %ecx
movq (%rdi), %rdx
andq $-0x2, %rdx
orq %rcx, %rdx
movq %rdx, (%rdi)
orb $0x1, (%r14)
testq %rax, %rax
je 0x7fef
orb $0x1, (%rax)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7cd4
movq (%rbx), %rcx
testq %rcx, %rcx
je 0x800c
movq (%rcx), %rax
orq $0x1, %rax
movq %rax, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq