// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %rbx
subq $0xa8, %rsp
movaps 0xd08(%rip), %xmm0      # 0x2010
leaq -0x30(%rbp), %rsi
movups %xmm0, (%rsi)
leaq -0x90(%rbp), %rdi
pushq $0x4
popq %rdx
leaq -0x48(%rbp), %rcx
callq 0x1538
leaq 0xd17(%rip), %rsi       # 0x2040
leaq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rbx
movq %rbx, %rdx
callq 0x1060
leaq -0x30(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x128c
leaq -0x30(%rbp), %rdi
callq 0x1080
movq %rbx, -0x40(%rbp)
movq %rbx, -0x48(%rbp)
andq $0x0, -0x38(%rbp)
leaq -0xa8(%rbp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
andq $0x0, 0x10(%rax)
leaq -0x90(%rbp), %rsi
movq (%rsi), %rdi
movq %rbx, %rdx
callq 0x170c
leaq -0x90(%rbp), %rsi
movq (%rsi), %rdi
leaq -0xa8(%rbp), %rdx
movq (%rdx), %rcx
callq 0x1754
leaq 0xc8e(%rip), %rsi       # 0x2032
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x1060
leaq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x128c
leaq -0x30(%rbp), %rdi
callq 0x1080
leaq 0xc69(%rip), %rsi       # 0x2037
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x1060
leaq -0x30(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x128c
leaq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x1080
movups 0xc7a(%rip), %xmm0      # 0x2078
movaps %xmm0, (%rbx)
movl $0x5, 0x10(%rbx)
leaq -0x60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
pushq $0x5
popq %rdx
leaq -0x78(%rbp), %rcx
callq 0x1570
movaps 0xbfd(%rip), %xmm0      # 0x2020
leaq -0x30(%rbp), %rsi
movups %xmm0, (%rsi)
leaq -0x78(%rbp), %rdi
pushq $0x4
popq %rdx
leaq -0x9(%rbp), %rcx
callq 0x1538
leaq -0x78(%rbp), %rdx
movq (%rdx), %rcx
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1904
leaq 0xbe7(%rip), %rsi       # 0x203c
leaq -0x30(%rbp), %rdi
leaq -0x9(%rbp), %rdx
callq 0x1060
leaq -0x30(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x128c
leaq -0x30(%rbp), %rdi
callq 0x1080
leaq -0x78(%rbp), %rdi
callq 0x15a6
leaq -0x60(%rbp), %rdi
callq 0x185e
leaq -0xa8(%rbp), %rdi
callq 0x15a6
leaq -0x48(%rbp), %rdi
callq 0x15a6
leaq -0x90(%rbp), %rdi
callq 0x15a6
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x1080
jmp 0x14ca
jmp 0x14c7
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x15a6
jmp 0x14d8
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x185e
jmp 0x150f
jmp 0x150c
jmp 0x14e9
jmp 0x150c
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x1080
jmp 0x150f
jmp 0x150c
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x1080
jmp 0x1524
movq %rax, %rbx
jmp 0x1524
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x15a6
leaq -0x48(%rbp), %rdi
callq 0x15a6
leaq -0x90(%rbp), %rdi
callq 0x15a6
movq %rbx, %rdi
callq 0x1140