// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x80, %rsp
leaq -0x88(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x1be7(%rip), %rsi      # 0x4004
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x2070
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2824
movq $0x1, (%rax)
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq 0x1bb3(%rip), %rsi      # 0x4004
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x2070
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2824
movq (%rax), %rsi
movq 0x3b60(%rip), %rdi      # 0x5fd8
callq 0x20c0
movq %rax, %rdi
callq 0x20a0
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq 0x1b6f(%rip), %rsi      # 0x4004
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x2070
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2824
incq (%rax)
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq 0x1b3f(%rip), %rsi      # 0x4004
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x2070
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2824
movq (%rax), %rsi
movq 0x3aec(%rip), %rdi      # 0x5fd8
callq 0x20c0
movq %rax, %rdi
callq 0x20a0
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2170
leaq -0x38(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x90(%rbp), %rdi
callq 0x2dc6
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2170
leaq -0x38(%rbp), %rsi
movl $0x1, 0x20(%rsi)
leaq -0x90(%rbp), %rdi
callq 0x2f2e
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2170
leaq -0x38(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x90(%rbp), %rdi
callq 0x3000
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2170
leaq -0x38(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x90(%rbp), %rdi
callq 0x2dc6
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2170
leaq -0x38(%rbp), %rsi
movq $0x1, 0x20(%rsi)
leaq -0x90(%rbp), %rdi
callq 0x2dc6
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq -0x3c(%rbp), %rdx
movl $0x1, (%rdx)
leaq 0x19fc(%rip), %rsi      # 0x4004
leaq -0x38(%rbp), %rdi
callq 0x288e
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2dc6
movq %rax, %rbx
movl %edx, %r14d
leaq -0x38(%rbp), %rdi
callq 0x2090
testb %r14b, %r14b
jne 0x2639
incq 0x40(%rbx)
leaq 0x19c4(%rip), %rsi      # 0x4004
leaq -0x38(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
callq 0x2070
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2824
movq (%rax), %rsi
movq 0x3971(%rip), %rdi      # 0x5fd8
callq 0x20c0
movq %rax, %rdi
callq 0x20a0
leaq -0x38(%rbp), %rdi
callq 0x2090
movq -0x78(%rbp), %rbx
leaq 0x20(%rbx), %rsi
movq 0x394c(%rip), %rdi      # 0x5fd8
callq 0x2100
movq 0x3940(%rip), %rdi      # 0x5fd8
leaq 0x196a(%rip), %rsi      # 0x4009
callq 0x2110
movq 0x40(%rbx), %rsi
movq %rax, %rdi
callq 0x20c0
incq 0x40(%rbx)
leaq -0x60(%rbp), %rdi
callq 0x2090
leaq -0x90(%rbp), %rdi
callq 0x2958
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x2700
jmp 0x2705
jmp 0x2700
jmp 0x2705
jmp 0x2700
jmp 0x2705
jmp 0x2700
jmp 0x2705
jmp 0x2700
jmp 0x2705
jmp 0x2700
jmp 0x2705
jmp 0x2700
jmp 0x26fb
jmp 0x2719
jmp 0x26fb
jmp 0x26fb
jmp 0x2719
movq %rax, %rbx
jmp 0x2725
movq %rax, %rbx
jmp 0x2711
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq -0x60(%rbp), %rdi
jmp 0x2720
jmp 0x2719
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x2090
leaq -0x90(%rbp), %rdi
callq 0x2958
movq %rbx, %rdi
callq 0x21d0
nop