// File: cjc12[P]ezSTL/src/../include/vector.h
// Function: ezSTL::vector<int, ezSTL::allocator<int>>::insert(int*, int const&)
typename vector<T, Alloc>::iterator
		vector<T, Alloc>::insert(const_iterator pos, const_reference x) {
		if (finish != end_of_storage) {
			for (auto ite = end(); ite != pos; --ite) {
				if (ite != end()) destroy(ite);
				*ite = *(ite - 1);
			}
			construct(pos, x);
			++finish;
			return pos;
		}
		else {
			size_type old_size = size();
			size_type new_size = old_size ? 2 * old_size : 1;
			// allocate new space
			iterator new_start = allocate(new_size);
			iterator temp = new_start;
			// copy values before pos
			for (auto ite = begin(); ite != pos; ++ite)
				construct(temp++, *ite);
			// insert new value x
			auto res = temp;
			construct(temp++, x);
			for (auto ite = pos; ite != end(); ++ite)
				construct(temp++, *ite);
			destroy(start, finish);
			deallocate();
			start = new_start;
			finish = temp;
			end_of_storage = start + new_size;
			return res;
		}
	}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq 0x68(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rcx), %rax
cmpq 0x10(%rcx), %rax
je 0xb639
movq 0x18(%rsp), %rdi
callq 0x11a20
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0xb605
movq 0x18(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
callq 0x11a20
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
je 0xb5e6
movq 0x18(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x11b00
movq 0x50(%rsp), %rax
movl -0x4(%rax), %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
movq 0x50(%rsp), %rax
addq $-0x4, %rax
movq %rax, 0x50(%rsp)
jmp 0xb5aa
movq 0x18(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x11a30
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x4, %rcx
movq %rcx, 0x8(%rax)
movq 0x60(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0xb7a5
movq 0x18(%rsp), %rdi
callq 0x11940
movl %eax, 0x4c(%rsp)
cmpl $0x0, 0x4c(%rsp)
je 0xb65a
movl 0x4c(%rsp), %eax
shll %eax
movl %eax, 0xc(%rsp)
jmp 0xb665
movl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xb665
movq 0x18(%rsp), %rdi
movl 0xc(%rsp), %eax
movl %eax, 0x48(%rsp)
movl 0x48(%rsp), %esi
callq 0x11a60
movq 0x18(%rsp), %rdi
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
callq 0xb7b0
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0xb6d5
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rsi, %rax
addq $0x4, %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rdx
callq 0x11a30
movq 0x30(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x30(%rsp)
jmp 0xb699
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rsi
movq %rsi, %rax
addq $0x4, %rax
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rdx
callq 0x11a30
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
callq 0x11a20
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
je 0xb758
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rsi, %rax
addq $0x4, %rax
movq %rax, 0x38(%rsp)
movq 0x20(%rsp), %rdx
callq 0x11a30
movq 0x20(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
jmp 0xb709
movq 0x18(%rsp), %rdi
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
callq 0x11850
movq 0x18(%rsp), %rdi
callq 0x118b0
movq 0x18(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, (%rax)
movq 0x38(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq (%rax), %rcx
movl 0x48(%rsp), %edx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, 0x10(%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
addq $0x78, %rsp
retq
nop