// File: /workspace/github_cpp_makefile_star2_O1/iZhangHui[P]CppPrimer/CH11_AssociativeContainers/examples/multimap.cc
// Function: main
int main()
{
	// map from author to title; there can be multiple titles per author
	multimap<string, string> authors;
	// add data to authors
	authors.insert({"Alain de Botton", "On Love"});
	authors.insert({"Alain de Botton", "Status Anxiety"});
	authors.insert({"Alain de Botton", "Art of Travel"});
	authors.insert({"Alain de Botton",
							  "Architecture of Happiness"});

	string search_item("Alain de Botton"); // author we'll look for
	auto entries = authors.count(search_item); // number of elements
	auto iter = authors.find(search_item); // first entry for this author

	// loop through the number of entries there are for this author
	while(entries) {
		cout << iter->second << endl; // print each title
		++iter;     // advance to the next title
		--entries;  // keep track of how many we've printed
	}

	// definitions of authors and search_item as above
	// beg and end denote the range of elements for this author
	for (auto beg = authors.lower_bound(search_item),
			  end = authors.upper_bound(search_item);
		 beg != end; ++beg)
		cout << beg->second << endl; // print each title

	// definitions of authors and search_item as above
	// pos holds iterators that denote the range of elements for this key
	for (auto pos = authors.equal_range(search_item);
		 pos.first != pos.second; ++pos.first)
		cout << pos.first->second << endl; // print each title

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
leaq -0x98(%rbp), %rbx
movl $0x0, (%rbx)
xorl %eax, %eax
movq %rax, 0x8(%rbx)
movq %rbx, 0x10(%rbx)
movq %rbx, 0x18(%rbx)
movq %rax, 0x20(%rbx)
leaq 0xd11(%rip), %rsi       # 0x2004
leaq 0xd1a(%rip), %rdx       # 0x2014
leaq -0x68(%rbp), %rdi
callq 0x16ac
leaq -0xa0(%rbp), %r14
leaq -0x68(%rbp), %rsi
movq %r14, %rdi
callq 0x19a8
leaq -0x70(%rbp), %r8
movq %r14, (%r8)
leaq -0x68(%rbp), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0x19f2
leaq -0x38(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x1345
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1100
leaq -0x58(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x135e
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x1100
leaq 0xc9f(%rip), %rsi       # 0x2004
leaq 0xcb0(%rip), %rdx       # 0x201c
leaq -0x68(%rbp), %rdi
callq 0x1770
leaq -0x68(%rbp), %rsi
movq %r14, %rdi
callq 0x19a8
leaq -0x70(%rbp), %r8
movq %r14, (%r8)
leaq -0x68(%rbp), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0x19f2
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x13ac
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1100
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x13c1
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x1100
leaq 0xc3c(%rip), %rsi       # 0x2004
leaq 0xc5c(%rip), %rdx       # 0x202b
leaq -0x68(%rbp), %rdi
callq 0x17ee
leaq -0x68(%rbp), %rsi
movq %r14, %rdi
callq 0x19a8
leaq -0x70(%rbp), %r8
movq %r14, (%r8)
leaq -0x68(%rbp), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0x19f2
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x140f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1100
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x1424
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x1100
leaq 0xbd9(%rip), %rsi       # 0x2004
leaq 0xc07(%rip), %rdx       # 0x2039
leaq -0x68(%rbp), %rdi
callq 0x186c
leaq -0x68(%rbp), %rsi
movq %r14, %rdi
callq 0x19a8
leaq -0x70(%rbp), %r8
movq %r14, (%r8)
leaq -0x68(%rbp), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0x19f2
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x1472
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1100
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x1487
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x1100
leaq -0x68(%rbp), %rdi
movq %r13, (%rdi)
leaq 0xb6f(%rip), %rsi       # 0x2004
leaq 0xb77(%rip), %rdx       # 0x2013
callq 0x1bda
leaq -0xa0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1c74
movq %rax, %r14
leaq -0xa0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1df6
testq %r14, %r14
je 0x151d
movq %rax, %r15
movq 0x2b05(%rip), %r12      # 0x3fd8
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
movq %r12, %rdi
callq 0x1110
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x10e0
movsbl %al, %esi
movq %r13, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq %r15, %rdi
callq 0x10a0
movq %rax, %r15
decq %r14
jne 0x14d3
leaq -0xa0(%rbp), %rdi
movq 0x10(%rdi), %rsi
leaq -0x68(%rbp), %rcx
movq %rbx, %rdx
callq 0x1e46
movq %rax, %r14
leaq -0xa0(%rbp), %rdi
movq 0x10(%rdi), %rsi
leaq -0x68(%rbp), %rcx
movq %rbx, %rdx
leaq -0x58(%rbp), %r13
callq 0x1e94
movq %rax, %rbx
cmpq %rax, %r14
je 0x15ab
movq 0x2a77(%rip), %r15      # 0x3fd8
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
movq %r15, %rdi
callq 0x1110
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10e0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq %r14, %rdi
callq 0x10a0
movq %rax, %r14
cmpq %rbx, %rax
jne 0x1561
leaq -0xa0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1ee4
movq %rax, %r14
movq %rdx, %rbx
cmpq %rdx, %rax
je 0x1617
movq 0x2a0b(%rip), %r15      # 0x3fd8
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
movq %r15, %rdi
callq 0x1110
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10e0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq %r14, %rdi
callq 0x10a0
movq %rax, %r14
cmpq %rbx, %rax
jne 0x15cd
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x162c
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x1100
leaq -0xa0(%rbp), %rdi
callq 0x18f8
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1676
jmp 0x1676
jmp 0x167b
jmp 0x167b
jmp 0x1676
jmp 0x165b
jmp 0x165b
jmp 0x165b
jmp 0x165b
movq %rax, %rbx
jmp 0x1697
jmp 0x1666
jmp 0x1666
jmp 0x1666
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x172a
jmp 0x1697
jmp 0x1676
movq %rax, %rbx
jmp 0x1682
movq %rax, %rbx
leaq -0x58(%rbp), %r13
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x1697
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x1100
leaq -0xa0(%rbp), %rdi
callq 0x18f8
movq %rbx, %rdi
callq 0x1160
nop