// File: /workspace/github_cpp_makefile_star2_O3/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), %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)
leaq -0x48(%rbp), %r15
movq 0x2c9d(%rip), %rdi      # 0x4fe0
movq %r15, %rsi
callq 0x2140
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x24d0
movq -0x48(%rbp), %r13
movq -0x40(%rbp), %rbx
testq %rbx, %rbx
je 0x2405
xorl %r14d, %r14d
movsbl (%r13,%r14), %edi
callq 0x2150
movb %al, (%r13,%r14)
incq %r14
cmpq %r14, %rbx
jne 0x2371
movq -0x48(%rbp), %r14
movq -0x40(%rbp), %rbx
leaq (%r14,%rbx), %r13
movq %rbx, %r15
sarq $0x2, %r15
testq %r15, %r15
jle 0x240d
andq $-0x4, %rbx
addq %r14, %rbx
incq %r15
leaq 0x3(%r14), %r12
movsbl -0x3(%r12), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2462
movsbl -0x2(%r12), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2468
movsbl -0x1(%r12), %edi
callq 0x21b0
testl %eax, %eax
jne 0x246e
movsbl (%r12), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2471
decq %r15
addq $0x4, %r12
cmpq $0x1, %r15
jg 0x23af
jmp 0x2410
movq %r13, %r14
movq %r13, %rbx
jmp 0x2414
movq %r14, %rbx
leaq -0x48(%rbp), %r15
movq %r13, %rax
subq %rbx, %rax
cmpq $0x1, %rax
je 0x244a
cmpq $0x2, %rax
je 0x243b
cmpq $0x3, %rax
jne 0x245d
movsbl (%rbx), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2458
incq %rbx
movsbl (%rbx), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2458
incq %rbx
movsbl (%rbx), %edi
callq 0x21b0
testl %eax, %eax
cmoveq %r13, %rbx
movq %rbx, %r12
jmp 0x2475
movq %r13, %r12
jmp 0x24ad
addq $-0x3, %r12
jmp 0x2471
addq $-0x2, %r12
jmp 0x2471
decq %r12
leaq -0x48(%rbp), %r15
cmpq %r13, %r12
sete %al
leaq 0x1(%r12), %rbx
cmpq %r13, %rbx
sete %cl
orb %al, %cl
jne 0x24ad
movb (%rbx), %r14b
movsbl %r14b, %edi
callq 0x21b0
testl %eax, %eax
jne 0x24a1
movb %r14b, (%r12)
incq %r12
incq %rbx
cmpq %r13, %rbx
jne 0x248a
movq -0x48(%rbp), %r14
movq %r12, %rax
subq %r14, %rax
movq %rax, -0x40(%rbp)
movb $0x0, (%r12)
leaq -0x78(%rbp), %rdi
movq %r15, %rsi
callq 0x2678
incq (%rax)
jmp 0x233c
movq -0x60(%rbp), %rbx
leaq -0x70(%rbp), %rax
cmpq %rax, %rbx
je 0x2578
movq 0x2ae8(%rip), %r14      # 0x4fd0
leaq 0xb15(%rip), %r15       # 0x3004
leaq 0xb17(%rip), %r12       # 0x300d
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x2120
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2120
movq 0x40(%rbx), %rsi
movq %r13, %rdi
callq 0x2080
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2120
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x20a0
movq %rax, %rbx
leaq -0x70(%rbp), %rax
cmpq %rax, %rbx
jne 0x24f6
movq -0x60(%rbp), %rbx
cmpq %rax, %rbx
je 0x2614
movq 0x2a48(%rip), %r14      # 0x4fd0
leaq 0xa75(%rip), %r15       # 0x3004
leaq 0xa77(%rip), %r12       # 0x300d
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x2120
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2120
movq 0x40(%rbx), %rsi
movq %r13, %rdi
callq 0x2080
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2120
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x2130
movq %rax, %rbx
leaq -0x70(%rbp), %rax
cmpq %rax, %rbx
jne 0x2596
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x262d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2100
leaq -0x78(%rbp), %rdi
callq 0x2706
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x264b
jmp 0x264b
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x2667
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2100
leaq -0x78(%rbp), %rdi
callq 0x2706
movq %rbx, %rdi
callq 0x2190