// File: /workspace/github_cpp_makefile_star2_O1/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 0x3973(%rip), %rdi      # 0x5fd0
leaq 0x19ad(%rip), %rsi      # 0x4011
movl $0x22, %edx
callq 0x21a0
leaq -0x98(%rbp), %rax
movq 0x10(%rax), %r12
cmpq %rax, %r12
je 0x277d
leaq -0x210(%rbp), %rbx
movq 0x3940(%rip), %r15      # 0x5fd0
leaq 0x19a3(%rip), %r13      # 0x403a
leaq 0x20(%r12), %rsi
leaq -0x220(%rbp), %rdi
callq 0x2c5a
movl $0x5, %edx
movq %r15, %rdi
leaq 0x197d(%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 0x2747
movq -0x1f0(%rbp), %rsi
incq %rsi
callq 0x2170
movq -0x220(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2762
movq -0x210(%rbp), %rsi
incq %rsi
callq 0x2170
movq %r12, %rdi
callq 0x2100
movq %rax, %r12
leaq -0x98(%rbp), %rax
cmpq %rax, %r12
jne 0x2697
movq 0x384c(%rip), %r14      # 0x5fd0
leaq 0x18a6(%rip), %rsi      # 0x4031
movl $0x2, %edx
movq %r14, %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), %r15
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 0x28f0
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 %r15, %rsi
callq 0x21c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x288c
testb $0x1, %bl
je 0x283f
xorl %ebx, %ebx
jmp 0x2853
movl $0x1, %edx
movq %r14, %rdi
leaq 0x17f3(%rip), %rsi      # 0x4041
callq 0x21a0
movq %r12, %rdi
movq %r15, %rsi
callq 0x3206
leaq 0x40(%rax), %rcx
leaq 0x48(%rax), %rdx
leaq -0x98(%rbp), %rsi
cmpq %rsi, %rax
cmoveq %r15, %rcx
movq (%rcx), %rsi
leaq -0x48(%rbp), %rax
cmoveq %rax, %rdx
movq (%rdx), %rdx
movq %r14, %rdi
callq 0x21a0
jmp 0x281d
movq (%r14), %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 -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
movq -0x30(%rbp), %rbx
je 0x28d0
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2170
movq %r13, %rdi
movq 0x36e6(%rip), %rsi      # 0x5fc0
callq 0x21d0
leaq -0x1a8(%rbp), %rdi
callq 0x20a0
jmp 0x27c1
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x2909
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2170
leaq -0xa0(%rbp), %rdi
callq 0x2d1a
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2929
movq %rax, %rbx
jmp 0x299c
jmp 0x2930
movq %rax, %rbx
jmp 0x2983
jmp 0x2948
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0x2cc6
jmp 0x299c
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x2964
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2170
movq 0x3655(%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 0x299c
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2170
leaq -0xa0(%rbp), %rdi
callq 0x2d1a
movq %rbx, %rdi
callq 0x2250