// File: /workspace/github_cpp_makefile_star2_O1/DimitriDaSilva[P]42_ft_containers/containers/vector.hpp
// Function: 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>>>, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void
		insert(iterator position, size_type n, const value_type& val)
		{
			value_type*	new_vec;
			size_type	new_size = _size + n;
			size_type	new_capacity;
			iterator 	it_old;
			iterator 	it_new;
			int 		i;

			// 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;
				i = n;
				while (it_old != end() || i > 0)
				{
					// Position found
					if (it_old == position)
					{
						while (i--)
							_allocator.construct(&*it_new++, val);
					}

					// 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;
			}
			else
			{
				// We offset the whole vector by n one item at a time
				// We need to start by the end to avoid overwritting values
				for (reverse_iterator it = rbegin() - n;
						it != reverse_iterator(position) - n;
						it++)
				{
					_allocator.construct(&*it, *(it + n));
					_allocator.destroy(&*(it + n));
				}

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, -0x48(%rbp)
movq %rdx, %r12
movq %rdi, %r14
movq 0x18(%rdi), %rbx
movq 0x20(%rdi), %rax
leaq (%rbx,%rdx), %rcx
cmpq %rax, %rcx
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
jbe 0x31505
movq %rcx, %r13
testq %rax, %rax
je 0x31409
movq %rax, %r13
addq %rax, %rax
cmpq %r13, %rcx
ja 0x313fe
movq %rcx, -0x50(%rbp)
leaq 0x10(%r14), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x28382
movq %rax, -0x40(%rbp)
cmpq $0x0, 0x18(%r14)
sete %al
testl %r12d, %r12d
setle %cl
testb %cl, %al
jne 0x314e4
movq 0x8(%r14), %rbx
movq -0x40(%rbp), %r15
movq -0x38(%rbp), %rax
cmpq (%rax), %rbx
jne 0x31483
movl %r12d, %eax
subl $0x1, %eax
jae 0x31453
movl %eax, %r12d
jmp 0x31483
movq -0x48(%rbp), %r14
movq %r15, %rdi
addq $0x20, %r15
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
callq 0x728c
decl %r12d
jne 0x31457
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq -0x30(%rbp), %r14
movq 0x18(%r14), %rax
shlq $0x5, %rax
addq 0x8(%r14), %rax
cmpq %rax, %rbx
je 0x314c4
leaq 0x20(%r15), %r14
leaq 0x20(%rbx), %rax
movq %rax, -0x58(%rbp)
leaq 0x10(%r15), %rax
movq %rax, (%r15)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x728c
movq %r14, %r15
movq -0x30(%rbp), %r14
movq -0x58(%rbp), %rbx
movq 0x18(%r14), %rax
shlq $0x5, %rax
addq 0x8(%r14), %rax
cmpq %rax, %rbx
setne %al
testl %r12d, %r12d
setg %cl
orb %al, %cl
jne 0x3143d
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movq -0x40(%rbp), %rax
movq %rax, 0x8(%r14)
movq -0x50(%rbp), %rax
movq %rax, 0x18(%r14)
movq %r13, 0x20(%r14)
jmp 0x315b2
shlq $0x5, %rbx
addq 0x8(%r14), %rbx
movq (%rsi), %r15
cmpq %r15, %rbx
je 0x31566
movq %r12, %r14
shlq $0x5, %r14
leaq (%rbx,%r14), %r13
addq $-0x20, %r13
leaq -0x10(%rbx,%r14), %rax
movq %rax, -0x10(%rax)
movq -0x20(%rbx), %rsi
movq -0x18(%rbx), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x728c
movq -0x20(%rbx), %rdi
leaq -0x10(%rbx), %rax
cmpq %rdi, %rax
je 0x31552
callq 0x5190
movq -0x38(%rbp), %rax
movq (%rax), %r15
leaq (%r15,%r14), %rax
addq $-0x20, %rbx
cmpq %rax, %r13
jne 0x3151c
movq %r12, %rbx
shlq $0x5, %rbx
movq -0x38(%rbp), %r13
movq (%r13), %rax
addq %rbx, %rax
cmpq %rax, %r15
movq -0x48(%rbp), %r14
je 0x315aa
leaq 0x10(%r15), %rax
movq %rax, (%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x728c
addq $0x20, %r15
movq (%r13), %rax
addq %rbx, %rax
cmpq %rax, %r15
jne 0x31581
movq -0x30(%rbp), %rax
addq %r12, 0x18(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop