// File: 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>>>::insert(ft::bidirectional_iterator<ft::red_black_tree_node<int>>, int const&)
iterator
		insert(iterator hint, value_type const& val)
		{
			node_pointer successor = get_successor(hint._ptr);
			node_pointer node;

			// Check if position is correct
			if (_comp(get_key_from_iterator(hint), get_key_from_val(val))
					&& _comp(get_key_from_val(val), get_key_from_val(successor->data)))
			{
				// New nodes are necessarily red and leaf nodes so they point
				// to _nil
				node = _alloc.allocate(1);
				_alloc.construct(node, node_type(val, NULL, _nil, _nil, red));

				_size++;

				return iterator(insert_helper(node, hint._ptr), _root, _nil);
			}
			else
				return insert(val).first;
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdx, -0xe8(%rbp)
movq %rdi, -0xf8(%rbp)
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
movq 0x8(%rdx), %rsi
callq 0x15d80
movq -0xe8(%rbp), %rsi
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x28(%rbp)
addq $0x20, %rax
movq %rax, -0xe0(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x90e0
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, -0xc4(%rbp)
jmp 0x156c6
movq -0xd8(%rbp), %rdi
movl -0xc4(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rsi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0xfc(%rbp)
jmp 0x156eb
movq -0xe0(%rbp), %rdi
movl -0xfc(%rbp), %eax
movl %eax, -0x68(%rbp)
leaq -0x34(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x93b0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xfd(%rbp)
jne 0x15719
jmp 0x1578b
movq -0xd8(%rbp), %rdi
movq %rdi, %rax
addq $0x20, %rax
movq %rax, -0x110(%rbp)
movq -0x20(%rbp), %rsi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x104(%rbp)
jmp 0x15743
movq -0xd8(%rbp), %rdi
movl -0x104(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x28(%rbp), %rsi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x114(%rbp)
jmp 0x15768
movq -0x110(%rbp), %rdi
movl -0x114(%rbp), %eax
movl %eax, -0x70(%rbp)
leaq -0x6c(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x93b0
movb %al, -0xfd(%rbp)
movb -0xfd(%rbp), %al
movb %al, -0x115(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x8600
movb -0x115(%rbp), %al
testb $0x1, %al
jne 0x157af
jmp 0x1588a
movq -0xd8(%rbp), %rdi
addq $0x21, %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x88b0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq %rax, %rcx
addq $0x21, %rcx
movq %rcx, -0x128(%rbp)
movq -0x30(%rbp), %rcx
movq %rcx, -0x120(%rbp)
movq -0x20(%rbp), %rcx
movl (%rcx), %esi
movq 0x10(%rax), %rcx
movq 0x10(%rax), %r8
leaq -0x98(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
xorl %r9d, %r9d
callq 0x8940
movq -0x128(%rbp), %rdi
movq -0x120(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0x8910
movq -0xe8(%rbp), %rax
movq -0xd8(%rbp), %rdi
movq 0x18(%rdi), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rdi)
movq -0x30(%rbp), %rsi
movq 0x8(%rax), %rdx
callq 0xe0c0
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
movq -0xd8(%rbp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
callq 0x9230
jmp 0x158e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x8600
jmp 0x15888
jmp 0x158f7
movq -0xd8(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0xc730
movq -0xf8(%rbp), %rdi
movq -0x130(%rbp), %rsi
callq 0x90e0
jmp 0x158bd
leaq -0xc0(%rbp), %rdi
callq 0x7e20
jmp 0x158e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x7e20
jmp 0x158e5
jmp 0x158f7
movq -0xf0(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x6310
movq %rax, %rdi
callq 0x7110
nopl (%rax,%rax)