// File: 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
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x9636
jmp 0x985e
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x965e
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x966a
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x9802
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x96d7
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x96d7
movq -0x30(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x9870
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x20, %rsi
callq 0x9990
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
addq $0x20, %rsi
callq 0x9990
jmp 0x9800
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x9741
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x9741
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x9870
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x99c0
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
addq $0x20, %rsi
callq 0x9990
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rsi
addq $0x20, %rsi
callq 0x9990
jmp 0x97fe
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x9795
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x9795
movq -0x30(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x99c0
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x20, %rsi
callq 0x9990
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rsi
addq $0x20, %rsi
callq 0x9990
jmp 0x97fc
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x97fa
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x97fa
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x99c0
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x9870
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
addq $0x20, %rsi
callq 0x9990
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rsi
addq $0x20, %rsi
callq 0x9990
jmp 0x97fc
jmp 0x97fe
jmp 0x9800
jmp 0x985e
movq -0x28(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jne 0x985c
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x20, %rsi
callq 0x9990
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x20, %rsi
callq 0x9990
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
cmpq 0x8(%rcx), %rax
je 0x985a
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x20, %rsi
callq 0x9990
movq -0x30(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x9600
jmp 0x985c
jmp 0x985e
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop