// File: /workspace/github_cpp_makefile_star2_O1/DimitriDaSilva[P]42_ft_containers/containers/utils/red_black_tree.hpp
// Function: ft::red_black_tree<int, int, ft::less<int>, custom_allocator<ft::red_black_tree_node<int>>>::check_insert(ft::red_black_tree_node<int>*&)
void
		check_insert(node_pointer& node)
		{
			node_pointer parent = node->parent;
			node_pointer grandparent;
			node_pointer uncle;

			// Base case of recursion
			if (parent->color == black)
				return;

			grandparent = parent->parent;
			uncle = grandparent->left == parent ?
					grandparent->right :
					grandparent->left;

			if (uncle->color == black)
			{
				// Rotate && recolor
				// Right - right situation
				if (parent->right == node && grandparent->right == parent)
				{
					rotate_left(parent);
					recolor(parent->color);
					recolor(parent->left->color);
				}
				// Right - left situation
				else if (parent->right == node && grandparent->left == parent)
				{
					rotate_left(node);
					rotate_right(node);
					recolor(node->color);
					recolor(node->right->color);
				}
				// Left - left situation
				else if (parent->left == node && grandparent->left == parent)
				{
					rotate_right(parent);
					recolor(parent->color);
					recolor(parent->right->color);
				}
				// Left - right situation
				else if (parent->left == node && grandparent->right == parent)
				{
					rotate_right(node);
					rotate_left(node);
					recolor(node->color);
					recolor(node->left->color);
				}
			}
			else if (uncle->color == red)
			{
				// Recolor parent and uncle
				recolor(parent->color);
				recolor(uncle->color);

				// If grandparent of new_node is not root node
				// recolor it and recheck
				if (grandparent != _root)
				{
					// Recolor
					recolor(grandparent->color);
					// Recheck with grandparent as node
					check_insert(grandparent);
				}
			}
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq (%rsi), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, -0x18(%rbp)
movl 0x20(%rcx), %edi
cmpl $0x1, %edi
je 0x6ff2
movq %rsi, %r14
movq 0x8(%rcx), %rax
movq %rax, -0x20(%rbp)
movq 0x10(%rax), %rsi
movq %rsi, %r8
cmpq %rcx, %rsi
jne 0x6eea
movq 0x18(%rax), %r8
movl 0x20(%r8), %r9d
testl %r9d, %r9d
je 0x6f3f
cmpl $0x1, %r9d
jne 0x6ff2
movq 0x18(%rcx), %rdi
cmpq %rdx, %rdi
je 0x6f7b
xorq %rcx, %rsi
movq 0x10(%rcx), %rdi
movq %rdi, %r8
xorq %rdx, %r8
orq %rsi, %r8
je 0x6fa0
cmpq %rdx, %rdi
jne 0x6ff2
cmpq %rcx, 0x18(%rax)
jne 0x6ff2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7066
jmp 0x6fc8
xorl %edx, %edx
testl %edi, %edi
sete %dl
movl %edx, 0x20(%rcx)
xorl %ecx, %ecx
cmpl $0x0, 0x20(%r8)
sete %cl
movl %ecx, 0x20(%r8)
cmpq 0x8(%rbx), %rax
je 0x6ff2
xorl %ecx, %ecx
cmpl $0x0, 0x20(%rax)
sete %cl
movl %ecx, 0x20(%rax)
leaq -0x20(%rbp), %rsi
movq %rbx, %rdi
callq 0x6eaa
jmp 0x6ff2
cmpq %rcx, 0x18(%rax)
je 0x6fc4
xorq %rdx, %rdi
movq %rsi, %r8
xorq %rcx, %r8
orq %rdi, %r8
jne 0x6f06
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6ffc
jmp 0x6fa4
leaq -0x18(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7066
movq (%r14), %rax
xorl %ecx, %ecx
cmpl $0x0, 0x20(%rax)
sete %cl
movl %ecx, 0x20(%rax)
movq 0x18(%rax), %rax
jmp 0x6fe6
leaq -0x18(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6ffc
movq (%r14), %rax
xorl %ecx, %ecx
cmpl $0x0, 0x20(%rax)
sete %cl
movl %ecx, 0x20(%rax)
movq 0x10(%rax), %rax
xorl %ecx, %ecx
cmpl $0x0, 0x20(%rax)
sete %cl
movl %ecx, 0x20(%rax)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop