// File: /workspace/github_cpp_makefile_star2_O1/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 0x24b5
movq -0x40(%rbp), %rbx
testq %rbx, %rbx
je 0x2383
movq -0x48(%rbp), %r14
xorl %r15d, %r15d
movsbl (%r14,%r15), %edi
callq 0x2150
movb %al, (%r14,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x236d
movq -0x48(%rbp), %r15
movq -0x40(%rbp), %r14
leaq (%r15,%r14), %r12
movq %r14, %rbx
sarq $0x2, %rbx
testq %rbx, %rbx
jle 0x23fc
andq $-0x4, %r14
addq %r15, %r14
incq %rbx
addq $0x3, %r15
movq %r15, %r13
movsbl -0x3(%r13), %edi
callq 0x21b0
testl %eax, %eax
jne 0x244b
movsbl -0x2(%r13), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2451
movsbl -0x1(%r13), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2457
movsbl (%r13), %edi
callq 0x21b0
testl %eax, %eax
jne 0x245a
decq %rbx
addq $0x4, %r13
cmpq $0x1, %rbx
jg 0x23ac
movq %r14, %r15
movq %r12, %rax
subq %r15, %rax
cmpq $0x1, %rax
je 0x2437
cmpq $0x2, %rax
je 0x2427
movq %r12, %r13
cmpq $0x3, %rax
jne 0x245a
movsbl (%r15), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2446
incq %r15
movsbl (%r15), %edi
callq 0x21b0
testl %eax, %eax
jne 0x2446
incq %r15
movsbl (%r15), %edi
callq 0x21b0
testl %eax, %eax
cmoveq %r12, %r15
movq %r15, %r13
jmp 0x245a
addq $-0x3, %r13
jmp 0x245a
addq $-0x2, %r13
jmp 0x245a
decq %r13
cmpq %r12, %r13
sete %al
leaq 0x1(%r13), %rbx
cmpq %r12, %rbx
sete %cl
leaq -0x48(%rbp), %r15
orb %al, %cl
jne 0x2491
movb (%rbx), %r14b
movsbl %r14b, %edi
callq 0x21b0
testl %eax, %eax
jne 0x2489
movb %r14b, (%r13)
incq %r13
incq %rbx
cmpq %r12, %rbx
jne 0x2472
movq %r13, %rax
subq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movb $0x0, (%r13)
leaq -0x78(%rbp), %rdi
movq %r15, %rsi
callq 0x265e
incq (%rax)
jmp 0x233c
movq -0x60(%rbp), %rbx
leaq -0x70(%rbp), %rax
cmpq %rax, %rbx
je 0x2559
movq 0x2b03(%rip), %r14      # 0x4fd0
leaq 0xb30(%rip), %r15       # 0x3004
leaq 0xb32(%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 0x24db
movq -0x60(%rbp), %rbx
cmpq %rax, %rbx
je 0x25f9
movq 0x2a63(%rip), %r14      # 0x4fd0
leaq 0xa90(%rip), %r15       # 0x3004
leaq 0xa92(%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 0x257b
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x2612
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2100
leaq -0x78(%rbp), %rdi
callq 0x26ec
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2630
jmp 0x2630
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x264c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2100
leaq -0x78(%rbp), %rdi
callq 0x26ec
movq %rbx, %rdi
callq 0x2190
nop