// File: iZhangHui[P]CppPrimer/CH12_DynamicMemory/exercises/ex12_27_30.cc
// Function: TextQuery::TextQuery(std::basic_ifstream<char, std::char_traits<char>>&)
TextQuery::TextQuery(ifstream& is) : file(new vector<string>)
{
	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), %rax
movq %rax, -0x230(%rbp)
movl $0x18, %edi
callq 0x21c0
movq %rax, %rdi
movq %rdi, -0x238(%rbp)
callq 0x3720
movq -0x238(%rbp), %rsi
movq -0x230(%rbp), %rdi
callq 0x3740
movq -0x230(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0x228(%rbp)
callq 0x3770
leaq -0x30(%rbp), %rdi
callq 0x2250
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2050
movq %rax, -0x240(%rbp)
jmp 0x2e10
movq -0x240(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2230
movb %al, -0x241(%rbp)
jmp 0x2e2e
movb -0x241(%rbp), %al
testb $0x1, %al
jne 0x2e3d
jmp 0x304b
movq -0x230(%rbp), %rdi
callq 0x3790
movq %rax, %rdi
leaq -0x30(%rbp), %rsi
callq 0x37b0
jmp 0x2e57
movq -0x230(%rbp), %rdi
callq 0x3790
movq %rax, %rdi
callq 0x3820
decl %eax
movl %eax, -0x40(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x8, %edx
callq 0x22b0
jmp 0x2e87
leaq -0x1e0(%rbp), %rdi
callq 0x2250
leaq -0x1c0(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x2240
movq %rax, -0x250(%rbp)
jmp 0x2eaf
movq -0x250(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2230
movb %al, -0x251(%rbp)
jmp 0x2ecd
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0x2edc
jmp 0x302e
leaq -0x200(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x3090
jmp 0x2ef1
leaq -0x1e0(%rbp), %rdi
movq %rdi, -0x268(%rbp)
leaq -0x200(%rbp), %rsi
movq %rsi, -0x270(%rbp)
callq 0x2220
movq -0x270(%rbp), %rdi
callq 0x2110
movq -0x230(%rbp), %rdi
movq -0x268(%rbp), %rsi
addq $0x10, %rdi
callq 0x3840
movq %rax, -0x260(%rbp)
jmp 0x2f3e
movq -0x260(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rdi
callq 0x3920
testb $0x1, %al
jne 0x2fda
movq -0x208(%rbp), %rax
movq %rax, -0x280(%rbp)
movl $0x30, %edi
callq 0x21c0
movq %rax, -0x278(%rbp)
jmp 0x2f7d
movq -0x278(%rbp), %rdi
callq 0x3990
movq -0x280(%rbp), %rdi
movq -0x278(%rbp), %rsi
callq 0x3940
jmp 0x2f9e
jmp 0x2fda
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x305d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x2110
leaq -0x1c0(%rbp), %rdi
callq 0x20e0
jmp 0x305d
movq -0x208(%rbp), %rdi
callq 0x39b0
movq %rax, %rdi
movslq -0x40(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x210(%rbp), %rsi
callq 0x39d0
movb %dl, -0x289(%rbp)
movq %rax, -0x288(%rbp)
jmp 0x300f
movb -0x289(%rbp), %al
movq -0x288(%rbp), %rcx
movq %rcx, -0x220(%rbp)
movb %al, -0x218(%rbp)
jmp 0x2e93
leaq -0x1e0(%rbp), %rdi
callq 0x2110
leaq -0x1c0(%rbp), %rdi
callq 0x20e0
jmp 0x2dfa
leaq -0x30(%rbp), %rdi
callq 0x2110
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x2110
movq -0x228(%rbp), %rdi
callq 0x29f0
movq -0x230(%rbp), %rdi
callq 0x27e0
movq -0x38(%rbp), %rdi
callq 0x22c0
nopw (%rax,%rax)