// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x78, %rsp
leaq -0x88(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0xd18(%rip), %rsi       # 0x2004
leaq 0xd21(%rip), %rdx       # 0x2014
leaq -0x60(%rbp), %rdi
callq 0x1514
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x16d6
leaq -0x60(%rbp), %rdi
callq 0x155a
leaq 0xce8(%rip), %rsi       # 0x2004
leaq 0xcf9(%rip), %rdx       # 0x201c
leaq -0x60(%rbp), %rdi
callq 0x157a
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x16d6
leaq -0x60(%rbp), %rdi
callq 0x155a
leaq 0xcb8(%rip), %rsi       # 0x2004
leaq 0xcd8(%rip), %rdx       # 0x202b
leaq -0x60(%rbp), %rdi
callq 0x15c0
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x16d6
leaq -0x60(%rbp), %rdi
callq 0x155a
leaq 0xc88(%rip), %rsi       # 0x2004
leaq 0xcb6(%rip), %rdx       # 0x2039
leaq -0x60(%rbp), %rdi
callq 0x1606
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x16d6
leaq -0x60(%rbp), %rdi
callq 0x155a
leaq 0xc58(%rip), %rsi       # 0x2004
leaq -0x60(%rbp), %rdi
leaq -0x19(%rbp), %rdx
callq 0x1070
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x18ea
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1a5e
movq %rax, %r14
movq 0x2bf2(%rip), %r15      # 0x3fd8
subq $0x1, %rbx
jb 0x140d
leaq 0x40(%r14), %rsi
movq %r15, %rdi
callq 0x10e0
movq %rax, %rdi
callq 0x10a0
movq %r14, %rdi
callq 0x10b0
movq %rax, %r14
jmp 0x13e6
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1ae8
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1afe
movq %rax, %r14
movq 0x2b9e(%rip), %r15      # 0x3fd8
cmpq %r14, %rbx
je 0x1460
leaq 0x40(%rbx), %rsi
movq %r15, %rdi
callq 0x10e0
movq %rax, %rdi
callq 0x10a0
movq %rbx, %rdi
callq 0x10b0
movq %rax, %rbx
jmp 0x143a
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1b58
movq %rax, %r14
movq %rdx, %rbx
movq 0x2b5b(%rip), %r15      # 0x3fd8
cmpq %rbx, %r14
je 0x14a3
leaq 0x40(%r14), %rsi
movq %r15, %rdi
callq 0x10e0
movq %rax, %rdi
callq 0x10a0
movq %r14, %rdi
callq 0x10b0
movq %rax, %r14
jmp 0x147d
leaq -0x60(%rbp), %rdi
callq 0x1090
leaq -0x90(%rbp), %rdi
callq 0x165a
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14f4
jmp 0x14f4
jmp 0x14f4
jmp 0x14f4
jmp 0x14f4
jmp 0x14eb
jmp 0x14dd
jmp 0x14eb
jmp 0x14dd
jmp 0x14eb
jmp 0x14dd
jmp 0x14eb
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x155a
jmp 0x1500
movq %rax, %rbx
jmp 0x1500
jmp 0x14f4
jmp 0x14f4
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x1090
leaq -0x90(%rbp), %rdi
callq 0x165a
movq %rbx, %rdi
callq 0x1170