// File: iZhangHui[P]CppPrimer/CH16_TemplatesAndGenericProgramming/exercises/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 will return a pointer to this set if we dont't find sought
	static auto nodata = make_shared<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);
	} 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, 0xbfa6(%rip)      # 0xf1c0
jne 0x3261
leaq 0xbf9d(%rip), %rdi      # 0xf1c0
callq 0x22e0
cmpl $0x0, %eax
je 0x3261
leaq 0xbf7c(%rip), %rdi      # 0xf1b0
callq 0x3ba0
jmp 0x323b
leaq -0xa32(%rip), %rdi      # 0x2810
leaq 0xbf67(%rip), %rsi      # 0xf1b0
leaq 0xbf40(%rip), %rdx      # 0xf190
callq 0x2190
leaq 0xbf64(%rip), %rdi      # 0xf1c0
callq 0x2160
movq -0xe0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x3100
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
callq 0x3c10
movq %rax, -0xf8(%rbp)
jmp 0x32a3
movq -0xf8(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2120
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0x3c70
movq %rax, -0x58(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3c40
testb $0x1, %al
jne 0x32e1
jmp 0x33db
movq -0x18(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x20c0
leaq 0xbeb4(%rip), %rsi      # 0xf1b0
leaq -0x88(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x3ca0
movq -0xe0(%rbp), %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x3cd0
movq -0xf0(%rbp), %rdi
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
movq -0x110(%rbp), %rcx
callq 0x3d00
jmp 0x334c
leaq -0x98(%rbp), %rdi
callq 0x27f0
leaq -0x88(%rbp), %rdi
callq 0x2810
leaq -0x78(%rbp), %rdi
callq 0x2120
jmp 0x34aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq 0xbe3b(%rip), %rdi      # 0xf1c0
callq 0x2150
jmp 0x34ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2120
jmp 0x34ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x27f0
leaq -0x88(%rbp), %rdi
callq 0x2810
leaq -0x78(%rbp), %rdi
callq 0x2120
jmp 0x34ba
movq -0x18(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x20c0
leaq -0x30(%rbp), %rdi
callq 0x3d60
movq %rax, %rsi
addq $0x20, %rsi
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x3ca0
movq -0xe0(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x3cd0
movq -0xf0(%rbp), %rdi
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
movq -0x128(%rbp), %rcx
callq 0x3d00
jmp 0x3452
leaq -0xd8(%rbp), %rdi
callq 0x27f0
leaq -0xc8(%rbp), %rdi
callq 0x2810
leaq -0xb8(%rbp), %rdi
callq 0x2120
jmp 0x34aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x27f0
leaq -0xc8(%rbp), %rdi
callq 0x2810
leaq -0xb8(%rbp), %rdi
callq 0x2120
jmp 0x34ba
movq -0xe8(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x22d0
nopw %cs:(%rax,%rax)