// File: /workspace/github_cpp_makefile_star2_O2/DimitriDaSilva[P]42_ft_containers/containers/utils/red_black_tree.hpp
// Function: ft::red_black_tree<int, int, ft::less<int>, std::allocator<ft::red_black_tree_node<int>>>::fix_double_black(ft::red_black_tree_node<int>*)
void
		fix_double_black(node_pointer node)
		{
			node_pointer parent;
			node_pointer sibling;

			// Base case of recursion: if DB is root, nothing to do
			if (node == _root)
				return;

			parent = node->parent;

			// Get double black's sibling. If it's a double black, it
			// necessarily has one
			if (parent->left == node)
				sibling = parent->right;
			else
				sibling = parent->left;

			// Case: DB's sibling is black and its children are black
			if (sibling->color == black
					&& sibling->left->color == black
					&& sibling->right->color == black)
			{
				// DB gives blackness to parent and sibling
				// gets mad (ie becomes red)
				if (parent->color == red)
				{
					parent->color = black;
					sibling->color = red;
				}
				else if (parent->color == black)
				{
					sibling->color = red;
					// If parent is already black it carries double-blackness
					fix_double_black(parent);
				}
			}
			// Case: DB's sibling is red
			else if (sibling->color == red)
			{
				parent->color = red;
				sibling->color = black;

				// Rotate towards the direction of the node we want to delete
				if (parent->left == node)
					rotate_left(sibling);
				else
					rotate_right(sibling);

				// Double black case still exists but the sibling of the node
				// we want to delete has changed
				fix_double_black(node);
			}
			// Case: DB's sibling is black and nearest sibling's child is red
			// and furthest from DB is black
			else if (sibling->color == black
					&& ((sibling == parent->right
						&& sibling->left->color == red
						&& sibling->right->color == black)
						|| (sibling == parent->left
							&& sibling->left->color == black
							&& sibling->right->color == red)))
			{
				if (sibling == parent->right)
				{
					swap_color(sibling, sibling->left);
					rotate_right(sibling->left);
				}
				else
				{
					swap_color(sibling, sibling->right);
					rotate_left(sibling->right);
				}

				// Double black case still exists but the sibling of the node
				// we want to delete has changed
				fix_double_black(node);
			}
			// Case: DB's sibling is black and furthest sibling's child is red
			else if (sibling->color == black
					&& ((sibling == parent->right
						&& sibling->right->color == red)
						|| (sibling == parent->left
							&& sibling->left->color == red)))
			{
				swap_color(parent, sibling);

				// Rotate parent towards DB
				if (sibling == parent->right)
				{
					rotate_left(sibling);
					sibling->right->color = black;
				}
				else
				{
					rotate_right(sibling);
					sibling->left->color = black;
				}
			}
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpq %rsi, 0x8(%rdi)
je 0xc43a
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rsi), %rax
movq 0x10(%rax), %rcx
movq %rcx, %rsi
cmpq %r14, %rcx
jne 0xc2e3
movq 0x18(%rax), %rsi
movq %rsi, -0x18(%rbp)
movl 0x20(%rsi), %edx
testl %edx, %edx
je 0xc332
cmpl $0x1, %edx
jne 0xc43a
movq 0x10(%rsi), %r8
movl 0x20(%r8), %edx
cmpl $0x1, %edx
jne 0xc350
movq 0x18(%rsi), %rdi
cmpl $0x1, 0x20(%rdi)
jne 0xc36f
movl 0x20(%rax), %ecx
cmpl $0x1, %ecx
je 0xc443
testl %ecx, %ecx
jne 0xc43a
movl $0x1, 0x20(%rax)
andl $0x0, 0x20(%rsi)
jmp 0xc43a
andl $0x0, 0x20(%rax)
movl $0x1, 0x20(%rsi)
leaq -0x18(%rbp), %rsi
movq %rbx, %rdi
cmpq %r14, %rcx
je 0xc35a
callq 0x8c88
jmp 0xc35f
cmpq 0x18(%rax), %rsi
je 0xc379
xorl %edi, %edi
jmp 0xc38b
callq 0x8c1e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc2b4
jmp 0xc43a
cmpq 0x18(%rax), %rsi
sete %dil
jmp 0xc38b
movb $0x1, %dil
testl %edx, %edx
jne 0xc38b
movq 0x18(%rsi), %r9
cmpl $0x1, 0x20(%r9)
je 0xc3f7
cmpl $0x1, %edx
setne %r9b
cmpq %rcx, %rsi
setne %r10b
orb %r9b, %r10b
jne 0xc3a9
movq 0x18(%rsi), %r9
cmpl $0x0, 0x20(%r9)
je 0xc3f2
testb %dil, %dil
je 0xc3b9
movq 0x18(%rsi), %r8
cmpl $0x0, 0x20(%r8)
je 0xc410
cmpq %rcx, %rsi
setne %cl
testl %edx, %edx
setne %dl
orb %cl, %dl
jne 0xc43a
movl 0x20(%rax), %ecx
movl %ecx, 0x20(%rsi)
movl $0x1, 0x20(%rax)
testb %dil, %dil
jne 0xc41d
leaq -0x18(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8c88
movq (%r14), %rax
movq 0x10(%rax), %rax
jmp 0xc433
testb %dil, %dil
je 0xc44f
movl $0x1, 0x20(%r8)
movl %edx, 0x20(%rsi)
addq $0x10, %rsi
movq %rbx, %rdi
callq 0x8c88
jmp 0xc467
movl 0x20(%rax), %ecx
movl %ecx, 0x20(%rsi)
movl $0x1, 0x20(%rax)
leaq -0x18(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8c1e
movq (%r14), %rax
movq 0x18(%rax), %rax
movl $0x1, 0x20(%rax)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
andl $0x0, 0x20(%rsi)
movq %rbx, %rdi
movq %rax, %rsi
jmp 0xc46d
movl $0x1, 0x20(%r9)
andl $0x0, 0x20(%rsi)
addq $0x18, %rsi
movq %rbx, %rdi
callq 0x8c1e
movq %rbx, %rdi
movq %r14, %rsi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xc2b4