// File: /workspace/github_cpp_makefile_star2_O3/iZhangHui[P]CppPrimer/CH11_AssociativeContainers/examples/map1.cc
// Function: main
int main()
{
	map <string, size_t> word_count; // empty map

	// insert a value-initialized element with key Anna;
	// assign 1 to the value of that element
	word_count["Anna"] = 1;

	// fetch the element indexed by Anna; prints 1
	cout << word_count["Anna"] << endl;

	++word_count["Anna"];        // fetch the element and add 1 to it
	cout << word_count["Anna"] << endl; // prints 2

	// various ways to add word to word_count
	string word;
	word_count.insert({word, 1});
	word_count.insert(make_pair(word, 1));
	word_count.insert(pair<string, size_t>(word, 1));
	word_count.insert(map<string, size_t>::value_type(word, 1));

	typedef map<string,size_t>::value_type valType;
	word_count.insert(valType(word, 1));

	// use value returned by insert
	pair<map<string, size_t>::iterator, bool> insert_ret;

	// if Anna not already in word_count, insert it with value 1
	insert_ret = word_count.insert({"Anna", 1});

	if (insert_ret.second == false)    // Anna was already in the map
		insert_ret.first->second++;    // increment current value
	cout << word_count["Anna"] << endl;

	// get an iterator to an element in word_count
	auto map_it = word_count.begin();

	// *map_it is a reference to a pair<const string, size_t> object
	cout << map_it->first;         // prints the key for this element
	cout << " " << map_it->second; // prints the value of the element
	++map_it->second;     // ok: we can change the value through an iterator
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
leaq -0x90(%rbp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1be7(%rip), %rsi      # 0x4004
leaq 0x1be4(%rip), %rdx      # 0x4008
leaq -0x48(%rbp), %rdi
callq 0x2d06
leaq -0x98(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2aba
movq $0x1, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2459
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x1b9d(%rip), %rsi      # 0x4004
leaq 0x1b9a(%rip), %rdx      # 0x4008
callq 0x2d06
leaq -0x98(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2aba
movq (%rax), %rsi
movq 0x3b4b(%rip), %rdi      # 0x5fd8
callq 0x20a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2100
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x24d1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x1b25(%rip), %rsi      # 0x4004
leaq 0x1b22(%rip), %rdx      # 0x4008
callq 0x2d06
leaq -0x98(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2aba
incq (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2513
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x1ae3(%rip), %rsi      # 0x4004
leaq 0x1ae0(%rip), %rdx      # 0x4008
callq 0x2d06
leaq -0x98(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2aba
movq (%rax), %rsi
movq 0x3a91(%rip), %rdi      # 0x5fd8
callq 0x20a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2100
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x258b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x58(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq $0x0, -0x8(%rbx)
movb $0x0, (%rbx)
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x2b48
leaq -0x48(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x98(%rbp), %rdi
callq 0x30e2
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x25dd
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
callq 0x2b48
leaq -0x48(%rbp), %rsi
movl $0x1, 0x20(%rsi)
leaq -0x98(%rbp), %rdi
callq 0x3222
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2620
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
callq 0x2b48
leaq -0x48(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x98(%rbp), %rdi
callq 0x330e
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2664
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
callq 0x2b48
leaq -0x48(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x98(%rbp), %rdi
callq 0x30e2
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x26a8
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
callq 0x2b48
leaq -0x48(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x98(%rbp), %rdi
callq 0x30e2
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x26ec
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x190a(%rip), %rsi      # 0x4004
leaq 0x1907(%rip), %rdx      # 0x4008
callq 0x2d06
leaq -0x48(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x98(%rbp), %rdi
callq 0x30e2
movq %rax, %r14
movl %edx, %r15d
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2739
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
testb %r15b, %r15b
jne 0x2742
incq 0x40(%r14)
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x18b4(%rip), %rsi      # 0x4004
leaq 0x18b1(%rip), %rdx      # 0x4008
callq 0x2d06
leaq -0x98(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2aba
movq (%rax), %rsi
movq 0x3862(%rip), %rdi      # 0x5fd8
callq 0x20a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2100
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x27ba
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
movq -0x80(%rbp), %r14
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq 0x380b(%rip), %rdi      # 0x5fd8
callq 0x2140
movq 0x37ff(%rip), %rdi      # 0x5fd8
leaq 0x1829(%rip), %rsi      # 0x4009
movl $0x1, %edx
callq 0x2140
movq 0x40(%r14), %rsi
movq 0x37e3(%rip), %rdi      # 0x5fd8
callq 0x20a0
incq 0x40(%r14)
movq -0x68(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2813
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x98(%rbp), %rdi
callq 0x2c76
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x285a
jmp 0x285f
jmp 0x285a
jmp 0x285f
jmp 0x285a
jmp 0x285f
jmp 0x285a
jmp 0x285f
jmp 0x285a
jmp 0x285f
jmp 0x285a
jmp 0x285f
jmp 0x285a
jmp 0x2855
jmp 0x2888
jmp 0x2855
jmp 0x2855
jmp 0x2888
movq %rax, %r14
jmp 0x28a0
movq %rax, %r14
jmp 0x2877
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2877
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
movq -0x68(%rbp), %rdi
cmpq %rbx, %rdi
je 0x28a0
movq -0x58(%rbp), %rsi
jmp 0x2898
jmp 0x2888
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x28a0
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x98(%rbp), %rdi
callq 0x2c76
movq %r14, %rdi
callq 0x21b0