// File: /workspace/github_cpp_makefile_star2_O3/iZhangHui[P]CppPrimer/CH11_AssociativeContainers/examples/word_count.cc
// Function: main
int main()
{
	// count the number of times each word occurs in the input
	map<string, size_t> word_count; // empty map from string to size_t
	string word;
	while (cin >> word)
		++word_count[word];

	for (const auto& w : word_count)
		cout <<  w.first << " occurs " << w.second << " times" << endl;

	// get an iterator positioned on the first element
	auto map_it = word_count.cbegin();
	// compare the current iterator to the off-the-end iterator
	while (map_it != word_count.cend()) {
		// dereference the iterator to print the element key--value pairs
		cout << map_it->first << " occurs "
			 << map_it->second << " times" << endl;
		++map_it;  // increment the iterator to denote the next element
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq -0x70(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq -0x38(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq 0x2cc1(%rip), %rbx      # 0x3fe0
leaq -0x48(%rbp), %r14
leaq -0x78(%rbp), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1140
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1350
movq %r15, %rdi
movq %r14, %rsi
callq 0x14f8
incq (%rax)
jmp 0x1327
movq -0x60(%rbp), %rbx
leaq -0x70(%rbp), %rax
cmpq %rax, %rbx
je 0x13f8
movq 0x2c68(%rip), %r14      # 0x3fd0
leaq 0xc95(%rip), %r15       # 0x2004
leaq 0xc97(%rip), %r12       # 0x200d
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x1120
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1120
movq 0x40(%rbx), %rsi
movq %r13, %rdi
callq 0x1080
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1120
movq (%r13), %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 %rbx, %rdi
callq 0x10a0
movq %rax, %rbx
leaq -0x70(%rbp), %rax
cmpq %rax, %rbx
jne 0x1376
movq -0x60(%rbp), %rbx
cmpq %rax, %rbx
je 0x1494
movq 0x2bc8(%rip), %r14      # 0x3fd0
leaq 0xbf5(%rip), %r15       # 0x2004
leaq 0xbf7(%rip), %r12       # 0x200d
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x1120
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1120
movq 0x40(%rbx), %rsi
movq %r13, %rdi
callq 0x1080
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1120
movq (%r13), %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 %rbx, %rdi
callq 0x1130
movq %rax, %rbx
leaq -0x70(%rbp), %rax
cmpq %rax, %rbx
jne 0x1416
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x14ad
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1100
leaq -0x78(%rbp), %rdi
callq 0x1586
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14cb
jmp 0x14cb
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x14e7
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1100
leaq -0x78(%rbp), %rdi
callq 0x1586
movq %rbx, %rdi
callq 0x1180