// File: /workspace/github_cpp_makefile_star2_O3/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), %rax
movq %rax, -0x18(%rbp)
movl 0x20(%rax), %edi
cmpl $0x1, %edi
je 0x6f4a
movq %rsi, %r14
movq 0x8(%rax), %rcx
movq %rcx, -0x20(%rbp)
movq 0x10(%rcx), %rsi
movq %rsi, %r8
cmpq %rax, %rsi
jne 0x6e54
movq 0x18(%rcx), %r8
movl 0x20(%r8), %r9d
testl %r9d, %r9d
je 0x6e86
cmpl $0x1, %r9d
jne 0x6f4a
cmpq %rdx, 0x18(%rax)
je 0x6ec5
cmpq %rdx, 0x10(%rax)
jne 0x6f4a
cmpq %rax, %rsi
je 0x6f0f
movq 0x18(%rcx), %rcx
jmp 0x6ed9
xorl %edx, %edx
testl %edi, %edi
sete %dl
movl %edx, 0x20(%rax)
xorl %eax, %eax
cmpl $0x0, 0x20(%r8)
sete %al
movl %eax, 0x20(%r8)
cmpq 0x8(%rbx), %rcx
je 0x6f4a
xorl %eax, %eax
cmpl $0x0, 0x20(%rcx)
sete %al
movl %eax, 0x20(%rcx)
leaq -0x20(%rbp), %rsi
movq %rbx, %rdi
callq 0x6e14
jmp 0x6f4a
movq 0x18(%rcx), %rcx
cmpq %rax, %rcx
je 0x6eeb
cmpq %rax, %rsi
je 0x6f15
cmpq %rdx, 0x10(%rax)
jne 0x6f4a
cmpq %rax, %rcx
jne 0x6f4a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6fbe
jmp 0x6eef
leaq -0x18(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6f54
movq (%r14), %rax
xorl %ecx, %ecx
cmpl $0x0, 0x20(%rax)
sete %cl
movl %ecx, 0x20(%rax)
movq 0x10(%rax), %rax
jmp 0x6f3e
leaq -0x18(%rbp), %r14
jmp 0x6f20
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6f54
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6fbe
movq (%r14), %rax
xorl %ecx, %ecx
cmpl $0x0, 0x20(%rax)
sete %cl
movl %ecx, 0x20(%rax)
movq 0x18(%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