// File: iZhangHui[P]CppPrimer/CH13_CopyControl/examples/StrFolderMain.cc
// Function: main
int main()
{
	String s1("contents1");
	String s2("contents2");
	String s3("contents3");
	String s4("contents4");
	String s5("contents5");
	String s6("contents6");
	
	// all new messages, no copies yet
	Message m1(s1);
	Message m2(s2);
	Message m3(s3);
	Message m4(s4);
	Message m5(s5);
	Message m6(s6);

	Folder f1;
	Folder f2;

	m1.save(f1); m3.save(f1); m5.save(f1);
	m1.save(f2);
	m2.save(f2); m4.save(f2); m6.save(f2);
	
	m1.debug_print();
	f2.debug_print();

	// create some copies
	Message c1(m1);
	Message c2(m2), c4(m4), c6(m6);
	
	m1.debug_print();
	f2.debug_print();

	// now some assignments
	m2 = m3;
	m4 = m5;
	m6 = m3;
	m1 = m5;

	m1.debug_print();
	f2.debug_print();

	// finally, self-assignment
	m2 = m2;
	m1 = m1;

	m1.debug_print();
	f2.debug_print();

	vector<Message> vm;
	cout << "capacity: " << vm.capacity() << endl;
	vm.push_back(m1);

	cout << "capacity: " << vm.capacity() << endl;
	vm.push_back(m2);

	cout << "capacity: " << vm.capacity() << endl;
	vm.push_back(m3);

	cout << "capacity: " << vm.capacity() << endl;
	vm.push_back(m4);

	cout << "capacity: " << vm.capacity() << endl;
	vm.push_back(m5);

	cout << "capacity: " << vm.capacity() << endl;
	vm.push_back(m6);

	vector<Folder> vf;
	cout << "capacity: " << vf.capacity() << endl;
	vf.push_back(f1);

	cout << "capacity: " << vf.capacity() << endl;
	vf.push_back(f2);

	cout << "capacity: " << vf.capacity() << endl;
	vf.push_back(Folder(f1));

	cout << "capacity: " << vf.capacity() << endl;
	vf.push_back(Folder(f2));

	cout << "capacity: " << vf.capacity() << endl;
	vf.push_back(Folder());

	Folder f3;
	f3.save(m6);
	cout << "capacity: " << vf.capacity() << endl;
	vf.push_back(f3);


	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x530, %rsp            # imm = 0x530
movl $0x0, -0x4(%rbp)
leaq 0x410f(%rip), %rsi      # 0xb078
leaq -0x18(%rbp), %rdi
callq 0x7b50
leaq 0x4109(%rip), %rsi      # 0xb082
leaq -0x28(%rbp), %rdi
callq 0x7b50
jmp 0x6f84
leaq 0x4101(%rip), %rsi      # 0xb08c
leaq -0x48(%rbp), %rdi
callq 0x7b50
jmp 0x6f96
leaq 0x40f9(%rip), %rsi      # 0xb096
leaq -0x58(%rbp), %rdi
callq 0x7b50
jmp 0x6fa8
leaq 0x40f1(%rip), %rsi      # 0xb0a0
leaq -0x68(%rbp), %rdi
callq 0x7b50
jmp 0x6fba
leaq 0x40e9(%rip), %rsi      # 0xb0aa
leaq -0x78(%rbp), %rdi
callq 0x7b50
jmp 0x6fcc
leaq -0xb8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x7bc0
jmp 0x6fde
leaq -0xf8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x7bc0
jmp 0x6ff0
leaq -0x138(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7bc0
jmp 0x7002
leaq -0x178(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x7bc0
jmp 0x7014
leaq -0x1b8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x7bc0
jmp 0x7026
leaq -0x1f8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x7bc0
jmp 0x7038
leaq -0x228(%rbp), %rdi
movq %rdi, -0x458(%rbp)
callq 0x7c00
leaq -0x258(%rbp), %rdi
callq 0x7c00
movq -0x458(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x1c50
jmp 0x706c
leaq -0x138(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x1c50
jmp 0x7081
leaq -0x1b8(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x1c50
jmp 0x7096
leaq -0xb8(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x1c50
jmp 0x70ab
leaq -0xf8(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x1c50
jmp 0x70c0
leaq -0x178(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x1c50
jmp 0x70d5
leaq -0x1f8(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x1c50
jmp 0x70ea
leaq -0xb8(%rbp), %rdi
callq 0x1e40
jmp 0x70f8
leaq -0x258(%rbp), %rdi
callq 0x1d30
jmp 0x7106
leaq -0x298(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x1810
jmp 0x711b
leaq -0x2d8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x1810
jmp 0x7130
leaq -0x318(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x1810
jmp 0x7145
leaq -0x358(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x1810
jmp 0x715a
leaq -0xb8(%rbp), %rdi
callq 0x1e40
jmp 0x7168
leaq -0x258(%rbp), %rdi
callq 0x1d30
jmp 0x7176
leaq -0xf8(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x1a00
jmp 0x718b
leaq -0x178(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x1a00
jmp 0x71a0
leaq -0x1f8(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x1a00
jmp 0x71b5
leaq -0xb8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x1a00
jmp 0x71ca
leaq -0xb8(%rbp), %rdi
callq 0x1e40
jmp 0x71d8
leaq -0x258(%rbp), %rdi
callq 0x1d30
jmp 0x71e6
leaq -0xf8(%rbp), %rsi
movq %rsi, %rdi
callq 0x1a00
jmp 0x71f7
leaq -0xb8(%rbp), %rsi
movq %rsi, %rdi
callq 0x1a00
jmp 0x7208
leaq -0xb8(%rbp), %rdi
callq 0x1e40
jmp 0x7216
leaq -0x258(%rbp), %rdi
callq 0x1d30
jmp 0x7224
leaq -0x370(%rbp), %rdi
callq 0x7c20
movq 0x9d99(%rip), %rdi      # 0x10fd0
leaq 0x3e76(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x460(%rbp)
jmp 0x724c
leaq -0x370(%rbp), %rdi
callq 0x7c40
movq -0x460(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x468(%rbp)
jmp 0x7270
movq -0x468(%rbp), %rdi
movq 0x9d3a(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x7285
leaq -0x370(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x7c60
jmp 0x729a
movq 0x9d2f(%rip), %rdi      # 0x10fd0
leaq 0x3e0c(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x470(%rbp)
jmp 0x72b6
leaq -0x370(%rbp), %rdi
callq 0x7c40
movq -0x470(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x478(%rbp)
jmp 0x72da
movq -0x478(%rbp), %rdi
movq 0x9cd0(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x72ef
leaq -0x370(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x7c60
jmp 0x7304
movq 0x9cc5(%rip), %rdi      # 0x10fd0
leaq 0x3da2(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x480(%rbp)
jmp 0x7320
leaq -0x370(%rbp), %rdi
callq 0x7c40
movq -0x480(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x488(%rbp)
jmp 0x7344
movq -0x488(%rbp), %rdi
movq 0x9c66(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x7359
leaq -0x370(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x7c60
jmp 0x736e
movq 0x9c5b(%rip), %rdi      # 0x10fd0
leaq 0x3d38(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x490(%rbp)
jmp 0x738a
leaq -0x370(%rbp), %rdi
callq 0x7c40
movq -0x490(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x498(%rbp)
jmp 0x73ae
movq -0x498(%rbp), %rdi
movq 0x9bfc(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x73c3
leaq -0x370(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x7c60
jmp 0x73d8
movq 0x9bf1(%rip), %rdi      # 0x10fd0
leaq 0x3cce(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x4a0(%rbp)
jmp 0x73f4
leaq -0x370(%rbp), %rdi
callq 0x7c40
movq -0x4a0(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x4a8(%rbp)
jmp 0x7418
movq -0x4a8(%rbp), %rdi
movq 0x9b92(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x742d
leaq -0x370(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x7c60
jmp 0x7442
movq 0x9b87(%rip), %rdi      # 0x10fd0
leaq 0x3c64(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x4b0(%rbp)
jmp 0x745e
leaq -0x370(%rbp), %rdi
callq 0x7c40
movq -0x4b0(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x4b8(%rbp)
jmp 0x7482
movq -0x4b8(%rbp), %rdi
movq 0x9b28(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x7497
leaq -0x370(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x7c60
jmp 0x74ac
leaq -0x388(%rbp), %rdi
callq 0x7cd0
movq 0x9b11(%rip), %rdi      # 0x10fd0
leaq 0x3bee(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x4c0(%rbp)
jmp 0x74d4
leaq -0x388(%rbp), %rdi
callq 0x7cf0
movq -0x4c0(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x4c8(%rbp)
jmp 0x74f8
movq -0x4c8(%rbp), %rdi
movq 0x9ab2(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x750d
leaq -0x388(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x7d20
jmp 0x7522
movq 0x9aa7(%rip), %rdi      # 0x10fd0
leaq 0x3b84(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x4d0(%rbp)
jmp 0x753e
leaq -0x388(%rbp), %rdi
callq 0x7cf0
movq -0x4d0(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x4d8(%rbp)
jmp 0x7562
movq -0x4d8(%rbp), %rdi
movq 0x9a48(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x7577
leaq -0x388(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x7d20
jmp 0x758c
movq 0x9a3d(%rip), %rdi      # 0x10fd0
leaq 0x3b1a(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x4e0(%rbp)
jmp 0x75a8
leaq -0x388(%rbp), %rdi
callq 0x7cf0
movq -0x4e0(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x4e8(%rbp)
jmp 0x75cc
movq -0x4e8(%rbp), %rdi
movq 0x99de(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x75e1
leaq -0x3b8(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x1b20
jmp 0x75f6
leaq -0x388(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x7d90
jmp 0x760b
leaq -0x3b8(%rbp), %rdi
callq 0x1bd0
movq 0x99b2(%rip), %rdi      # 0x10fd0
leaq 0x3a8f(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x4f0(%rbp)
jmp 0x7633
leaq -0x388(%rbp), %rdi
callq 0x7cf0
movq -0x4f0(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x4f8(%rbp)
jmp 0x7657
movq -0x4f8(%rbp), %rdi
movq 0x9953(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x766c
leaq -0x3e8(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x1b20
jmp 0x7681
leaq -0x388(%rbp), %rdi
leaq -0x3e8(%rbp), %rsi
callq 0x7d90
jmp 0x7696
leaq -0x3e8(%rbp), %rdi
callq 0x1bd0
movq 0x9927(%rip), %rdi      # 0x10fd0
leaq 0x3a04(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x500(%rbp)
jmp 0x76be
leaq -0x388(%rbp), %rdi
callq 0x7cf0
movq -0x500(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x508(%rbp)
jmp 0x76e2
movq -0x508(%rbp), %rdi
movq 0x98c8(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x76f7
xorps %xmm0, %xmm0
movaps %xmm0, -0x400(%rbp)
movaps %xmm0, -0x410(%rbp)
movaps %xmm0, -0x420(%rbp)
leaq -0x420(%rbp), %rdi
movq %rdi, -0x510(%rbp)
callq 0x7c00
movq -0x510(%rbp), %rsi
leaq -0x388(%rbp), %rdi
callq 0x7d90
jmp 0x7737
leaq -0x420(%rbp), %rdi
callq 0x1bd0
leaq -0x450(%rbp), %rdi
movq %rdi, -0x518(%rbp)
callq 0x7c00
movq -0x518(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x1ca0
jmp 0x776b
movq 0x985e(%rip), %rdi      # 0x10fd0
leaq 0x393b(%rip), %rsi      # 0xb0b4
callq 0x10d0
movq %rax, -0x520(%rbp)
jmp 0x7787
leaq -0x388(%rbp), %rdi
callq 0x7cf0
movq -0x520(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0x528(%rbp)
jmp 0x77ab
movq -0x528(%rbp), %rdi
movq 0x97ff(%rip), %rsi      # 0x10fb8
callq 0x1110
jmp 0x77c0
leaq -0x388(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x7d20
jmp 0x77d5
movl $0x0, -0x4(%rbp)
leaq -0x450(%rbp), %rdi
callq 0x1bd0
leaq -0x388(%rbp), %rdi
callq 0x7dc0
leaq -0x370(%rbp), %rdi
callq 0x7e20
leaq -0x358(%rbp), %rdi
callq 0x1a60
leaq -0x318(%rbp), %rdi
callq 0x1a60
leaq -0x2d8(%rbp), %rdi
callq 0x1a60
leaq -0x298(%rbp), %rdi
callq 0x1a60
leaq -0x258(%rbp), %rdi
callq 0x1bd0
leaq -0x228(%rbp), %rdi
callq 0x1bd0
leaq -0x1f8(%rbp), %rdi
callq 0x1a60
leaq -0x1b8(%rbp), %rdi
callq 0x1a60
leaq -0x178(%rbp), %rdi
callq 0x1a60
leaq -0x138(%rbp), %rdi
callq 0x1a60
leaq -0xf8(%rbp), %rdi
callq 0x1a60
leaq -0xb8(%rbp), %rdi
callq 0x1a60
leaq -0x78(%rbp), %rdi
callq 0x2330
leaq -0x68(%rbp), %rdi
callq 0x2330
leaq -0x58(%rbp), %rdi
callq 0x2330
leaq -0x48(%rbp), %rdi
callq 0x2330
leaq -0x28(%rbp), %rdi
callq 0x2330
leaq -0x18(%rbp), %rdi
callq 0x2330
movl -0x4(%rbp), %eax
addq $0x530, %rsp            # imm = 0x530
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7b3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7b33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7b2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7b21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7b18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7b0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7b03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7af7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7aeb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7adf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7ad3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7aaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7aa3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7a97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7a8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7a7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7a73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7a67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x1bd0
jmp 0x7a67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x3e8(%rbp), %rdi
callq 0x1bd0
jmp 0x7a67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x420(%rbp), %rdi
callq 0x1bd0
jmp 0x7a67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x450(%rbp), %rdi
callq 0x1bd0
leaq -0x388(%rbp), %rdi
callq 0x7dc0
leaq -0x370(%rbp), %rdi
callq 0x7e20
leaq -0x358(%rbp), %rdi
callq 0x1a60
leaq -0x318(%rbp), %rdi
callq 0x1a60
leaq -0x2d8(%rbp), %rdi
callq 0x1a60
leaq -0x298(%rbp), %rdi
callq 0x1a60
leaq -0x258(%rbp), %rdi
callq 0x1bd0
leaq -0x228(%rbp), %rdi
callq 0x1bd0
leaq -0x1f8(%rbp), %rdi
callq 0x1a60
leaq -0x1b8(%rbp), %rdi
callq 0x1a60
leaq -0x178(%rbp), %rdi
callq 0x1a60
leaq -0x138(%rbp), %rdi
callq 0x1a60
leaq -0xf8(%rbp), %rdi
callq 0x1a60
leaq -0xb8(%rbp), %rdi
callq 0x1a60
leaq -0x78(%rbp), %rdi
callq 0x2330
leaq -0x68(%rbp), %rdi
callq 0x2330
leaq -0x58(%rbp), %rdi
callq 0x2330
leaq -0x48(%rbp), %rdi
callq 0x2330
leaq -0x28(%rbp), %rdi
callq 0x2330
leaq -0x18(%rbp), %rdi
callq 0x2330
movq -0x30(%rbp), %rdi
callq 0x1190
nop