// File: /workspace/github_cpp_makefile_star2_O1/iZhangHui[P]CppPrimer/CH11_AssociativeContainers/examples/wcEx.cc
// Function: main
int main()
{
	// count 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) {
		auto ret = word_count.insert({word, 0});
		cout << "insert " << word << (ret.second ? " successfully" : " failed") << endl;
		++ret.first->second;
		// ++word_count.insert({word, 0}).first->second;
	}

	for(auto it = word_count.cbegin(); it != word_count.cend(); ++it) {
		auto w = *it;
		cout <<  w.first << " occurs " << w.second << " times" << endl;
	}

	// get iterator positioned on the first element
	auto map_it = word_count.cbegin();
	// for each element in the map
	while (map_it != word_count.cend()) {
		// print the element key, value pairs
		cout << map_it->first << " occurs "
			 << map_it->second << " times" << endl;
		++map_it;  // increment 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 $0x78, %rsp
leaq -0x98(%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 -0x60(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
leaq -0x50(%rbp), %r15
movq 0x2cba(%rip), %r13      # 0x3fd0
movq 0x2cc3(%rip), %rdi      # 0x3fe0
leaq -0x70(%rbp), %rsi
callq 0x1130
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x140b
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x163e
movq $0x0, -0x30(%rbp)
leaq -0xa0(%rbp), %rdi
movq %r15, %rsi
callq 0x1768
movq %rax, %r12
movl %edx, %ebx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x1388
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10f0
movl $0x7, %edx
movq %r13, %rdi
leaq 0xc6d(%rip), %rsi       # 0x2004
callq 0x1110
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %r13, %rdi
callq 0x1110
movq %rax, %r14
testb $0x1, %bl
leaq 0xc61(%rip), %rsi       # 0x201a
leaq 0xc4c(%rip), %rax       # 0x200c
cmovneq %rax, %rsi
movl $0x7, %edx
movl $0xd, %eax
cmovneq %rax, %rdx
movq %r14, %rdi
callq 0x1110
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
incq 0x40(%r12)
jmp 0x1316
movq -0x88(%rbp), %rbx
leaq -0x98(%rbp), %rax
cmpq %rax, %rbx
je 0x14f8
movq 0x2ba7(%rip), %r15      # 0x3fd0
leaq 0xbf2(%rip), %r12       # 0x2022
leaq 0xbf4(%rip), %r13       # 0x202b
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %rsi, %rdx
leaq -0x50(%rbp), %rdi
callq 0x163e
movq 0x40(%rbx), %rax
movq %rax, -0x30(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r15, %rdi
callq 0x1110
movq %rax, %r14
movl $0x8, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1110
movq -0x30(%rbp), %rsi
movq %r14, %rdi
callq 0x1080
movq %rax, %r14
movl $0x6, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x1110
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x14dd
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10f0
movq %rbx, %rdi
callq 0x1120
movq %rax, %rbx
leaq -0x98(%rbp), %rax
cmpq %rax, %rbx
jne 0x1437
movq -0x88(%rbp), %rbx
cmpq %rax, %rbx
je 0x15a2
movq 0x2ac1(%rip), %r14      # 0x3fd0
leaq 0xb0c(%rip), %r15       # 0x2022
leaq 0xb0e(%rip), %r12       # 0x202b
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x1110
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1110
movq 0x40(%rbx), %rsi
movq %r13, %rdi
callq 0x1080
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1110
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r13, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq %rbx, %rdi
callq 0x1120
movq %rax, %rbx
leaq -0x98(%rbp), %rax
cmpq %rax, %rbx
jne 0x151d
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x15bb
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x10f0
leaq -0xa0(%rbp), %rdi
callq 0x16d8
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1600
jmp 0x1600
jmp 0x15e2
jmp 0x1600
jmp 0x1600
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x1603
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10f0
jmp 0x1603
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x161c
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x10f0
leaq -0xa0(%rbp), %rdi
callq 0x16d8
movq %rbx, %rdi
callq 0x1170