// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movq %rdx, %r12
movq 0x18(%rdi), %r15
movq 0x20(%rdi), %rax
leaq (%r15,%rdx), %rcx
cmpq %rax, %rcx
movq %rdi, -0x30(%rbp)
movq %rsi, -0x40(%rbp)
jbe 0x3034f
movq %rcx, %r13
testq %rax, %rax
je 0x3023f
movq %rax, %r13
addq %rax, %rax
cmpq %r13, %rcx
ja 0x30234
movq %rcx, -0x50(%rbp)
movq -0x30(%rbp), %rax
leaq 0x10(%rax), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2724a
movq -0x30(%rbp), %rdi
movq %rax, -0x48(%rbp)
movq 0x18(%rdi), %rax
testq %rax, %rax
sete %cl
testl %r12d, %r12d
setle %dl
testb %dl, %cl
jne 0x3032e
movq 0x8(%rdi), %rcx
movq %rcx, %r15
movq -0x48(%rbp), %rbx
movq -0x40(%rbp), %rdx
cmpq (%rdx), %r15
jne 0x302c2
testl %r12d, %r12d
je 0x302bc
movq %rbx, %rdi
addq $0x20, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
callq 0x71e4
decl %r12d
jne 0x3028e
movq -0x30(%rbp), %rdi
movq 0x8(%rdi), %rcx
movq 0x18(%rdi), %rax
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq %rax, %rdx
shlq $0x5, %rdx
addq %rcx, %rdx
cmpq %rdx, %r15
je 0x3030e
leaq 0x20(%rbx), %rax
movq %rax, -0x38(%rbp)
leaq 0x20(%r15), %rax
movq %rax, -0x58(%rbp)
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x71e4
movq -0x30(%rbp), %rdi
movq 0x8(%rdi), %rcx
movq 0x18(%rdi), %rax
movq -0x38(%rbp), %rbx
movq -0x58(%rbp), %r15
movq %rax, %rdx
shlq $0x5, %rdx
addq %rcx, %rdx
cmpq %rdx, %r15
setne %dl
testl %r12d, %r12d
setg %sil
orb %dl, %sil
jne 0x30280
movq (%rdi), %rax
movq %rdi, %rbx
callq *(%rax)
movq -0x48(%rbp), %rax
movq %rax, 0x8(%rbx)
movq -0x50(%rbp), %rax
movq %rax, 0x18(%rbx)
movq %r13, 0x20(%rbx)
jmp 0x303f9
shlq $0x5, %r15
addq 0x8(%rdi), %r15
movq (%rsi), %rbx
cmpq %rbx, %r15
je 0x303b8
movq %r12, %rcx
shlq $0x5, %rcx
movq %rcx, -0x38(%rbp)
leaq (%r15,%rcx), %r13
addq $-0x20, %r13
leaq -0x10(%r15,%rcx), %rax
movq %rax, -0x10(%rax)
movq -0x20(%r15), %rsi
movq -0x18(%r15), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x71e4
movq -0x20(%r15), %rdi
leaq -0x10(%r15), %rax
cmpq %rdi, %rax
je 0x303a0
callq 0x5190
movq -0x40(%rbp), %rax
movq (%rax), %rbx
movq -0x38(%rbp), %rcx
leaq (%rbx,%rcx), %rax
addq $-0x20, %r15
cmpq %rax, %r13
jne 0x3036a
testq %r12, %r12
movq -0x40(%rbp), %r13
je 0x303f1
movq %r12, %r15
shlq $0x5, %r15
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x71e4
addq $0x20, %rbx
movq (%r13), %rax
addq %r15, %rax
cmpq %rax, %rbx
jne 0x303c8
movq -0x30(%rbp), %rax
addq %r12, 0x18(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq