// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH11_AssociativeContainers/exercises/ex11_03_04.cc
// Function: main
int main(int argc, char const *argv[])
{
	// 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) {
		for (auto& ch : word)
			ch = tolower(ch);

		// strip - iterator erase(iterator __first, iterator __last)
		word.erase(remove_if(word.begin(), word.end(), ispunct), word.end());
		++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), %r13
andl $0x0, (%r13)
andq $0x0, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
andq $0x0, 0x20(%r13)
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x48(%rbp), %r14
movq 0x2c95(%rip), %rdi      # 0x4fd8
movq %r14, %rsi
callq 0x2150
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x23c1
movq %r13, %r12
movq -0x48(%rbp), %r13
movq -0x40(%rbp), %r15
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0x2380
movsbl (%r13,%rbx), %edi
callq 0x2170
movb %al, (%r13,%rbx)
incq %rbx
jmp 0x2366
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq %rdi, %rsi
movq 0x2c5e(%rip), %rdx      # 0x4ff0
callq 0x25c3
movq -0x48(%rbp), %rdx
addq -0x40(%rbp), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x2050
movq %r12, %r13
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x24d0
incq (%rax)
jmp 0x233c
movq -0x60(%rbp), %r12
movq 0x2bfc(%rip), %rbx      # 0x4fc8
leaq 0xc31(%rip), %r14       # 0x3004
leaq 0xc33(%rip), %r15       # 0x300d
cmpq %r13, %r12
je 0x2424
leaq 0x20(%r12), %rsi
movq %rbx, %rdi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x2100
movq 0x40(%r12), %rsi
movq %rax, %rdi
callq 0x20b0
movq %rax, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
callq 0x20c0
movq %rax, %r12
jmp 0x23da
movq -0x60(%rbp), %r12
movq 0x2b99(%rip), %rbx      # 0x4fc8
leaq 0xbce(%rip), %r14       # 0x3004
leaq 0xbd0(%rip), %r15       # 0x300d
cmpq %r13, %r12
je 0x2487
leaq 0x20(%r12), %rsi
movq %rbx, %rdi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x2100
movq 0x40(%r12), %rsi
movq %rax, %rdi
callq 0x20b0
movq %rax, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
callq 0x2140
movq %rax, %r12
jmp 0x243d
leaq -0x48(%rbp), %rdi
callq 0x2090
leaq -0x78(%rbp), %rdi
callq 0x2548
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24b2
jmp 0x24b2
jmp 0x24b2
jmp 0x24b2
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2090
leaq -0x78(%rbp), %rdi
callq 0x2548
movq %rbx, %rdi
callq 0x21b0
nop