// File: /workspace/github_cpp_makefile_star2_O3/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 0x304e
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 0x2450
leaq -0xe0(%rbp), %rdx
callq 0x3244
movq -0x50(%rbp), %rdi
movq 0x8(%rdi), %rsi
cmpq (%rdi), %rsi
je 0x24a1
xorl %ebx, %ebx
movq 0x4b62(%rip), %r15      # 0x6fc0
leaq 0x1b9f(%rip), %r12      # 0x4004
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2c7a
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 0x2d10
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 0x2c7a
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
movl $0x28, %edi
callq 0x2120
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x47c6(%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 0x4a0e(%rip), %rdi      # 0x6fc0
xorl %esi, %esi
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 0x1a11(%rip), %rsi      # 0x4006
leaq 0x1a0b(%rip), %rdx      # 0x4007
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
callq 0x33ca
leaq -0xc0(%rbp), %r15
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x19e4(%rip), %rsi      # 0x4008
leaq 0x19df(%rip), %rdx      # 0x400a
movq %r15, %rdi
callq 0x33ca
leaq -0xa0(%rbp), %r15
leaq -0x90(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x19be(%rip), %rsi      # 0x400b
leaq 0x19ba(%rip), %rdx      # 0x400e
movq %r15, %rdi
callq 0x33ca
leaq -0x80(%rbp), %rcx
movq %r14, (%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 0x3592
leaq -0x30(%rbp), %r14
movq $-0x60, %r15
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x26a8
movq (%r12), %rsi
incq %rsi
callq 0x2130
addq $-0x20, %r12
addq $0x20, %r15
jne 0x2692
movq -0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2eec
leaq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
movq %rax, (%rdi)
leaq 0x1932(%rip), %rsi      # 0x400f
leaq 0x1930(%rip), %rdx      # 0x4014
callq 0x33ca
movq -0x68(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3774
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x271b
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2130
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x488f(%rip), %rdi      # 0x6fc0
callq 0x20a0
movq %rax, %rbx
leaq 0x18c4(%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 0x279c
callq 0x2f44
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x480e(%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 0x2811
movq 0x47b5(%rip), %rcx      # 0x6fb8
cmpb $0x0, (%rcx)
je 0x280d
incl 0xc(%rax)
jmp 0x2811
lock
incl 0xc(%rax)
leaq -0xe0(%rbp), %rbx
movq $0x0, 0x10(%rbx)
leaq -0x80(%rbp), %r14
movq 0x4795(%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 0x285c
movq 0x476a(%rip), %rsi      # 0x6fb8
cmpb $0x0, (%rsi)
je 0x2858
incl 0xc(%rdx)
jmp 0x285c
lock
incl 0xc(%rdx)
subq %rcx, %rax
sarq $0x5, %rax
movq %rax, -0x70(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x39be
movl %eax, %r12d
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x28aa
movq 0x4733(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
je 0x2895
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
jmp 0x289f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x28aa
movq (%rdi), %rax
callq *0x18(%rax)
testb %r12b, %r12b
jne 0x28fd
movq %rbx, %rdi
callq 0x2d9a
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 0x2e4a
jmp 0x282b
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x2935
movq 0x46a8(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
je 0x2920
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
jmp 0x292a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2935
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rax, -0x80(%rbp)
movq %rcx, -0x78(%rbp)
testq %rcx, %rcx
je 0x2963
movq 0x4667(%rip), %rdx      # 0x6fb8
cmpb $0x0, (%rdx)
je 0x295b
incl 0xc(%rcx)
jmp 0x2963
lock
incl 0xc(%rcx)
movq -0x38(%rbp), %rax
movq $0x0, -0x70(%rbp)
movq (%rax), %rdx
movq 0x8(%rax), %rcx
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
testq %rax, %rax
je 0x2998
movq 0x462e(%rip), %rsi      # 0x6fb8
cmpb $0x0, (%rsi)
je 0x2994
incl 0xc(%rax)
jmp 0x2998
lock
incl 0xc(%rax)
subq %rdx, %rcx
sarq $0x5, %rcx
leaq -0x68(%rbp), %rbx
movq %rcx, 0x10(%rbx)
leaq -0x80(%rbp), %r14
leaq -0xe0(%rbp), %r15
movq 0x4607(%rip), %r12      # 0x6fc0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x39be
testb %al, %al
jne 0x2a63
movq %r14, %rdi
callq 0x2d9a
leaq -0xd0(%rbp), %rcx
movq %rcx, -0xe0(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2fb0
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 0x2a56
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2130
movq %r14, %rdi
callq 0x2e4a
jmp 0x29b9
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2a98
movq 0x4545(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
je 0x2a83
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
jmp 0x2a8d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2a98
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x2acd
movq 0x4510(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
je 0x2ab8
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
jmp 0x2ac2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2acd
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x2adb
callq 0x2f44
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2ae9
callq 0x2f44
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2ba3
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x2b80
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2130
jmp 0x2b80
jmp 0x2b7d
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x2200
jmp 0x2c55
jmp 0x2b45
movq %rax, %rbx
addq $-0x10, %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x2b60
movq (%r15), %rsi
incq %rsi
callq 0x2130
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x2b4c
jmp 0x2c55
jmp 0x2b97
jmp 0x2ba3
jmp 0x2ba3
jmp 0x2ba3
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2c55
callq 0x2f44
jmp 0x2c55
movq %rax, %rbx
jmp 0x2c55
jmp 0x2bab
jmp 0x2ba3
movq %rax, %rbx
jmp 0x2c63
movq %rax, %rbx
jmp 0x2bd5
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x2bd5
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2130
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x2c0a
movq 0x43d3(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
jne 0x2bf6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
jmp 0x2bff
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2c0a
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x2c55
movq 0x439e(%rip), %rax      # 0x6fb8
cmpb $0x0, (%rax)
jne 0x2c2b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
lock
xaddl %eax, 0xc(%rdi)
jmp 0x2c34
movl 0xc(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rdi)
cmpl $0x1, %eax
jne 0x2c55
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x2c55
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x2c55
callq 0x223a
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x2c63
callq 0x2f44
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x2c71
callq 0x2f44
movq %rbx, %rdi
callq 0x21d0
nop