// File: /workspace/github_cpp_makefile_star2_O3/iZhangHui[P]CppPrimer/CH11_AssociativeContainers/examples/setOps.cc
// Function: main
int main()
{
	// define a vector with 20 elements,
	// holding two copies of each number from 0 to 9
	vector<int> ivec;
	for (vector<int>::size_type i = 10; i != 0; --i) {
		ivec.push_back(i);
		ivec.push_back(i);  // duplicate copies of each number
	}

	// iset holds unique elements from ivec; miset holds all 20 elements
	set<int> iset(ivec.cbegin(), ivec.cend());
	multiset<int> miset(ivec.cbegin(), ivec.cend());

	cout << ivec.size() << endl;    // prints 20
	cout << iset.size() << endl;    // prints 10
	for (const auto item : iset)
		cout << item << endl;

	cout << miset.size() << endl;   // prints 20

	// returns an iterator that refers to the element with key == 1
	iset.find(1);
	iset.find(11);  // returns the iterator == iset.end()
	iset.count(1);  // returns 1
	iset.count(11); // returns 0

	// returns an iterator to the first element with key == 1
	iset.find(1);
	iset.find(11);   // returns the iterator == iset.end()
	miset.count(1);  // returns 2
	miset.count(11); // returns 0

	set<string> set1;    // empty set
	set1.insert("the");  // set1 now has one element
	set1.insert("and");  // set1 now has two elements

	ivec = {2,4,6,8,2,4,6,8}; // ivec now has eight elements
	set<int> set2;            // empty set
	set2.insert(ivec.cbegin(), ivec.cend()); // set2 has four elements
	set2.insert({1,3,5,7,1,3,5,7});      // set2 now has eight elements
	for (const auto item : set2)
		cout << item << endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rbx
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movl $0xa, %r15d
leaq -0xa0(%rbp), %r14
movl %r15d, -0xa0(%rbp)
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rax
cmpq %rax, %rsi
je 0x1350
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x1363
movq %rbx, %rdi
movq %r14, %rdx
callq 0x199a
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rax
movl %r15d, -0xa0(%rbp)
cmpq %rax, %rsi
je 0x137c
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x1387
movq %rbx, %rdi
movq %r14, %rdx
callq 0x199a
decq %r15
jne 0x132f
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x17a6
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0x1822
movq -0x38(%rbp), %rsi
subq -0x40(%rbp), %rsi
sarq $0x2, %rsi
movq 0x3c11(%rip), %rdi      # 0x4fd8
callq 0x10a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10b0
movq -0x78(%rbp), %rsi
movq 0x3bd7(%rip), %rdi      # 0x4fd8
callq 0x10a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10b0
leaq -0x98(%rbp), %r12
movq 0x10(%r12), %rbx
cmpq %r12, %rbx
je 0x148d
movq 0x3b90(%rip), %r14      # 0x4fd8
movl 0x20(%rbx), %esi
movq %r14, %rdi
callq 0x1180
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x1110
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10b0
movq %rbx, %rdi
callq 0x1150
movq %rax, %rbx
cmpq %r12, %rax
jne 0x1448
movq -0xf8(%rbp), %rsi
movq 0x3b3d(%rip), %rdi      # 0x4fd8
callq 0x10a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10b0
leaq -0xf0(%rbp), %rsi
movl $0x1, (%rsi)
leaq -0x120(%rbp), %rdi
callq 0x1ea4
leaq -0xf0(%rbp), %rsi
movl $0xb, (%rsi)
leaq -0x120(%rbp), %rdi
callq 0x1ea4
leaq -0xe8(%rbp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq -0x60(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x1ada(%rip), %rsi      # 0x3004
leaq 0x1ad6(%rip), %rdx      # 0x3007
leaq -0x70(%rbp), %rdi
callq 0x2108
leaq -0xf0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x1f58
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x155f
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x1130
leaq -0x70(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x1a9b(%rip), %rsi      # 0x3008
leaq 0x1a97(%rip), %rdx      # 0x300b
callq 0x2108
leaq -0xf0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x1f58
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x159e
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x1130
movups 0x1aef(%rip), %xmm0     # 0x3094
leaq -0x50(%rbp), %rdx
movaps %xmm0, -0x10(%rdx)
movups 0x1ad0(%rip), %xmm0     # 0x3084
movaps %xmm0, -0x20(%rdx)
leaq -0x40(%rbp), %rdi
leaq -0x70(%rbp), %r12
movq %r12, %rsi
callq 0x21a6
leaq -0x68(%rbp), %rbx
movl $0x0, (%rbx)
xorl %eax, %eax
movq %rax, 0x8(%rbx)
movq %rbx, 0x10(%rbx)
movq %rbx, 0x18(%rbx)
movq %rax, 0x20(%rbx)
movq -0x40(%rbp), %r15
movq -0x38(%rbp), %r14
movq %r12, -0xc0(%rbp)
cmpq %r14, %r15
je 0x1619
leaq -0xc0(%rbp), %r13
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x1ada
addq $0x4, %r15
cmpq %r14, %r15
jne 0x15ff
movups 0x1a94(%rip), %xmm0     # 0x30b4
movaps %xmm0, -0xb0(%rbp)
movups 0x1a76(%rip), %xmm0     # 0x30a4
movaps %xmm0, -0xc0(%rbp)
leaq -0x128(%rbp), %r15
leaq -0x70(%rbp), %rax
movq %rax, (%r15)
xorl %r14d, %r14d
leaq (%r14,%rbp), %rdx
addq $-0xc0, %rdx
leaq -0x70(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x1ada
addq $0x4, %r14
cmpq $0x20, %r14
jne 0x1646
movq -0x58(%rbp), %r14
cmpq %rbx, %r14
je 0x16c0
movq 0x395e(%rip), %r15      # 0x4fd8
movl 0x20(%r14), %esi
movq %r15, %rdi
callq 0x1180
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x1110
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10b0
movq %r14, %rdi
callq 0x1150
movq %rax, %r14
cmpq %rbx, %rax
jne 0x167a
leaq -0x70(%rbp), %rdi
callq 0x18ac
leaq -0xf0(%rbp), %rdi
callq 0x190a
leaq -0x120(%rbp), %rdi
callq 0x18ac
leaq -0xa0(%rbp), %rdi
callq 0x18ac
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1702
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x1130
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1736
jmp 0x171c
jmp 0x1736
movq %rax, %rbx
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x175f
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x1130
jmp 0x175f
movq %rax, %rbx
jmp 0x175f
jmp 0x176d
jmp 0x176d
movq %rax, %rbx
jmp 0x177c
jmp 0x174a
jmp 0x176d
jmp 0x174a
movq %rax, %rbx
jmp 0x1788
jmp 0x1753
jmp 0x1753
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x18ac
leaq -0xf0(%rbp), %rdi
callq 0x190a
jmp 0x1770
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x18ac
leaq -0xa0(%rbp), %rdi
callq 0x18ac
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x179d
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x1130
movq %rbx, %rdi
callq 0x1190
nop