// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH16_TemplatesAndGenericProgramming/exercises/ex16_12_13_main.cc
// Function: main
int main(int argc, char const *argv[])
{
	Blob<int> blob{1, 2, 3};
	blob.push_back(4);

	// for (auto item : blob) {
	// 	std::cout << item << " "
	// }
	// std::cout << std::endl;
	for (size_t i = 0; i != blob.size(); ++i) {
		std::cout << blob[i] << " ";
	}
	std::cout << std::endl;

	// int ret = blob.back();
	int& ret = blob.back();
	ret = 5;

	for (size_t i = 0; i != blob.size(); ++i) {
		std::cout << blob[i] << " ";
	}
	std::cout << std::endl;


	Blob<std::string> b1; // empty Blob
	std::cout << b1.size() << std::endl;
	{  // new scope
		Blob<std::string> b2 = {"a", "an", "the"};
		b1 = b2;  // b1 and b2 share the same elements
		b2.push_back("about");
		std::cout << b1.size() << " " << b2.size() << std::endl;
	} // b2 is destroyed, but the elements it points to must not be destroyed
	std::cout << b1.size() << std::endl;
	for(auto p = b1.begin(); p != b1.end(); ++p)
		std::cout << *p << std::endl;

	for(auto item : b1)
		std::cout << item << std::endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movabsq $0x200000001, %rax      # imm = 0x200000001
leaq -0xe0(%rbp), %rbx
movq %rax, (%rbx)
movl $0x3, 0x8(%rbx)
leaq -0x68(%rbp), %r14
pushq $0x3
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27aa
movl $0x4, (%rbx)
movq (%r14), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x2eb4
xorl %ebx, %ebx
movq 0x4c35(%rip), %r15      # 0x6fc0
leaq 0x1c72(%rip), %r12      # 0x4004
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %rbx
je 0x23cb
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27cc
movl (%rax), %esi
movq %r15, %rdi
callq 0x21d0
movq %rax, %rdi
movq %r12, %rsi
callq 0x2110
incq %rbx
jmp 0x2392
movq 0x4bee(%rip), %rdi      # 0x6fc0
callq 0x2090
leaq -0x68(%rbp), %rdi
callq 0x283a
movl $0x5, (%rax)
xorl %ebx, %ebx
leaq -0x68(%rbp), %r14
movq 0x4bcd(%rip), %r15      # 0x6fc0
leaq 0x1c0a(%rip), %r12      # 0x4004
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %rbx
je 0x2433
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27cc
movl (%rax), %esi
movq %r15, %rdi
callq 0x21d0
movq %rax, %rdi
movq %r12, %rsi
callq 0x2110
incq %rbx
jmp 0x23fa
movq 0x4b86(%rip), %rdi      # 0x6fc0
callq 0x2090
leaq -0x40(%rbp), %rdi
callq 0x304b
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x4b62(%rip), %rdi      # 0x6fc0
callq 0x20c0
movq %rax, %rdi
callq 0x2090
leaq 0x1b94(%rip), %rsi      # 0x4006
leaq -0xe0(%rbp), %r14
leaq -0x80(%rbp), %rdx
movq %r14, %rdi
callq 0x2060
leaq -0xc0(%rbp), %r15
leaq 0x1b75(%rip), %rsi      # 0x4008
leaq -0x2a(%rbp), %rdx
movq %r15, %rdi
callq 0x2060
leaq -0xa0(%rbp), %r15
leaq 0x1b5e(%rip), %rsi      # 0x400b
leaq -0x29(%rbp), %rdx
movq %r15, %rdi
callq 0x2060
leaq -0x58(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
pushq $0x3
popq %rdx
callq 0x289e
pushq $0x40
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0xe0, %rdi
callq 0x2080
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x24cf
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2a0a
leaq 0x1b12(%rip), %rsi      # 0x400f
leaq -0xe0(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x2060
movq -0x58(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x34da
leaq -0xe0(%rbp), %rdi
callq 0x2080
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x4a81(%rip), %rdi      # 0x6fc0
callq 0x20c0
leaq 0x1ab9(%rip), %rsi      # 0x4004
movq %rax, %rdi
callq 0x2110
movq -0x58(%rbp), %rcx
movq 0x8(%rcx), %rsi
subq (%rcx), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x20c0
movq %rax, %rdi
callq 0x2090
leaq -0x50(%rbp), %rdi
callq 0x2b04
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x4a2f(%rip), %rdi      # 0x6fc0
callq 0x20c0
movq %rax, %rdi
callq 0x2090
leaq -0xe0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x28c0
leaq -0x58(%rbp), %rbx
leaq -0x40(%rbp), %r15
leaq -0xe0(%rbp), %r12
movq 0x49fc(%rip), %r13      # 0x6fc0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x28ea
movq %r12, %rdi
movq %rbx, %rsi
callq 0x28dd
movl %eax, %r14d
leaq -0x50(%rbp), %rdi
callq 0x2b18
testb %r14b, %r14b
je 0x2610
movq %r12, %rdi
callq 0x2914
movq %r13, %rdi
movq %rax, %rsi
callq 0x2100
movq %rax, %rdi
callq 0x2090
movq %r12, %rdi
callq 0x2994
jmp 0x25c4
leaq -0xd8(%rbp), %rdi
callq 0x2b18
leaq -0x58(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x28c0
leaq -0x80(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x28ea
leaq -0x58(%rbp), %rbx
leaq -0x80(%rbp), %r14
leaq -0xe0(%rbp), %r15
movq 0x4974(%rip), %r12      # 0x6fc0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x28dd
testb %al, %al
je 0x2693
movq %rbx, %rdi
callq 0x2914
movq %r15, %rdi
movq %rax, %rsi
callq 0x2150
movq %r12, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %rdi
callq 0x2090
movq %r15, %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2994
jmp 0x264c
leaq -0x78(%rbp), %rdi
callq 0x2b18
leaq -0x50(%rbp), %rdi
callq 0x2b18
leaq -0x38(%rbp), %rdi
callq 0x2b04
leaq -0x60(%rbp), %rdi
callq 0x2b04
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2774
jmp 0x2740
jmp 0x2740
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x2080
jmp 0x2735
jmp 0x2732
movq %rax, %rbx
pushq $0x40
popq %r14
leaq (%r14,%rbp), %rdi
addq $-0xe0, %rdi
callq 0x2080
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x26f1
jmp 0x2790
jmp 0x2712
movq %rax, %rbx
addq $-0x20, %r15
movq %r15, %rdi
callq 0x2080
cmpq %r14, %r15
jne 0x2715
jmp 0x2790
jmp 0x2740
jmp 0x277c
jmp 0x277c
jmp 0x277c
jmp 0x277c
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x2b04
jmp 0x2790
movq %rax, %rbx
jmp 0x2790
jmp 0x2781
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x2b18
jmp 0x2784
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x2080
jmp 0x276b
jmp 0x2768
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x2b18
leaq -0x50(%rbp), %rdi
jmp 0x278b
jmp 0x277c
movq %rax, %rbx
jmp 0x2799
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x2b18
leaq -0x38(%rbp), %rdi
callq 0x2b04
leaq -0x60(%rbp), %rdi
callq 0x2b04
movq %rbx, %rdi
callq 0x21e0