// File: iZhangHui[P]CppPrimer/CH12_DynamicMemory/examples/TextQuery.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)) {       // for each line in the file
		file->push_back(text);        // remember this line of text
		int n = file->size() - 1;     // the current line number
		istringstream line(text);     // separate the line into words
		string word;
		while (line >> word) {        // for each word in that line
            word = cleanup_str(word);
            // if word isn't already in wm, subscripting adds a new entry
            auto& lines = wm[word]; // lines is a shared_ptr
            if (!lines) // that pointer is null the first time we see word
                lines.reset(new set<line_no>); // allocate a new set
            lines->insert(n);      // insert this line number
		}
	}
}

// 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 0x3230
movq %rax, %rdi
movq %rdi, -0x238(%rbp)
callq 0x8840
movq -0x238(%rbp), %rsi
movq -0x230(%rbp), %rdi
callq 0x8860
movq -0x230(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0x228(%rbp)
callq 0x8890
leaq -0x30(%rbp), %rdi
callq 0x32e0
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3060
movq %rax, -0x240(%rbp)
jmp 0x7d40
movq -0x240(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x32b0
movb %al, -0x241(%rbp)
jmp 0x7d5e
movb -0x241(%rbp), %al
testb $0x1, %al
jne 0x7d6d
jmp 0x7f7b
movq -0x230(%rbp), %rdi
callq 0x3fd0
movq %rax, %rdi
leaq -0x30(%rbp), %rsi
callq 0x88b0
jmp 0x7d87
movq -0x230(%rbp), %rdi
callq 0x3fd0
movq %rax, %rdi
callq 0x3ff0
decl %eax
movl %eax, -0x40(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x8, %edx
callq 0x3350
jmp 0x7db7
leaq -0x1e0(%rbp), %rdi
callq 0x32e0
leaq -0x1c0(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x32c0
movq %rax, -0x250(%rbp)
jmp 0x7ddf
movq -0x250(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x32b0
movb %al, -0x251(%rbp)
jmp 0x7dfd
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0x7e0c
jmp 0x7f5e
leaq -0x200(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x7fc0
jmp 0x7e21
leaq -0x1e0(%rbp), %rdi
movq %rdi, -0x268(%rbp)
leaq -0x200(%rbp), %rsi
movq %rsi, -0x270(%rbp)
callq 0x32a0
movq -0x270(%rbp), %rdi
callq 0x3160
movq -0x230(%rbp), %rdi
movq -0x268(%rbp), %rsi
addq $0x10, %rdi
callq 0x8920
movq %rax, -0x260(%rbp)
jmp 0x7e6e
movq -0x260(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rdi
callq 0x8a00
testb $0x1, %al
jne 0x7f0a
movq -0x208(%rbp), %rax
movq %rax, -0x280(%rbp)
movl $0x30, %edi
callq 0x3230
movq %rax, -0x278(%rbp)
jmp 0x7ead
movq -0x278(%rbp), %rdi
callq 0x57f0
movq -0x280(%rbp), %rdi
movq -0x278(%rbp), %rsi
callq 0x8a20
jmp 0x7ece
jmp 0x7f0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x7f8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x3160
leaq -0x1c0(%rbp), %rdi
callq 0x3110
jmp 0x7f8d
movq -0x208(%rbp), %rdi
callq 0x4090
movq %rax, %rdi
movslq -0x40(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x210(%rbp), %rsi
callq 0x8a70
movb %dl, -0x289(%rbp)
movq %rax, -0x288(%rbp)
jmp 0x7f3f
movb -0x289(%rbp), %al
movq -0x288(%rbp), %rcx
movq %rcx, -0x220(%rbp)
movb %al, -0x218(%rbp)
jmp 0x7dc3
leaq -0x1e0(%rbp), %rdi
callq 0x3160
leaq -0x1c0(%rbp), %rdi
callq 0x3110
jmp 0x7d2a
leaq -0x30(%rbp), %rdi
callq 0x3160
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x3160
movq -0x228(%rbp), %rdi
callq 0x7920
movq -0x230(%rbp), %rdi
callq 0x4010
movq -0x38(%rbp), %rdi
callq 0x3370
nopw (%rax,%rax)