// File: /workspace/github_c_makefile_star2_O0/ngkaho1234[P]ext4-extents-tree/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) != NULL)
			node = 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;

		child = node->rb_right;
		parent = rb_parent(node);
		color = rb_color(node);

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

			node->rb_right = old->rb_right;
			rb_set_parent(old->rb_right, node);
		}

		node->rb_parent_color = old->rb_parent_color;
		node->rb_left = old->rb_left;
		rb_set_parent(old->rb_left, 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 == EVENT_RB_BLACK)
		__rb_erase_color(child, parent, root);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x47ac
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x4904
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x47c8
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x4902
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x47f8
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x47dc
movq -0x30(%rbp), %rax
movq (%rax), %rax
andq $-0x4, %rax
cmpq $0x0, %rax
je 0x4848
movq -0x30(%rbp), %rax
movq (%rax), %rax
andq $-0x4, %rax
movq 0x10(%rax), %rax
cmpq -0x30(%rbp), %rax
jne 0x4833
movq -0x8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq (%rax), %rax
andq $-0x4, %rax
movq %rcx, 0x10(%rax)
jmp 0x4846
movq -0x8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq (%rax), %rax
andq $-0x4, %rax
movq %rcx, 0x8(%rax)
jmp 0x4853
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
andq $-0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
andq $0x1, %rax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x4890
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x48d1
cmpq $0x0, -0x18(%rbp)
je 0x48a4
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4990
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x4990
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x4990
jmp 0x4973
jmp 0x4904
movq -0x8(%rbp), %rax
movq (%rax), %rax
andq $-0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
andq $0x1, %rax
movl %eax, -0x24(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x4935
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4990
cmpq $0x0, -0x20(%rbp)
je 0x4966
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x4958
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x4964
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x4971
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4973
cmpl $0x1, -0x24(%rbp)
jne 0x498a
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x49c0
addq $0x40, %rsp
popq %rbp
retq