// File: DimitriDaSilva[P]42_ft_containers/containers/vector.hpp
// Function: void ft::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>::insert<ft::random_access_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const>>(ft::random_access_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, ft::random_access_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const>, ft::random_access_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const>, ft::enable_if<!ft::is_integral<ft::random_access_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const>>::value, ft::random_access_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const>>::type*)
void
		insert(iterator position, InputIterator first, InputIterator last,
				typename ft::enable_if<!ft::is_integral<InputIterator>::value,
					InputIterator>::type* = NULL)
		{
			value_type*		new_vec;
			difference_type	distance = ft::distance(first, last);
			size_type		new_size = _size + distance;
			size_type		new_capacity;
			iterator 		it_old;
			iterator 		it_new;

			// New element requires reallocation because vector is full
			if (new_size > _capacity)
			{
				new_capacity = get_new_capacity(new_size);

				// Reallocate new
				new_vec = _allocator.allocate(new_capacity);

				// Copy sequence to new array
				it_old = begin();
				it_new = new_vec;
				while (it_old != end() || distance > 0)
				{
					// Position found
					if (it_old == position)
					{
						while (distance--)
							_allocator.construct(&*it_new++, *first++);
					}

					// Copy old to new
					if (it_old != end())
						_allocator.construct(&*it_new++, *it_old++);
				}

				// Update private data of vector
				this->~vector();
				_start = new_vec;
				_size = new_size;
				_capacity = new_capacity;
			}
			// No reallocation
			else
			{
				// We offset the whole vector by distance one item at a time
				// We need to start by the end to avoid overwritting values
				for (reverse_iterator it = rbegin() - distance;
						it != reverse_iterator(position) - distance;
						it++)
				{
					_allocator.construct(&*it, *(it + distance));
					_allocator.destroy(&*(it + distance));
				}

				// Setting the new values before position
				for (iterator it = position; it != position + distance; it++, first++)
					_allocator.construct(&*it, *first);

				// Update private data of vector
				_size += distance;
			}
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdx, -0x170(%rbp)
movq %rsi, %rax
movq -0x170(%rbp), %rsi
movq %rax, -0x168(%rbp)
movq %rsi, -0x160(%rbp)
movq %rcx, -0x150(%rbp)
movq %rdi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x540f0
movq -0x150(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x540f0
jmp 0x55b6b
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x55430
movq %rax, -0x178(%rbp)
jmp 0x55b81
leaq -0x48(%rbp), %rdi
callq 0x54040
jmp 0x55b8c
leaq -0x40(%rbp), %rdi
callq 0x54040
movq -0x178(%rbp), %rcx
movq -0x158(%rbp), %rax
movq %rcx, -0x38(%rbp)
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x56510
leaq -0x78(%rbp), %rdi
callq 0x56510
jmp 0x55bca
movq -0x158(%rbp), %rcx
movq -0x60(%rbp), %rax
cmpq 0x20(%rcx), %rax
jbe 0x56041
movq -0x158(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x55820
movq -0x158(%rbp), %rdi
movq %rax, -0x68(%rbp)
addq $0x10, %rdi
movq -0x68(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x53eb0
movq %rax, -0x180(%rbp)
jmp 0x55c14
movq -0x158(%rbp), %rsi
movq -0x180(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x564a0
jmp 0x55c31
leaq -0x70(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x56530
jmp 0x55c40
leaq -0x80(%rbp), %rdi
callq 0x564d0
jmp 0x55c4b
movq -0x30(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x56570
jmp 0x55c5d
leaq -0x78(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x56530
jmp 0x55c6f
leaq -0x88(%rbp), %rdi
callq 0x564d0
jmp 0x55c7d
jmp 0x55c7f
movq -0x158(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x565c0
jmp 0x55c94
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x56590
movb %al, -0x181(%rbp)
jmp 0x55cac
movb -0x181(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x182(%rbp)
jne 0x55ccf
jmp 0x55cc1
cmpq $0x0, -0x38(%rbp)
setg %al
movb %al, -0x182(%rbp)
movb -0x182(%rbp), %al
movb %al, -0x183(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x564d0
jmp 0x55ce9
movb -0x183(%rbp), %al
testb $0x1, %al
jne 0x55cf8
jmp 0x5600c
movq -0x168(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x56630
movb %al, -0x184(%rbp)
jmp 0x55d10
movb -0x184(%rbp), %al
testb $0x1, %al
jne 0x55d1f
jmp 0x55ec3
jmp 0x55d21
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x38(%rbp)
cmpq $0x0, %rax
je 0x55ec1
movq -0x158(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x190(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0x78(%rbp), %rsi
xorl %edx, %edx
callq 0x56660
jmp 0x55d60
leaq -0x98(%rbp), %rdi
callq 0x566c0
movq %rax, -0x198(%rbp)
jmp 0x55d75
movq -0x160(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
xorl %edx, %edx
callq 0x54070
jmp 0x55d8c
leaq -0xa0(%rbp), %rdi
callq 0x54050
movq -0x190(%rbp), %rdi
movq -0x198(%rbp), %rsi
movq %rax, %rdx
callq 0x53e60
jmp 0x55db0
leaq -0xa0(%rbp), %rdi
callq 0x54040
jmp 0x55dbe
leaq -0x98(%rbp), %rdi
callq 0x564d0
jmp 0x55dcc
jmp 0x55d21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x55df8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x54040
jmp 0x55df6
jmp 0x55df8
leaq -0x40(%rbp), %rdi
callq 0x54040
jmp 0x55e03
jmp 0x56487
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5647a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5646d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x564d0
jmp 0x55e41
jmp 0x5646d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x564d0
jmp 0x55e60
jmp 0x5646d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x564d0
jmp 0x55e7f
jmp 0x5646d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x55eae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x54040
jmp 0x55eac
jmp 0x55eae
leaq -0x98(%rbp), %rdi
callq 0x564d0
jmp 0x55ebc
jmp 0x5646d
jmp 0x55ec3
movq -0x158(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x565c0
jmp 0x55ed8
leaq -0x70(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x56590
movb %al, -0x199(%rbp)
jmp 0x55ef0
leaq -0xa8(%rbp), %rdi
callq 0x564d0
jmp 0x55efe
movb -0x199(%rbp), %al
testb $0x1, %al
jne 0x55f0d
jmp 0x56007
movq -0x158(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x1a8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
xorl %edx, %edx
callq 0x56660
jmp 0x55f33
leaq -0xb0(%rbp), %rdi
callq 0x566c0
movq %rax, -0x1b0(%rbp)
jmp 0x55f48
leaq -0xb8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
xorl %edx, %edx
callq 0x56660
jmp 0x55f5c
leaq -0xb8(%rbp), %rdi
callq 0x566c0
movq %rax, -0x1b8(%rbp)
jmp 0x55f71
movq -0x1b8(%rbp), %rdx
movq -0x1b0(%rbp), %rsi
movq -0x1a8(%rbp), %rdi
callq 0x53e60
jmp 0x55f8d
leaq -0xb8(%rbp), %rdi
callq 0x564d0
jmp 0x55f9b
leaq -0xb0(%rbp), %rdi
callq 0x564d0
jmp 0x55fa9
jmp 0x56007
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x564d0
jmp 0x55fc5
jmp 0x5646d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x55ff4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x564d0
jmp 0x55ff2
jmp 0x55ff4
leaq -0xb0(%rbp), %rdi
callq 0x564d0
jmp 0x56002
jmp 0x5646d
jmp 0x55c7f
movq -0x158(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x5601d
movq -0x158(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x20(%rax)
jmp 0x56450
movq -0x158(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x566e0
jmp 0x56056
movq -0x38(%rbp), %rdx
leaq -0xc8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x56790
jmp 0x5606f
leaq -0xd8(%rbp), %rdi
callq 0x56820
jmp 0x5607d
jmp 0x5607f
movq -0x168(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x568d0
jmp 0x56094
movq -0x38(%rbp), %rdx
leaq -0xe8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x56790
jmp 0x560ad
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x56840
movb %al, -0x1b9(%rbp)
jmp 0x560c8
leaq -0xe8(%rbp), %rdi
callq 0x56820
jmp 0x560d6
leaq -0xf8(%rbp), %rdi
callq 0x56820
jmp 0x560e4
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x56172
jmp 0x560f4
leaq -0xc8(%rbp), %rdi
callq 0x56820
jmp 0x562b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x56820
jmp 0x5611f
jmp 0x5646d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x562ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5615f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x56820
jmp 0x5615d
jmp 0x5615f
leaq -0xf8(%rbp), %rdi
callq 0x56820
jmp 0x5616d
jmp 0x562ba
movq -0x158(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x1d0(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x56910
movq %rax, -0x1c8(%rbp)
jmp 0x56199
movq -0x38(%rbp), %rdx
leaq -0x108(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x56990
jmp 0x561b2
leaq -0x108(%rbp), %rdi
callq 0x56910
movq %rax, -0x1d8(%rbp)
jmp 0x561c7
movq -0x1d8(%rbp), %rdx
movq -0x1c8(%rbp), %rsi
movq -0x1d0(%rbp), %rdi
callq 0x53e60
jmp 0x561e3
leaq -0x108(%rbp), %rdi
callq 0x56820
jmp 0x561f1
movq -0x158(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x1e0(%rbp)
movq -0x38(%rbp), %rdx
leaq -0x118(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x56990
jmp 0x5621c
leaq -0x118(%rbp), %rdi
callq 0x56910
movq %rax, -0x1e8(%rbp)
jmp 0x56231
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rdi
callq 0x20ab0
jmp 0x56246
leaq -0x118(%rbp), %rdi
callq 0x56820
jmp 0x56254
jmp 0x56256
leaq -0x128(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
xorl %edx, %edx
callq 0x56a20
jmp 0x5626d
leaq -0x128(%rbp), %rdi
callq 0x56820
jmp 0x5627b
jmp 0x5607f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x56820
jmp 0x5629a
jmp 0x562ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x56820
jmp 0x562b6
jmp 0x562ba
jmp 0x562cd
leaq -0xc8(%rbp), %rdi
callq 0x56820
jmp 0x562c8
jmp 0x5646d
movq -0x168(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x56ac0
jmp 0x562e2
jmp 0x562e4
movq -0x168(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x138(%rbp), %rdi
callq 0x56ae0
jmp 0x562fd
leaq -0x130(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x56590
movb %al, -0x1e9(%rbp)
jmp 0x56318
leaq -0x138(%rbp), %rdi
callq 0x564d0
jmp 0x56326
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x56373
jmp 0x56332
leaq -0x130(%rbp), %rdi
callq 0x564d0
jmp 0x5642b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5642d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x564d0
jmp 0x5636e
jmp 0x5642d
movq -0x158(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x200(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x566c0
movq %rax, -0x1f8(%rbp)
jmp 0x5639a
movq -0x160(%rbp), %rdi
callq 0x54050
movq -0x200(%rbp), %rdi
movq -0x1f8(%rbp), %rsi
movq %rax, %rdx
callq 0x53e60
jmp 0x563be
jmp 0x563c0
leaq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rsi
xorl %edx, %edx
callq 0x56660
jmp 0x563d7
movq -0x160(%rbp), %rsi
leaq -0x148(%rbp), %rdi
xorl %edx, %edx
callq 0x54070
jmp 0x563ee
leaq -0x148(%rbp), %rdi
callq 0x54040
jmp 0x563fc
leaq -0x140(%rbp), %rdi
callq 0x564d0
jmp 0x5640a
jmp 0x562e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x564d0
jmp 0x56429
jmp 0x5642d
jmp 0x5643d
leaq -0x130(%rbp), %rdi
callq 0x564d0
jmp 0x5643b
jmp 0x5646d
movq -0x158(%rbp), %rax
movq -0x38(%rbp), %rcx
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
leaq -0x78(%rbp), %rdi
callq 0x564d0
jmp 0x5645b
leaq -0x70(%rbp), %rdi
callq 0x564d0
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
leaq -0x78(%rbp), %rdi
callq 0x564d0
jmp 0x56478
jmp 0x5647a
leaq -0x70(%rbp), %rdi
callq 0x564d0
jmp 0x56485
jmp 0x56487
movq -0x50(%rbp), %rdi
callq 0x6310
movq %rax, %rdi
callq 0x7110
nopl (%rax,%rax)