// File: /workspace/github_cpp_makefile_star2_O1/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
cmpq -0x30(%rbp), %rsi
je 0x134d
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x1358
movq %rbx, %rdi
movq %r14, %rdx
callq 0x19a0
movl %r15d, -0xa0(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0x1376
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x1381
movq %rbx, %rdi
movq %r14, %rdx
callq 0x19a0
decq %r15
jne 0x132f
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x17a0
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 0x3c17(%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 0x3bdd(%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 0x1487
movq 0x3b96(%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 0x1442
movq -0xf8(%rbp), %rsi
movq 0x3b43(%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 0x1eae
leaq -0xf0(%rbp), %rsi
movl $0xb, (%rsi)
leaq -0x120(%rbp), %rdi
callq 0x1eae
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 0x1ae0(%rip), %rsi      # 0x3004
leaq 0x1adc(%rip), %rdx      # 0x3007
leaq -0x70(%rbp), %rdi
callq 0x2116
leaq -0xf0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x1f5c
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x1559
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x1130
leaq -0x70(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x1aa1(%rip), %rsi      # 0x3008
leaq 0x1a9d(%rip), %rdx      # 0x300b
callq 0x2116
leaq -0xf0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x1f5c
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x1598
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x1130
movups 0x1af5(%rip), %xmm0     # 0x3094
leaq -0x50(%rbp), %rdx
movaps %xmm0, -0x10(%rdx)
movups 0x1ad6(%rip), %xmm0     # 0x3084
movaps %xmm0, -0x20(%rdx)
leaq -0x40(%rbp), %rdi
leaq -0x70(%rbp), %r12
movq %r12, %rsi
callq 0x21b0
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 0x1613
leaq -0xc0(%rbp), %r13
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x1ae0
addq $0x4, %r15
cmpq %r14, %r15
jne 0x15f9
movups 0x1a9a(%rip), %xmm0     # 0x30b4
movaps %xmm0, -0xb0(%rbp)
movups 0x1a7c(%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 0x1ae0
addq $0x4, %r14
cmpq $0x20, %r14
jne 0x1640
movq -0x58(%rbp), %r14
cmpq %rbx, %r14
je 0x16ba
movq 0x3964(%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 0x1674
leaq -0x70(%rbp), %rdi
callq 0x18b2
leaq -0xf0(%rbp), %rdi
callq 0x1910
leaq -0x120(%rbp), %rdi
callq 0x18b2
leaq -0xa0(%rbp), %rdi
callq 0x18b2
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x16fc
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 0x1730
jmp 0x1716
jmp 0x1730
movq %rax, %rbx
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x1759
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x1130
jmp 0x1759
movq %rax, %rbx
jmp 0x1759
jmp 0x1767
jmp 0x1767
movq %rax, %rbx
jmp 0x1776
jmp 0x1744
jmp 0x1767
jmp 0x1744
movq %rax, %rbx
jmp 0x1782
jmp 0x174d
jmp 0x174d
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x18b2
leaq -0xf0(%rbp), %rdi
callq 0x1910
jmp 0x176a
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x18b2
leaq -0xa0(%rbp), %rdi
callq 0x18b2
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1797
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x1130
movq %rbx, %rdi
callq 0x1190
nop