// File: 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
subq $0xf0, %rsp
movl $0x0, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x25b0
leaq -0x58(%rbp), %rdi
callq 0x2170
movq 0x4cb5(%rip), %rdi      # 0x6fe0
leaq -0x58(%rbp), %rsi
callq 0x2160
movq %rax, -0xa0(%rbp)
jmp 0x233d
movq -0xa0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2150
movb %al, -0xa1(%rbp)
jmp 0x235b
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x2367
jmp 0x23b3
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x25d0
movq %rax, -0xb0(%rbp)
jmp 0x237d
movq -0xb0(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x2324
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x20a0
leaq -0x38(%rbp), %rdi
callq 0x2870
jmp 0x259c
leaq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x26b0
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x26e0
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2710
testb $0x1, %al
jne 0x23eb
jmp 0x2494
leaq -0x78(%rbp), %rdi
callq 0x2740
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rsi
movq 0x4bc7(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq %rax, -0xb8(%rbp)
jmp 0x2417
movq -0xb8(%rbp), %rdi
leaq 0x1bdf(%rip), %rsi      # 0x4004
callq 0x20f0
movq %rax, -0xc0(%rbp)
jmp 0x2433
movq -0xc0(%rbp), %rdi
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x2050
movq %rax, -0xc8(%rbp)
jmp 0x2453
movq -0xc8(%rbp), %rdi
leaq 0x1bac(%rip), %rsi      # 0x400d
callq 0x20f0
movq %rax, -0xd0(%rbp)
jmp 0x246f
movq -0xd0(%rbp), %rdi
movq 0x4b43(%rip), %rsi      # 0x6fc0
callq 0x2130
jmp 0x2484
jmp 0x2486
leaq -0x78(%rbp), %rdi
callq 0x2760
jmp 0x23d5
leaq -0x38(%rbp), %rdi
callq 0x2790
movq %rax, -0x90(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x27f0
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x27c0
testb $0x1, %al
jne 0x24d0
jmp 0x2577
leaq -0x90(%rbp), %rdi
callq 0x2820
movq %rax, %rsi
movq 0x4aea(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq %rax, -0xd8(%rbp)
jmp 0x24f4
movq -0xd8(%rbp), %rdi
leaq 0x1b02(%rip), %rsi      # 0x4004
callq 0x20f0
movq %rax, -0xe0(%rbp)
jmp 0x2510
leaq -0x90(%rbp), %rdi
callq 0x2820
movq -0xe0(%rbp), %rdi
movq 0x20(%rax), %rsi
callq 0x2050
movq %rax, -0xe8(%rbp)
jmp 0x2535
movq -0xe8(%rbp), %rdi
leaq 0x1aca(%rip), %rsi      # 0x400d
callq 0x20f0
movq %rax, -0xf0(%rbp)
jmp 0x2551
movq -0xf0(%rbp), %rdi
movq 0x4a61(%rip), %rsi      # 0x6fc0
callq 0x2130
jmp 0x2566
leaq -0x90(%rbp), %rdi
callq 0x2840
jmp 0x24a4
movl $0x0, -0x4(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x20a0
leaq -0x38(%rbp), %rdi
callq 0x2870
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x21b0
nopw %cs:(%rax,%rax)
nop