// File: iZhangHui[P]CppPrimer/CH12_DynamicMemory/examples/usealloc2.cc
// Function: main
int main()
{
	vector<int> vi{1,2,3,4,5,6,7,8,9};

	allocator<int> alloc;
	// allocate twice as many elements as vi holds
	auto p = alloc.allocate(vi.size() * 2);

	// construct elements starting at p as copies of elements in vi
	auto q = uninitialized_copy(vi.begin(), vi.end(), p); 

	// initialize the remaining elements to 42
	uninitialized_fill_n(q, vi.size(), 42);

	for (size_t i = 0; i != vi.size(); ++i)
		cout << *(p + i) << " ";
	cout << endl;

	for (size_t i = 0; i != vi.size(); ++i)
		cout << *(q + i) << " ";
	cout << endl;

	alloc.deallocate(p, vi.size());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl $0x0, -0x4(%rbp)
movups 0x1dab(%rip), %xmm0     # 0x3014
movaps %xmm0, -0x50(%rbp)
movups 0x1d90(%rip), %xmm0     # 0x3004
movaps %xmm0, -0x60(%rbp)
movl $0x9, -0x40(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x9, -0x28(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x1560
movq -0xb8(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x1580
jmp 0x12b9
leaq -0x61(%rbp), %rdi
callq 0x1600
leaq -0x75(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x1560
leaq -0x20(%rbp), %rdi
callq 0x1680
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
addq %rsi, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x1620
movq %rax, -0xc0(%rbp)
jmp 0x12fa
movq -0xc0(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x20(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x16e0
movq -0xd8(%rbp), %rdi
movq %rax, -0x90(%rbp)
callq 0x1710
movq %rax, -0x98(%rbp)
movq -0x80(%rbp), %rdx
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x16a0
movq %rax, -0xd0(%rbp)
jmp 0x134f
movq -0xd0(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1680
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
movl $0x2a, -0x9c(%rbp)
leaq -0x9c(%rbp), %rdx
callq 0x1740
jmp 0x1396
movq $0x0, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1680
movq %rax, %rcx
movq -0xe8(%rbp), %rax
cmpq %rcx, %rax
je 0x1456
movq -0x80(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movq 0x3bf8(%rip), %rdi      # 0x4fd8
callq 0x10f0
movq %rax, -0xf0(%rbp)
jmp 0x13ee
movq -0xf0(%rbp), %rdi
leaq 0x1c2c(%rip), %rsi      # 0x3028
callq 0x1090
jmp 0x1403
jmp 0x1405
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0x13a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x1600
jmp 0x1549
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x75(%rbp), %rdi
callq 0x1600
leaq -0x20(%rbp), %rdi
callq 0x17a0
jmp 0x1549
movq 0x3b7b(%rip), %rdi      # 0x4fd8
movq 0x3b64(%rip), %rsi      # 0x4fc8
callq 0x10c0
jmp 0x146b
movq $0x0, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1680
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
je 0x14ed
movq -0x88(%rbp), %rax
movq -0xb0(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movq 0x3b24(%rip), %rdi      # 0x4fd8
callq 0x10f0
movq %rax, -0x100(%rbp)
jmp 0x14c2
movq -0x100(%rbp), %rdi
leaq 0x1b58(%rip), %rsi      # 0x3028
callq 0x1090
jmp 0x14d7
jmp 0x14d9
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x1476
movq 0x3ae4(%rip), %rdi      # 0x4fd8
movq 0x3acd(%rip), %rsi      # 0x4fc8
callq 0x10c0
jmp 0x1502
movq -0x80(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1680
movq -0x108(%rbp), %rsi
movq %rax, %rdx
leaq -0x75(%rbp), %rdi
callq 0x1770
jmp 0x152b
leaq -0x75(%rbp), %rdi
callq 0x1600
leaq -0x20(%rbp), %rdi
callq 0x17a0
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x1100
nopw %cs:(%rax,%rax)
nopl (%rax)