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

	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 (size_t i = 0; i != b1.size(); ++i) {
		std::cout << b1[i] << " ";
	}
	std::cout << std::endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movabsq $0x200000001, %rax      # imm = 0x200000001
leaq -0xc0(%rbp), %rbx
movq %rax, (%rbx)
movl $0x3, 0x8(%rbx)
leaq -0xf0(%rbp), %r14
movl $0x3, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2926
movl $0x4, (%rbx)
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x23e5
movl $0x4, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x23f1
leaq -0xc0(%rbp), %rdx
callq 0x315a
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x2450
xorl %ebx, %ebx
movq 0x3bbe(%rip), %r15      # 0x5fc8
leaq 0x1bf3(%rip), %r12      # 0x4004
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2a1c
movl (%rax), %esi
movq %r15, %rdi
callq 0x21b0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2140
incq %rbx
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %rbx
jne 0x2411
movq 0x3b71(%rip), %rdi      # 0x5fc8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x3b56(%rip), %rbx      # 0x5fc8
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0xf0(%rbp), %rdi
callq 0x2ab2
movl $0x5, (%rax)
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x24fb
xorl %r14d, %r14d
leaq -0xf0(%rbp), %r15
movq 0x3b13(%rip), %r12      # 0x5fc8
leaq 0x1b48(%rip), %r13      # 0x4004
movq %r15, %rdi
movq %r14, %rsi
callq 0x2a1c
movl (%rax), %esi
movq %r12, %rdi
callq 0x21b0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2140
incq %r14
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %r14
jne 0x24bc
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x3aaf(%rip), %rdi      # 0x5fc8
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0x60(%rbp), %rdi
callq 0x2b3c
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x3a83(%rip), %rdi      # 0x5fc8
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 -0xb0(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1a7f(%rip), %rsi      # 0x4006
leaq 0x1a79(%rip), %rdx      # 0x4007
leaq -0xc0(%rbp), %r15
movq %r15, %rdi
callq 0x32e0
leaq -0xa0(%rbp), %r14
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1a52(%rip), %rsi      # 0x4008
leaq 0x1a4d(%rip), %rdx      # 0x400a
movq %r14, %rdi
callq 0x32e0
leaq -0x80(%rbp), %r14
leaq -0x70(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1a33(%rip), %rsi      # 0x400b
leaq 0x1a2f(%rip), %rdx      # 0x400e
movq %r14, %rdi
callq 0x32e0
leaq -0x120(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
movl $0x3, %edx
callq 0x2bfc
movq $-0x60, %r14
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0x261a
movq (%rbx), %rsi
incq %rsi
callq 0x2130
addq $-0x20, %rbx
addq $0x20, %r14
jne 0x2606
movq -0x118(%rbp), %rax
incq (%rax)
cmpq $0x0, -0x60(%rbp)
je 0x2673
movq -0x58(%rbp), %rdi
decq (%rdi)
jne 0x266c
movl $0x8, %esi
callq 0x2130
movq -0x60(%rbp), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x2857
leaq -0x50(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq *0x18(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
leaq -0x110(%rbp), %rsi
movups -0x10(%rsi), %xmm0
leaq -0x50(%rbp), %rdi
movaps %xmm0, -0x10(%rdi)
callq 0x2d88
leaq -0xc0(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x1973(%rip), %rsi      # 0x400f
leaq 0x1971(%rip), %rdx      # 0x4014
callq 0x32e0
movq -0x120(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x36c0
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x26d6
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2130
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x38dc(%rip), %rdi      # 0x5fc8
callq 0x20a0
movq %rax, %rbx
leaq 0x1909(%rip), %rsi      # 0x4004
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq -0x120(%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
leaq -0x120(%rbp), %rdi
callq 0x2e70
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x385a(%rip), %rbx      # 0x5fc8
movq %rbx, %rdi
callq 0x20a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x2803
xorl %r14d, %r14d
leaq -0x60(%rbp), %r15
movq 0x380d(%rip), %r12      # 0x5fc8
leaq 0x1842(%rip), %r13      # 0x4004
movq %r15, %rdi
movq %r14, %rsi
callq 0x2cf2
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r12, %rdi
callq 0x2140
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2140
incq %r14
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x5, %rcx
cmpq %rcx, %r14
jne 0x27c2
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x37a7(%rip), %rdi      # 0x5fc8
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0x60(%rbp), %rdi
callq 0x2e70
leaq -0xf0(%rbp), %rdi
callq 0x2ee2
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2060
jmp 0x290f
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x28ef
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2130
jmp 0x28ef
jmp 0x28ec
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x21f0
movb $0x1, %al
jmp 0x28ab
jmp 0x289c
movq %rax, %rbx
xorl %eax, %eax
jmp 0x28ab
movq %rax, %rbx
xorl %eax, %eax
movq %r15, %r14
cmpq %r14, %r15
sete %cl
orb %al, %cl
jne 0x2902
addq $-0x10, %r14
leaq -0xc0(%rbp), %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x28d4
movq (%r14), %rsi
incq %rsi
callq 0x2130
leaq -0x20(%r14), %rax
addq $-0x10, %r14
cmpq %r15, %r14
movq %rax, %r14
jne 0x28c0
jmp 0x2902
jmp 0x290f
jmp 0x290f
jmp 0x290f
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x2e70
jmp 0x2902
jmp 0x28ff
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2e70
jmp 0x2912
jmp 0x290f
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x2ee2
movq %rbx, %rdi
callq 0x21c0