// File: /workspace/github_cpp_makefile_star2_O1/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), %r12
movl $0x0, (%r12)
xorl %eax, %eax
movq %rax, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
movq %rax, 0x20(%r12)
leaq -0x38(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq 0x2cbb(%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 0x1356
movq %r15, %rdi
movq %r14, %rsi
callq 0x14ec
incq (%rax)
jmp 0x132d
movq -0x60(%rbp), %rbx
cmpq %r12, %rbx
je 0x13ef
leaq 0xc9a(%rip), %r15       # 0x2004
leaq 0xc9c(%rip), %r14       # 0x200d
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x2c50(%rip), %rdi      # 0x3fd0
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 %r14, %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
cmpq %r12, %rax
jne 0x1371
movq -0x60(%rbp), %rbx
cmpq %r12, %rbx
je 0x1488
leaq 0xc01(%rip), %r15       # 0x2004
leaq 0xc03(%rip), %r14       # 0x200d
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x2bb7(%rip), %rdi      # 0x3fd0
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 %r14, %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
cmpq %r12, %rax
jne 0x140a
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x14a1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1100
leaq -0x78(%rbp), %rdi
callq 0x157a
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14bf
jmp 0x14bf
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x14db
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1100
leaq -0x78(%rbp), %rdi
callq 0x157a
movq %rbx, %rdi
callq 0x1180