// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movaps 0xc98(%rip), %xmm0      # 0x2010
leaq -0x50(%rbp), %rsi
movups %xmm0, (%rsi)
leaq -0xa0(%rbp), %rdi
leaq -0x70(%rbp), %rbx
movl $0x4, %edx
movq %rbx, %rcx
callq 0x1736
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xc9a(%rip), %rsi       # 0x2040
leaq 0xc96(%rip), %rdx       # 0x2043
leaq -0x50(%rbp), %rdi
callq 0x1820
leaq -0x50(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x129c
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x13df
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10e0
movq %rbx, -0x68(%rbp)
movq %rbx, -0x70(%rbp)
xorl %eax, %eax
movq %rax, -0x60(%rbp)
leaq -0xd0(%rbp), %rcx
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
movq %rax, 0x10(%rcx)
leaq -0xa0(%rbp), %rsi
movq (%rsi), %rdi
movq %rbx, %rdx
callq 0x18ba
leaq -0xa0(%rbp), %r15
movq (%r15), %rdi
leaq -0xd0(%rbp), %rdx
movq (%rdx), %rcx
movq %r15, %rsi
callq 0x190a
leaq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rbx
movq %rbx, (%rdi)
leaq 0xbf3(%rip), %rsi       # 0x2032
leaq 0xbf0(%rip), %rdx       # 0x2036
callq 0x1820
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %r12
movq %r12, %rsi
callq 0x129c
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x1470
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10e0
leaq -0x50(%rbp), %rdi
movq %rbx, (%rdi)
leaq 0xbb9(%rip), %rsi       # 0x2037
leaq 0xbb6(%rip), %rdx       # 0x203b
callq 0x1820
leaq -0x50(%rbp), %rdi
leaq -0xd0(%rbp), %r13
movq %r13, %rsi
callq 0x129c
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x14b2
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10e0
movups 0xbe7(%rip), %xmm0      # 0x20a0
leaq -0x50(%rbp), %rsi
movaps %xmm0, (%rsi)
movl $0x5, 0x10(%rsi)
leaq -0x88(%rbp), %rdi
leaq -0xb8(%rbp), %rcx
movl $0x5, %edx
callq 0x178e
movaps 0xb3a(%rip), %xmm0      # 0x2020
leaq -0x50(%rbp), %rsi
movups %xmm0, (%rsi)
leaq -0xb8(%rbp), %rdi
leaq -0x51(%rbp), %rcx
movl $0x4, %edx
callq 0x1736
leaq -0xb8(%rbp), %rbx
movq (%rbx), %rcx
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq %rbx, %rdx
callq 0x1a1a
leaq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
movq %rax, (%rdi)
leaq 0xb0b(%rip), %rsi       # 0x203c
leaq 0xb0b(%rip), %rdx       # 0x2043
callq 0x1820
leaq -0x50(%rbp), %rdi
leaq -0xb8(%rbp), %r14
movq %r14, %rsi
callq 0x129c
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x1569
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10e0
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0x158a
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x10e0
movq %rbx, %rdi
cmpq %r14, %rbx
jne 0x1575
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x15a2
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq -0xd0(%rbp), %rdi
cmpq %r13, %rdi
je 0x15c3
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x10e0
movq %rbx, %rdi
cmpq %r13, %rbx
jne 0x15ae
movq -0x70(%rbp), %rdi
cmpq %r12, %rdi
je 0x15e1
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x10e0
movq %rbx, %rdi
cmpq %r12, %rbx
jne 0x15cc
movq -0xa0(%rbp), %rdi
cmpq %r15, %rdi
je 0x1602
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x10e0
movq %rbx, %rdi
cmpq %r15, %rbx
jne 0x15ed
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x1639
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10e0
jmp 0x1639
jmp 0x1636
movq %rax, %r15
movq -0xb8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x165f
movq (%rdi), %r14
movl $0x18, %esi
callq 0x10e0
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x1645
jmp 0x165f
movq %rax, %r15
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x16bc
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
jmp 0x168d
jmp 0x16b9
jmp 0x167a
jmp 0x16b9
movq %rax, %r15
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x16bc
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10e0
jmp 0x16bc
jmp 0x16b9
movq %rax, %r15
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x1706
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10e0
jmp 0x1706
movq %rax, %r15
jmp 0x1706
movq %rax, %r15
movq -0xd0(%rbp), %rdi
leaq -0xd0(%rbp), %r14
cmpq %r14, %rdi
je 0x16e4
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x10e0
movq %rbx, %rdi
cmpq %r14, %rbx
jne 0x16cf
movq -0x70(%rbp), %rdi
leaq -0x70(%rbp), %r14
cmpq %r14, %rdi
je 0x1706
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x10e0
movq %rbx, %rdi
cmpq %r14, %rbx
jne 0x16f1
movq -0xa0(%rbp), %rdi
leaq -0xa0(%rbp), %r14
cmpq %r14, %rdi
je 0x172e
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x10e0
movq %rbx, %rdi
cmpq %r14, %rbx
jne 0x1719
movq %r15, %rdi
callq 0x1130