// File: /workspace/github_cpp_makefile_star2_O1/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 -0x80(%rbp), %rcx
movq %rax, (%rcx)
movl $0x3, 0x8(%rcx)
leaq -0xe0(%rbp), %rbx
movq %rcx, (%rbx)
movq $0x3, 0x8(%rbx)
leaq -0x48(%rbp), %rdi
movq $0x0, -0x8(%rdi)
leaq -0x50(%rbp), %r14
leaq -0x68(%rbp), %rdx
movq %r14, %rsi
movq %rbx, %rcx
callq 0x307c
movl $0x4, (%rbx)
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x243c
movl $0x4, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x2448
leaq -0xe0(%rbp), %rdx
callq 0x3298
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x24a1
xorl %ebx, %ebx
movq 0x4b62(%rip), %r15      # 0x6fc0
leaq 0x1b9f(%rip), %r12      # 0x4004
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2cb0
movl (%rax), %esi
movq %r15, %rdi
callq 0x21c0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2140
incq %rbx
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %rbx
jne 0x2465
movq 0x4b18(%rip), %rdi      # 0x6fc0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x4afd(%rip), %rbx      # 0x6fc0
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0x50(%rbp), %rdi
callq 0x2d46
movl $0x5, (%rax)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x2540
xorl %r14d, %r14d
leaq -0x50(%rbp), %r15
movq 0x4ac3(%rip), %r12      # 0x6fc0
leaq 0x1b00(%rip), %r13      # 0x4004
movq %r15, %rdi
movq %r14, %rsi
callq 0x2cb0
movl (%rax), %esi
movq %r12, %rdi
callq 0x21c0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2140
incq %r14
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %r14
jne 0x2504
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x4a62(%rip), %rdi      # 0x6fc0
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq $0x0, -0x38(%rbp)
movl $0x28, %edi
callq 0x2120
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x47be(%rip), %rcx      # 0x6d50
movq %rcx, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq $0x0, 0x20(%rax)
movq %rax, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq 0x18(%rax), %rsi
sarq $0x5, %rsi
movq 0x49fe(%rip), %rdi      # 0x6fc0
callq 0x20a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0xd0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1a03(%rip), %rsi      # 0x4006
leaq 0x19fd(%rip), %rdx      # 0x4007
leaq -0xe0(%rbp), %r15
movq %r15, %rdi
callq 0x341e
leaq -0xc0(%rbp), %r14
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x19d6(%rip), %rsi      # 0x4008
leaq 0x19d1(%rip), %rdx      # 0x400a
movq %r14, %rdi
callq 0x341e
leaq -0xa0(%rbp), %r14
leaq -0x90(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x19b0(%rip), %rsi      # 0x400b
leaq 0x19ac(%rip), %rdx      # 0x400e
movq %r14, %rdi
callq 0x341e
leaq -0xe0(%rbp), %rax
leaq -0x80(%rbp), %rcx
movq %rax, (%rcx)
movq $0x3, 0x8(%rcx)
leaq -0x60(%rbp), %rbx
movq $0x0, -0x8(%rbx)
leaq -0x68(%rbp), %rsi
leaq -0x39(%rbp), %rdx
movq %rbx, %rdi
callq 0x35e6
leaq -0x30(%rbp), %r14
movq $-0x60, %r15
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x26bd
movq (%r12), %rsi
incq %rsi
callq 0x2130
addq $-0x20, %r12
addq $0x20, %r15
jne 0x26a7
movq -0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2f22
leaq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
movq %rax, (%rdi)
leaq 0x191d(%rip), %rsi      # 0x400f
leaq 0x191b(%rip), %rdx      # 0x4014
callq 0x341e
movq -0x68(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x37c8
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x2730
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2130
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x487a(%rip), %rdi      # 0x6fc0
callq 0x20a0
movq %rax, %rbx
leaq 0x18af(%rip), %rsi      # 0x4004
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq %rbx, %rdi
callq 0x20a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x27b1
callq 0x2f76
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x47f9(%rip), %rdi      # 0x6fc0
callq 0x20a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0xe0(%rbp)
movq %rax, -0xd8(%rbp)
testq %rax, %rax
je 0x2826
movq 0x47a0(%rip), %rcx      # 0x6fb8
cmpb $0x0, (%rcx)
je 0x2822
incl 0xc(%rax)
jmp 0x2826
lock
incl 0xc(%rax)
leaq -0xe0(%rbp), %rbx
movq $0x0, 0x10(%rbx)
leaq -0x80(%rbp), %r14
movq 0x4780(%rip), %r15      # 0x6fc0
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq (%rsi), %rcx
movq 0x8(%rsi), %rax
movq %rsi, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
testq %rdx, %rdx
je 0x2871
movq 0x4755(%rip), %rsi      # 0x6fb8
cmpb $0x0, (%rsi)
je 0x286d
incl 0xc(%rdx)
jmp 0x2871
lock
incl 0xc(%rdx)
subq %rcx, %rax
sarq $0x5, %rax
movq %rax, -0x70(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3a12
movl %eax, %r12d
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x28bf
movq 0x471e(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
je 0x28aa
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
jmp 0x28b4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x28bf
movq (%rdi), %rax
callq *0x18(%rax)
testb %r12b, %r12b
jne 0x2912
movq %rbx, %rdi
callq 0x2dd0
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x2140
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2e80
jmp 0x2840
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x294a
movq 0x4693(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
je 0x2935
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
jmp 0x293f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x294a
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x80(%rbp)
movq %rax, -0x78(%rbp)
testq %rax, %rax
je 0x2974
movq 0x4652(%rip), %rcx      # 0x6fb8
cmpb $0x0, (%rcx)
je 0x2970
incl 0xc(%rax)
jmp 0x2974
lock
incl 0xc(%rax)
movq $0x0, -0x70(%rbp)
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq (%rsi), %rcx
movq 0x8(%rsi), %rax
movq %rsi, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
testq %rdx, %rdx
je 0x29ad
movq 0x4619(%rip), %rsi      # 0x6fb8
cmpb $0x0, (%rsi)
je 0x29a9
incl 0xc(%rdx)
jmp 0x29ad
lock
incl 0xc(%rdx)
subq %rcx, %rax
sarq $0x5, %rax
leaq -0x68(%rbp), %rbx
movq %rax, 0x10(%rbx)
leaq -0x80(%rbp), %r14
leaq -0xe0(%rbp), %r15
movq 0x45f2(%rip), %r12      # 0x6fc0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3a12
testb %al, %al
jne 0x2a78
movq %r14, %rdi
callq 0x2dd0
leaq -0xd0(%rbp), %rcx
movq %rcx, -0xe0(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2fe2
movq -0xe0(%rbp), %rsi
movq -0xd8(%rbp), %rdx
movq %r12, %rdi
callq 0x2140
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x2a6b
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2130
movq %r14, %rdi
callq 0x2e80
jmp 0x29ce
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2aad
movq 0x4530(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
je 0x2a98
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
jmp 0x2aa2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2aad
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x2ae2
movq 0x44fb(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
je 0x2acd
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
jmp 0x2ad7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2ae2
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x2af0
callq 0x2f76
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2afe
callq 0x2f76
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2bda
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x2bb7
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2130
jmp 0x2bb7
jmp 0x2bb4
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x2206
movb $0x1, %al
jmp 0x2b6c
jmp 0x2b5d
movq %rax, %rbx
xorl %eax, %eax
jmp 0x2b6c
movq %rax, %rbx
xorl %eax, %eax
movq %r15, %r14
cmpq %r14, %r15
sete %cl
orb %al, %cl
jne 0x2c8c
addq $-0x10, %r14
leaq -0xe0(%rbp), %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x2b99
movq (%r14), %rsi
incq %rsi
callq 0x2130
leaq -0x20(%r14), %rax
addq $-0x10, %r14
cmpq %r15, %r14
movq %rax, %r14
jne 0x2b85
jmp 0x2c8c
jmp 0x2bda
jmp 0x2bda
jmp 0x2bda
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2c8c
callq 0x2f76
jmp 0x2c8c
movq %rax, %rbx
jmp 0x2c8c
jmp 0x2be2
jmp 0x2bda
movq %rax, %rbx
jmp 0x2c9a
movq %rax, %rbx
jmp 0x2c0c
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x2c0c
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2130
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2c41
movq 0x439c(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
jne 0x2c2d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
jmp 0x2c36
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2c41
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x2c8c
movq 0x4367(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
jne 0x2c62
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
jmp 0x2c6b
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2c8c
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x2c8c
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x2c8c
callq 0x2240
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x2c9a
callq 0x2f76
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2ca8
callq 0x2f76
movq %rbx, %rdi
callq 0x21d0