// File: iZhangHui[P]CppPrimer/CH12_DynamicMemory/exercises/ex12_32.cc
// Function: TextQuery::TextQuery(std::basic_ifstream<char, std::char_traits<char>>&)
TextQuery::TextQuery(ifstream& is)
{
	string text;
	while (getline(is, text)) {
		file.push_back(text);
		int n = file.size() - 1;
		istringstream line(text);
		string word;
		while (line >> word) {
			word = clean_str(word);
			/**
			 * if the key is not already present,
			 * a new element is created and inserted
			 * into the map for that key.
			*/
			auto& lines = wm[word];
			if (!lines)
				lines.reset(new set<line_no>);
			lines->insert(n);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x47a0
movq -0x230(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0x228(%rbp)
callq 0x47c0
leaq -0x30(%rbp), %rdi
callq 0x32b0
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3050
movq %rax, -0x238(%rbp)
jmp 0x3e99
movq -0x238(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3280
movb %al, -0x239(%rbp)
jmp 0x3eb7
movb -0x239(%rbp), %al
testb $0x1, %al
jne 0x3ec6
jmp 0x40d4
movq -0x230(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x47e0
jmp 0x3ed8
movq -0x230(%rbp), %rdi
callq 0x4810
movq %rax, -0x248(%rbp)
jmp 0x3eed
movq -0x248(%rbp), %rax
decl %eax
movl %eax, -0x40(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x8, %edx
callq 0x3320
jmp 0x3f10
leaq -0x1e0(%rbp), %rdi
callq 0x32b0
leaq -0x1c0(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x3290
movq %rax, -0x250(%rbp)
jmp 0x3f38
movq -0x250(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3280
movb %al, -0x251(%rbp)
jmp 0x3f56
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0x3f65
jmp 0x40b7
leaq -0x200(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x4110
jmp 0x3f7a
leaq -0x1e0(%rbp), %rdi
movq %rdi, -0x268(%rbp)
leaq -0x200(%rbp), %rsi
movq %rsi, -0x270(%rbp)
callq 0x3270
movq -0x270(%rbp), %rdi
callq 0x3140
movq -0x230(%rbp), %rdi
movq -0x268(%rbp), %rsi
addq $0x10, %rdi
callq 0x4840
movq %rax, -0x260(%rbp)
jmp 0x3fc7
movq -0x260(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rdi
callq 0x4920
testb $0x1, %al
jne 0x4063
movq -0x208(%rbp), %rax
movq %rax, -0x280(%rbp)
movl $0x30, %edi
callq 0x3200
movq %rax, -0x278(%rbp)
jmp 0x4006
movq -0x278(%rbp), %rdi
callq 0x4990
movq -0x280(%rbp), %rdi
movq -0x278(%rbp), %rsi
callq 0x4940
jmp 0x4027
jmp 0x4063
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x40e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x3140
leaq -0x1c0(%rbp), %rdi
callq 0x30f0
jmp 0x40e6
movq -0x208(%rbp), %rdi
callq 0x49b0
movq %rax, %rdi
movslq -0x40(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x210(%rbp), %rsi
callq 0x49d0
movb %dl, -0x289(%rbp)
movq %rax, -0x288(%rbp)
jmp 0x4098
movb -0x289(%rbp), %al
movq -0x288(%rbp), %rcx
movq %rcx, -0x220(%rbp)
movb %al, -0x218(%rbp)
jmp 0x3f1c
leaq -0x1e0(%rbp), %rdi
callq 0x3140
leaq -0x1c0(%rbp), %rdi
callq 0x30f0
jmp 0x3e83
leaq -0x30(%rbp), %rdi
callq 0x3140
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x3140
movq -0x228(%rbp), %rdi
callq 0x3aa0
movq -0x230(%rbp), %rdi
callq 0x3870
movq -0x38(%rbp), %rdi
callq 0x3340