// File: iZhangHui[P]CppPrimer/CH10_GenericAlgorithms/examples/inserters.cc
// Function: main
int main() 
{

    list<int> lst = {1,2,3,4};
	print("lst", lst);

    // after copy completes, lst2 contains 4 3 2 1
	list<int> lst2, lst3;     // empty lists
    copy(lst.cbegin(), lst.cend(), front_inserter(lst2));

    // after copy completes, lst3 contains 1 2 3 4
    copy(lst.cbegin(), lst.cend(), inserter(lst3, lst3.begin()));

	print("lst2", lst2);
	print("lst3", lst3);
	
	vector<int> v = {1,2,3,4,5};
	list<int> new_lst = {6,7,8,9};
	auto it = new_lst.begin();
	copy(v.begin(), v.end(), inserter(new_lst, it));
	print("new_lst", new_lst);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movl $0x0, -0x4(%rbp)
movl $0x1, -0x40(%rbp)
movl $0x2, -0x3c(%rbp)
movl $0x3, -0x38(%rbp)
movl $0x4, -0x34(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x4, -0x28(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x1b30
movq -0x258(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x1b50
jmp 0x13d8
leaq -0x41(%rbp), %rdi
callq 0x1c00
leaq -0x79(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x1160
movq -0x260(%rbp), %rdx
leaq 0x2c15(%rip), %rsi      # 0x4014
leaq -0x78(%rbp), %rdi
callq 0x1110
jmp 0x140a
leaq -0x78(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x12b0
jmp 0x1419
leaq -0x78(%rbp), %rdi
callq 0x1080
leaq -0x79(%rbp), %rdi
callq 0x1100
leaq -0x98(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x1c20
leaq -0xb0(%rbp), %rdi
callq 0x1c20
leaq -0x20(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x1cb0
movq -0x278(%rbp), %rdi
movq %rax, -0xb8(%rbp)
callq 0x1ce0
movq -0x270(%rbp), %rdi
movq %rax, -0xc0(%rbp)
callq 0x1d10
movq %rax, -0x268(%rbp)
jmp 0x1489
movq -0x268(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
callq 0x1c40
movq %rax, -0x280(%rbp)
jmp 0x14ba
movq -0x280(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x20(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x1cb0
movq -0x2a0(%rbp), %rdi
movq %rax, -0xd8(%rbp)
callq 0x1ce0
movq %rax, -0xe0(%rbp)
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x1e00
movq -0x298(%rbp), %rdi
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rsi
callq 0x1dc0
movq %rdx, -0x290(%rbp)
movq %rax, -0x288(%rbp)
jmp 0x152f
movq -0x290(%rbp), %rax
movq -0x288(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xf0(%rbp), %rdx
movq -0xe8(%rbp), %rcx
callq 0x1d40
movq %rdx, -0x2b0(%rbp)
movq %rax, -0x2a8(%rbp)
jmp 0x157c
movq -0x2b0(%rbp), %rax
movq -0x2a8(%rbp), %rcx
movq %rcx, -0x108(%rbp)
movq %rax, -0x100(%rbp)
leaq -0x129(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x1160
movq -0x2b8(%rbp), %rdx
leaq 0x2a4d(%rip), %rsi      # 0x4006
leaq -0x128(%rbp), %rdi
callq 0x1110
jmp 0x15c7
leaq -0x128(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x12b0
jmp 0x15dc
leaq -0x128(%rbp), %rdi
callq 0x1080
leaq -0x129(%rbp), %rdi
callq 0x1100
leaq -0x151(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x1160
movq -0x2c0(%rbp), %rdx
leaq 0x29f6(%rip), %rsi      # 0x400b
leaq -0x150(%rbp), %rdi
callq 0x1110
jmp 0x1623
leaq -0x150(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x12b0
jmp 0x1638
leaq -0x150(%rbp), %rdi
callq 0x1080
leaq -0x151(%rbp), %rdi
callq 0x1100
movups 0x29f5(%rip), %xmm0     # 0x404c
movaps %xmm0, -0x1a0(%rbp)
movl $0x5, -0x190(%rbp)
leaq -0x1a0(%rbp), %rax
movq %rax, -0x180(%rbp)
movq $0x5, -0x178(%rbp)
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x1b30
movq -0x2c8(%rbp), %rcx
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rdx
leaq -0x170(%rbp), %rdi
callq 0x1e30
jmp 0x16b7
leaq -0x1a1(%rbp), %rdi
callq 0x1c00
movl $0x6, -0x1e0(%rbp)
movl $0x7, -0x1dc(%rbp)
movl $0x8, -0x1d8(%rbp)
movl $0x9, -0x1d4(%rbp)
leaq -0x1e0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq $0x4, -0x1c8(%rbp)
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x1b30
movq -0x2d0(%rbp), %rcx
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rdx
leaq -0x1c0(%rbp), %rdi
callq 0x1b50
jmp 0x173a
leaq -0x1e1(%rbp), %rdi
callq 0x1c00
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x1e00
movq %rax, -0x1f0(%rbp)
leaq -0x170(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x1f30
movq -0x2f0(%rbp), %rdi
movq %rax, -0x1f8(%rbp)
callq 0x1f60
movq -0x2e8(%rbp), %rdi
movq %rax, -0x200(%rbp)
movq -0x1f0(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x218(%rbp), %rsi
callq 0x1dc0
movq %rdx, -0x2e0(%rbp)
movq %rax, -0x2d8(%rbp)
jmp 0x17be
movq -0x2e0(%rbp), %rax
movq -0x2d8(%rbp), %rcx
movq %rcx, -0x210(%rbp)
movq %rax, -0x208(%rbp)
movq -0x1f8(%rbp), %rdi
movq -0x200(%rbp), %rsi
movq -0x210(%rbp), %rdx
movq -0x208(%rbp), %rcx
callq 0x1eb0
movq %rdx, -0x300(%rbp)
movq %rax, -0x2f8(%rbp)
jmp 0x180b
movq -0x300(%rbp), %rax
movq -0x2f8(%rbp), %rcx
movq %rcx, -0x228(%rbp)
movq %rax, -0x220(%rbp)
leaq -0x249(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x1160
movq -0x308(%rbp), %rdx
leaq 0x27c8(%rip), %rsi      # 0x4010
leaq -0x248(%rbp), %rdi
callq 0x1110
jmp 0x1856
leaq -0x248(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x12b0
jmp 0x186b
leaq -0x248(%rbp), %rdi
callq 0x1080
leaq -0x249(%rbp), %rdi
callq 0x1100
movl $0x0, -0x4(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x1f90
leaq -0x170(%rbp), %rdi
callq 0x1fb0
leaq -0xb0(%rbp), %rdi
callq 0x1f90
leaq -0x98(%rbp), %rdi
callq 0x1f90
leaq -0x20(%rbp), %rdi
callq 0x1f90
movl -0x4(%rbp), %eax
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x1c00
jmp 0x1a46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x190c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x1080
leaq -0x79(%rbp), %rdi
callq 0x1100
jmp 0x1a3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1a25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1951
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x1080
leaq -0x129(%rbp), %rdi
callq 0x1100
jmp 0x1a25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1988
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x1080
leaq -0x151(%rbp), %rdi
callq 0x1100
jmp 0x1a25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1a1(%rbp), %rdi
callq 0x1c00
jmp 0x1a25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1e1(%rbp), %rdi
callq 0x1c00
jmp 0x1a19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1a0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1a01
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x1080
leaq -0x249(%rbp), %rdi
callq 0x1100
leaq -0x1c0(%rbp), %rdi
callq 0x1f90
leaq -0x170(%rbp), %rdi
callq 0x1fb0
leaq -0xb0(%rbp), %rdi
callq 0x1f90
leaq -0x98(%rbp), %rdi
callq 0x1f90
leaq -0x20(%rbp), %rdi
callq 0x1f90
movq -0x50(%rbp), %rdi
callq 0x1150
nop