// File: iZhangHui[P]CppPrimer/CH12_DynamicMemory/examples/TextQuery.cc
// Function: TextQuery::query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) const
QueryResult
TextQuery::query(const string& sought) const
{
	// we'll return a pointer to this set if we don't find sought
	static shared_ptr<set<line_no>> nodata(new set<line_no>);

    // use find and not a subscript to avoid adding words to wm!
    auto loc = wm.find(cleanup_str(sought));

	if (loc == wm.end())
		return QueryResult(sought, nodata, file);  // not found
	else
		return QueryResult(sought, loc->second, file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0xf0(%rbp)
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpb $0x0, 0xb14e(%rip)      # 0x13228
jne 0x8147
leaq 0xb145(%rip), %rdi      # 0x13228
callq 0x3390
cmpl $0x0, %eax
je 0x8147
movl $0x30, %edi
callq 0x3230
movq %rax, -0xf8(%rbp)
jmp 0x8100
movq -0xf8(%rbp), %rdi
callq 0x57f0
movq -0xf8(%rbp), %rsi
leaq 0xb0fe(%rip), %rdi      # 0x13218
callq 0x8b40
jmp 0x8121
leaq -0x3f38(%rip), %rdi     # 0x41f0
leaq 0xb0e9(%rip), %rsi      # 0x13218
leaq 0xb0c2(%rip), %rdx      # 0x131f8
callq 0x31f0
leaq 0xb0e6(%rip), %rdi      # 0x13228
callq 0x31a0
movq -0xe0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x7fc0
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rsi
callq 0x8b70
movq %rax, -0x100(%rbp)
jmp 0x8189
movq -0x100(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3160
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0x8bd0
movq %rax, -0x58(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x8ba0
testb $0x1, %al
jne 0x81c7
jmp 0x82c1
movq -0x18(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x30f0
leaq 0xb036(%rip), %rsi      # 0x13218
leaq -0x88(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x4160
movq -0xe0(%rbp), %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x4990
movq -0xf0(%rbp), %rdi
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
movq -0x118(%rbp), %rcx
callq 0x4190
jmp 0x8232
leaq -0x98(%rbp), %rdi
callq 0x4010
leaq -0x88(%rbp), %rdi
callq 0x41f0
leaq -0x78(%rbp), %rdi
callq 0x3160
jmp 0x8390
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq 0xafbd(%rip), %rdi      # 0x13228
callq 0x3190
jmp 0x83a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3160
jmp 0x83a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4010
leaq -0x88(%rbp), %rdi
callq 0x41f0
leaq -0x78(%rbp), %rdi
callq 0x3160
jmp 0x83a0
movq -0x18(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x30f0
leaq -0x30(%rbp), %rdi
callq 0x8c00
movq %rax, %rsi
addq $0x20, %rsi
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x4160
movq -0xe0(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x4990
movq -0xf0(%rbp), %rdi
movq -0x140(%rbp), %rsi
movq -0x138(%rbp), %rdx
movq -0x130(%rbp), %rcx
callq 0x4190
jmp 0x8338
leaq -0xd8(%rbp), %rdi
callq 0x4010
leaq -0xc8(%rbp), %rdi
callq 0x41f0
leaq -0xb8(%rbp), %rdi
callq 0x3160
jmp 0x8390
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4010
leaq -0xc8(%rbp), %rdi
callq 0x41f0
leaq -0xb8(%rbp), %rdi
callq 0x3160
jmp 0x83a0
movq -0xe8(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x3370
nopl (%rax)