// File: /workspace/github_cpp_makefile_star2_O3/iZhangHui[P]CppPrimer/CH11_AssociativeContainers/examples/word_transform.cc
// Function: word_transform(std::basic_ifstream<char, std::char_traits<char>>&, std::basic_ifstream<char, std::char_traits<char>>&)
void word_transform(ifstream& map_file, ifstream& input)
{
	auto trans_map = buildMap(map_file); // store the transformations

	// for debugging purposes print the map after its built
	cout << "Here is our transformation map: \n\n";
	for (auto entry : trans_map)
		cout << "key: "   << entry.first
			 << "\tvalue: " << entry.second << endl;
	cout << "\n\n";

	// do the transformation of the given text
	string text;                    // hold each line from the input
	while (getline(input, text)) {  // read a line of input
		istringstream stream(text); // read each word
		string word;
		bool firstword = true;      // controls whether a space is printed
		while (stream >> word) {
			if (firstword)
				firstword = false;
			else
				cout << " ";  // print a space between words
			// transform returns its first argument or its transformation
			cout << transform(word, trans_map); // print the output
		}
		cout << endl;        // done with this line of input
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rsi, -0x30(%rbp)
movq %rdi, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x23cc
movq 0x3976(%rip), %rdi      # 0x5fd0
leaq 0x19b0(%rip), %rsi      # 0x4011
movl $0x22, %edx
callq 0x21a0
leaq -0x98(%rbp), %rax
movq 0x10(%rax), %r12
cmpq %rax, %r12
je 0x277a
leaq -0x210(%rbp), %rbx
movq 0x3943(%rip), %r15      # 0x5fd0
leaq 0x19a6(%rip), %r13      # 0x403a
leaq 0x20(%r12), %rsi
leaq -0x220(%rbp), %rdi
callq 0x2c54
movl $0x5, %edx
movq %r15, %rdi
leaq 0x1980(%rip), %rsi      # 0x4034
callq 0x21a0
movq -0x220(%rbp), %rsi
movq -0x218(%rbp), %rdx
movq %r15, %rdi
callq 0x21a0
movq %rax, %r14
movl $0x8, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x21a0
movq -0x200(%rbp), %rsi
movq -0x1f8(%rbp), %rdx
movq %r14, %rdi
callq 0x21a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq -0x200(%rbp), %rdi
leaq -0x1f0(%rbp), %rax
cmpq %rax, %rdi
je 0x2744
movq -0x1f0(%rbp), %rsi
incq %rsi
callq 0x2170
movq -0x220(%rbp), %rdi
cmpq %rbx, %rdi
je 0x275f
movq -0x210(%rbp), %rsi
incq %rsi
callq 0x2170
movq %r12, %rdi
callq 0x2100
movq %rax, %r12
leaq -0x98(%rbp), %rax
cmpq %rax, %r12
jne 0x2694
movq 0x384f(%rip), %r15      # 0x5fd0
leaq 0x18a9(%rip), %rsi      # 0x4031
movl $0x2, %edx
movq %r15, %rdi
callq 0x21a0
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x220(%rbp), %r13
leaq -0x50(%rbp), %r14
leaq -0xa0(%rbp), %r12
movq -0x30(%rbp), %rbx
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %edx
movq %rbx, %rdi
leaq -0x70(%rbp), %rsi
callq 0x2280
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x28eb
movq %r13, %rdi
leaq -0x70(%rbp), %rsi
movl $0x8, %edx
callq 0x2230
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
movb $0x1, %bl
movq %r13, %rdi
movq %r14, %rsi
callq 0x21c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2887
testb $0x1, %bl
jne 0x284c
movl $0x1, %edx
movq %r15, %rdi
leaq 0x17fa(%rip), %rsi      # 0x4041
callq 0x21a0
movq %r12, %rdi
movq %r14, %rsi
callq 0x31fa
leaq 0x40(%rax), %rcx
leaq 0x48(%rax), %rdx
leaq -0x98(%rbp), %rsi
cmpq %rsi, %rax
cmoveq %r14, %rcx
movq (%rcx), %rsi
leaq -0x48(%rbp), %rax
cmoveq %rax, %rdx
movq (%rdx), %rdx
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x21a0
jmp 0x281a
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
movq -0x30(%rbp), %rbx
je 0x28cb
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2170
movq %r13, %rdi
movq 0x36eb(%rip), %rsi      # 0x5fc0
callq 0x21d0
leaq -0x1a8(%rbp), %rdi
callq 0x20a0
jmp 0x27be
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x2904
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2170
leaq -0xa0(%rbp), %rdi
callq 0x2d14
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2924
movq %rax, %rbx
jmp 0x2997
jmp 0x292b
movq %rax, %rbx
jmp 0x297e
jmp 0x2943
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0x2cc0
jmp 0x2997
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x295f
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2170
movq 0x365a(%rip), %rsi      # 0x5fc0
leaq -0x220(%rbp), %rdi
callq 0x21d0
leaq -0x1a8(%rbp), %rdi
callq 0x20a0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x2997
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2170
leaq -0xa0(%rbp), %rdi
callq 0x2d14
movq %rbx, %rdi
callq 0x2250