// File: DimitriDaSilva[P]42_ft_containers/containers/utils/red_black_tree.hpp
// Function: ft::red_black_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, ft::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, custom_allocator<ft::red_black_tree_node<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>::insert_helper(ft::red_black_tree_node<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>*, ft::red_black_tree_node<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>*)
node_pointer
		insert_helper(node_pointer node, node_pointer hint)
		{
			node->parent = find_right_position(node, hint);

			// Set node in the position found. Either left or right
			// If parent NULL then it means we are at the root of the tree
			// so we can retrun
			if (node->parent == NULL)
			{
				_root = node;
				_root->color = black;

				return _root;
			}
			else if (_comp(get_key_from_val(node->data), get_key_from_val(node->parent->data)))
				node->parent->left = node;
			else
				node->parent->right = node;

			// If parent is _root then we are at level 1 of the tree
			// so we can't be unbalancing the tree
			// Else the new node could have unbalanced the red-black tree
			// so we need to check after each insert
			if (node->parent != _root)
				check_insert(node);

			return node;
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x78(%rbp)
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xac20
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0xa636
movq -0x78(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq 0x8(%rax), %rcx
movl $0x1, 0x38(%rcx)
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0xa729
movq -0x78(%rbp), %rsi
movq %rsi, %rax
addq $0x20, %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdx
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x40(%rbp), %rdi
callq *%rax
movq -0x78(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdx
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x60(%rbp), %rdi
callq *%rax
jmp 0xa671
movq -0x80(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0xaa00
movb %al, -0x81(%rbp)
jmp 0xa68a
leaq -0x60(%rbp), %rdi
callq 0x6130
jmp 0xa695
leaq -0x40(%rbp), %rdi
callq 0x6130
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0xa6aa
jmp 0xa6f0
movq -0x18(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x28(%rax)
jmp 0xa700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xa6e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x6130
jmp 0xa6e1
jmp 0xa6e3
leaq -0x40(%rbp), %rdi
callq 0x6130
jmp 0xa6ee
jmp 0xa736
movq -0x18(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x30(%rax)
jmp 0xa702
movq -0x78(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
cmpq 0x8(%rcx), %rax
je 0xa721
movq -0x78(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xad50
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x6310
movq %rax, %rdi
callq 0x7110
nopw (%rax,%rax)