// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH16_TemplatesAndGenericProgramming/examples/useChcking.cc
// Function: main
int main()
{
	vector<int> v1(3, 43), v2(10);
	Blob<int> a1(v1.begin(), v1.end()),
	          a2 = {0,1,2,3,4,5,6,7,8,9},
	          a3(v2.begin(), v2.end());

	cout << a1 << "\n\n" << a2 << "\n\n" << a3 << endl;

	cout << "\ncopy" << "\n\n";
	Blob<int> a5(a1);
	cout << a5 << endl;

	cout << "\nassignment" << "\n\n";

	a1 = a3;
	cout << a1 << "\n\n" << a2 << "\n\n" << a3 << endl;

	cout << "\nelement assignment" << "\n\n";
	a1[0] = 42;
	a1[a1.size() - 1] = 15;
	cout << a1 << "\n\n" << a3 << endl;

	Blob<string> s1 = {"hi", "bye", "now"};
	BlobPtr<string> p(s1);    // p points to the vector inside s1
	*p = "okay";                 // assigns to the first element in s1
	cout << p->size() << endl;   // prints 4, the size of the first element in s1
	cout << (*p).size() << endl; // equivalent to p->size()

	Blob<string> s2{"one", "two", "three"};
	// run the string empty function in the first element in s2
	if (s2[0].empty())
	    s2[0] = "empty"; // assign a new value to the first string in s2

	cout << a1 << endl;
	cout << a2 << endl;
	a2.swap(a1);
	cout << a1 << endl;
	cout << a2 << endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
leaq -0x200(%rbp), %rdx
movl $0x2b, (%rdx)
leaq -0xb8(%rbp), %rdi
pushq $0x3
popq %rsi
leaq -0xa0(%rbp), %rcx
callq 0x2b58
leaq -0xa0(%rbp), %rdi
pushq $0xa
popq %rsi
leaq -0x200(%rbp), %rdx
callq 0x2bb8
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x2c0a
movups 0x1c91(%rip), %xmm0     # 0x4014
leaq -0x200(%rbp), %rsi
movaps %xmm0, 0x10(%rsi)
movups 0x1c6f(%rip), %xmm0     # 0x4004
movaps %xmm0, (%rsi)
movabsq $0x900000008, %rax      # imm = 0x900000008
movq %rax, 0x20(%rsi)
leaq -0x40(%rbp), %rdi
pushq $0xa
popq %rdx
callq 0x2c32
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x2c0a
leaq -0x198(%rbp), %rbx
leaq -0x30(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e4c
movq 0x4bdd(%rip), %rdi      # 0x6fc0
movq %rbx, %rsi
callq 0x2c53
leaq 0x1c3a(%rip), %rsi      # 0x402c
movq %rax, %rdi
callq 0x2100
movq %rax, %rbx
leaq -0x188(%rbp), %r14
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x2e4c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c53
leaq 0x1c0a(%rip), %rsi      # 0x402c
movq %rax, %rdi
callq 0x2100
movq %rax, %rbx
leaq -0x178(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2e4c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c53
movq %rax, %rdi
callq 0x2090
leaq -0x170(%rbp), %rdi
callq 0x2e98
leaq -0x180(%rbp), %rdi
callq 0x2e98
leaq -0x190(%rbp), %rdi
callq 0x2e98
movq 0x4b42(%rip), %rdi      # 0x6fc0
leaq 0x1baa(%rip), %rsi      # 0x402f
callq 0x2100
leaq 0x1b9b(%rip), %rsi      # 0x402c
movq %rax, %rdi
callq 0x2100
leaq -0x168(%rbp), %rbx
leaq -0x30(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e4c
leaq -0x158(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e4c
movq 0x4afb(%rip), %rdi      # 0x6fc0
movq %r14, %rsi
callq 0x2c53
movq %rax, %rdi
callq 0x2090
leaq -0x150(%rbp), %rdi
callq 0x2e98
movq 0x4ad8(%rip), %rdi      # 0x6fc0
leaq 0x1b46(%rip), %rsi      # 0x4035
callq 0x2100
leaq 0x1b31(%rip), %rsi      # 0x402c
movq %rax, %rdi
callq 0x2100
leaq -0x30(%rbp), %rbx
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x2f28
leaq -0x148(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e4c
movq 0x4a94(%rip), %rdi      # 0x6fc0
movq %r14, %rsi
callq 0x2c53
leaq 0x1af1(%rip), %rsi      # 0x402c
movq %rax, %rdi
callq 0x2100
movq %rax, %rbx
leaq -0x138(%rbp), %r14
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x2e4c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c53
leaq 0x1ac1(%rip), %rsi      # 0x402c
movq %rax, %rdi
callq 0x2100
movq %rax, %rbx
leaq -0x128(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2e4c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c53
movq %rax, %rdi
callq 0x2090
leaq -0x120(%rbp), %rdi
callq 0x2e98
leaq -0x130(%rbp), %rdi
callq 0x2e98
leaq -0x140(%rbp), %rdi
callq 0x2e98
movq 0x49f9(%rip), %rdi      # 0x6fc0
leaq 0x1a73(%rip), %rsi      # 0x4041
callq 0x2100
leaq 0x1a52(%rip), %rsi      # 0x402c
movq %rax, %rdi
callq 0x2100
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x2cce
movl $0x2a, (%rax)
leaq -0x30(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x2, %rsi
decq %rsi
callq 0x2cce
movl $0xf, (%rax)
leaq -0x118(%rbp), %rbx
leaq -0x30(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e4c
movq 0x4993(%rip), %rdi      # 0x6fc0
movq %rbx, %rsi
callq 0x2c53
leaq 0x19f0(%rip), %rsi      # 0x402c
movq %rax, %rdi
callq 0x2100
movq %rax, %rbx
leaq -0x108(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2e4c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c53
movq %rax, %rdi
callq 0x2090
leaq -0x100(%rbp), %rdi
callq 0x2e98
leaq -0x110(%rbp), %rdi
callq 0x2e98
leaq 0x19c9(%rip), %rsi      # 0x4055
leaq -0x200(%rbp), %r14
leaq -0x78(%rbp), %rdx
movq %r14, %rdi
callq 0x2060
leaq -0x1e0(%rbp), %r15
leaq 0x19ab(%rip), %rsi      # 0x4058
leaq -0x60(%rbp), %rdx
movq %r15, %rdi
callq 0x2060
leaq -0x1c0(%rbp), %r15
leaq 0x1995(%rip), %rsi      # 0x405c
leaq -0x19(%rbp), %rdx
movq %r15, %rdi
callq 0x2060
leaq -0x88(%rbp), %rdi
leaq -0x200(%rbp), %rsi
pushq $0x3
popq %rdx
callq 0x2d3c
pushq $0x40
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0x200, %rdi           # imm = 0xFE00
callq 0x2080
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x26ec
leaq -0x78(%rbp), %rbx
leaq -0x88(%rbp), %rsi
movq %rbx, %rdi
callq 0x3a48
andq $0x0, 0x10(%rbx)
movq %rbx, %rdi
callq 0x2d5e
leaq 0x1933(%rip), %rsi      # 0x4060
movq %rax, %rdi
callq 0x21d0
leaq -0x78(%rbp), %rdi
callq 0x2d5e
movq 0x8(%rax), %rsi
movq 0x4877(%rip), %rdi      # 0x6fc0
callq 0x20c0
movq %rax, %rdi
callq 0x2090
leaq -0x78(%rbp), %rdi
callq 0x2d5e
movq 0x8(%rax), %rsi
movq 0x4856(%rip), %rdi      # 0x6fc0
callq 0x20c0
movq %rax, %rdi
callq 0x2090
leaq 0x18e7(%rip), %rsi      # 0x4065
leaq -0x200(%rbp), %r14
leaq -0x19(%rbp), %rdx
movq %r14, %rdi
callq 0x2060
leaq -0x1e0(%rbp), %r15
leaq 0x18ca(%rip), %rsi      # 0x4069
leaq -0x1b(%rbp), %rdx
movq %r15, %rdi
callq 0x2060
leaq -0x1c0(%rbp), %r15
leaq 0x18b4(%rip), %rsi      # 0x406d
leaq -0x1a(%rbp), %rdx
movq %r15, %rdi
callq 0x2060
leaq -0x60(%rbp), %rdi
leaq -0x200(%rbp), %rsi
pushq $0x3
popq %rdx
callq 0x2d3c
pushq $0x40
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0x200, %rdi           # imm = 0xFE00
callq 0x2080
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x27db
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
callq 0x2dde
cmpq $0x0, 0x8(%rax)
jne 0x2821
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
callq 0x2dde
leaq 0x185a(%rip), %rsi      # 0x4073
movq %rax, %rdi
callq 0x21d0
leaq -0xf8(%rbp), %rbx
leaq -0x30(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e4c
movq 0x4785(%rip), %rdi      # 0x6fc0
movq %rbx, %rsi
callq 0x2c53
movq %rax, %rdi
callq 0x2090
leaq -0xf0(%rbp), %rdi
callq 0x2e98
leaq -0xe8(%rbp), %rbx
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e4c
movq 0x474f(%rip), %rdi      # 0x6fc0
movq %rbx, %rsi
callq 0x2c53
movq %rax, %rdi
callq 0x2090
leaq -0xe0(%rbp), %rdi
callq 0x2e98
movups -0x40(%rbp), %xmm0
leaq -0x30(%rbp), %rsi
movups (%rsi), %xmm1
movups %xmm1, -0x40(%rbp)
movups %xmm0, (%rsi)
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
callq 0x2e4c
movq 0x470b(%rip), %rdi      # 0x6fc0
movq %rbx, %rsi
callq 0x2c53
movq %rax, %rdi
callq 0x2090
leaq -0xd0(%rbp), %rdi
callq 0x2e98
leaq -0xc8(%rbp), %rbx
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e4c
movq 0x46d5(%rip), %rdi      # 0x6fc0
movq %rbx, %rsi
callq 0x2c53
movq %rax, %rdi
callq 0x2090
leaq -0x38(%rbp), %r14
leaq -0x28(%rbp), %rbx
leaq -0xc0(%rbp), %rdi
callq 0x2e98
leaq -0x58(%rbp), %rdi
callq 0x2e98
leaq -0x70(%rbp), %rdi
callq 0x2f98
leaq -0x80(%rbp), %rdi
callq 0x2e98
leaq -0x160(%rbp), %rdi
callq 0x2e98
leaq -0x48(%rbp), %rdi
callq 0x2e98
movq %r14, %rdi
callq 0x2e98
movq %rbx, %rdi
callq 0x2e98
leaq -0xa0(%rbp), %rdi
callq 0x301a
leaq -0xb8(%rbp), %rdi
callq 0x301a
xorl %eax, %eax
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x40
popq %r14
leaq (%r14,%rbp), %rdi
addq $-0x200, %rdi           # imm = 0xFE00
callq 0x2080
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x297e
jmp 0x2afe
jmp 0x299f
movq %rax, %rbx
addq $-0x20, %r15
movq %r15, %rdi
callq 0x2080
cmpq %r14, %r15
jne 0x29a2
jmp 0x2afe
jmp 0x2afb
movq %rax, %rbx
pushq $0x40
popq %r14
leaq (%r14,%rbp), %rdi
addq $-0x200, %rdi           # imm = 0xFE00
callq 0x2080
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x29c4
jmp 0x2b10
jmp 0x29e5
movq %rax, %rbx
addq $-0x20, %r15
movq %r15, %rdi
callq 0x2080
cmpq %r14, %r15
jne 0x29e8
jmp 0x2b10
jmp 0x2af6
movq %rax, %rbx
jmp 0x2b25
movq %rax, %rbx
jmp 0x2b2e
movq %rax, %rbx
jmp 0x2b37
movq %rax, %rbx
jmp 0x2b43
movq %rax, %rbx
jmp 0x2a5b
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x2a56
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
jmp 0x2a56
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x2a56
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x2e98
leaq -0x58(%rbp), %rdi
callq 0x2e98
jmp 0x2afe
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x2e98
jmp 0x2a7d
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
jmp 0x2b0b
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x2e98
jmp 0x2a9d
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x2e98
jmp 0x2aae
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
jmp 0x2b0b
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
jmp 0x2b0b
movq %rax, %rbx
jmp 0x2b1c
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
callq 0x2e98
jmp 0x2adc
movq %rax, %rbx
leaq -0x180(%rbp), %rdi
callq 0x2e98
jmp 0x2aed
movq %rax, %rbx
leaq -0x190(%rbp), %rdi
jmp 0x2b17
movq %rax, %rbx
jmp 0x2b10
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x2f98
leaq -0x80(%rbp), %rdi
callq 0x2e98
leaq -0x160(%rbp), %rdi
callq 0x2e98
leaq -0x48(%rbp), %rdi
callq 0x2e98
leaq -0x38(%rbp), %rdi
callq 0x2e98
leaq -0x28(%rbp), %rdi
callq 0x2e98
leaq -0xa0(%rbp), %rdi
callq 0x301a
leaq -0xb8(%rbp), %rdi
callq 0x301a
movq %rbx, %rdi
callq 0x21c0
nop