// File: iZhangHui[P]CppPrimer/CH15_ObjectOrientedProgramming/examples/Query.cc
// Function: AndQuery::eval(TextQuery const&) const
QueryResult
AndQuery::eval(const TextQuery& text) const
{
    // virtual calls through the Query operands to get result sets for the operands
    auto left = lhs.eval(text), right = rhs.eval(text);

	// set to hold the intersection of left and right
    auto ret_lines = make_shared<set<line_no>>();  

    // writes the intersection of two ranges to a destination iterator
    // destination iterator in this call adds elements to ret
    set_intersection(left.begin(), left.end(), 
                   right.begin(), right.end(),
                   inserter(*ret_lines, ret_lines->begin()));
    return QueryResult(rep(), ret_lines, left.get_file());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x158(%rbp)
movq %rdi, %rax
movq %rax, -0x150(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x148(%rbp)
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3e80
movq -0x148(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
leaq -0x98(%rbp), %rdi
callq 0x3e80
jmp 0x3901
leaq -0xb8(%rbp), %rdi
callq 0x3ed0
jmp 0x390f
leaq -0x58(%rbp), %rdi
callq 0x3f40
movq %rax, -0x160(%rbp)
jmp 0x3921
movq -0x160(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3f70
movq %rax, -0x168(%rbp)
jmp 0x3941
movq -0x168(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x3f40
movq %rax, -0x170(%rbp)
jmp 0x3964
movq -0x170(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x3f70
movq %rax, -0x178(%rbp)
jmp 0x3987
movq -0x178(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x4320
movq -0x198(%rbp), %rdi
movq %rax, -0x190(%rbp)
callq 0x4090
movq %rax, %rdi
callq 0x4350
movq -0x190(%rbp), %rdi
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rsi
callq 0x42e0
movq %rdx, -0x188(%rbp)
movq %rax, -0x180(%rbp)
jmp 0x39ed
movq -0x188(%rbp), %rax
movq -0x180(%rbp), %rcx
movq %rcx, -0xe8(%rbp)
movq %rax, -0xe0(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
movq -0xd8(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0xe0(%rbp), %r9
callq 0x4250
movq %rdx, -0x1a8(%rbp)
movq %rax, -0x1a0(%rbp)
jmp 0x3a48
movq -0x148(%rbp), %rsi
movq -0x1a8(%rbp), %rax
movq -0x1a0(%rbp), %rcx
movq %rcx, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x120(%rbp), %rdi
callq *%rax
jmp 0x3a7d
leaq -0x130(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4160
leaq -0x140(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3fa0
jmp 0x3aa2
movq -0x158(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x130(%rbp), %rdx
leaq -0x140(%rbp), %rcx
callq 0x4190
jmp 0x3ac5
leaq -0x140(%rbp), %rdi
callq 0x4010
leaq -0x130(%rbp), %rdi
callq 0x41f0
leaq -0x120(%rbp), %rdi
callq 0x3160
leaq -0xb8(%rbp), %rdi
callq 0x41f0
leaq -0x98(%rbp), %rdi
callq 0x4210
leaq -0x58(%rbp), %rdi
callq 0x4210
movq -0x150(%rbp), %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x3bbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x3baf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x3ba3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x3b8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x4010
leaq -0x130(%rbp), %rdi
callq 0x41f0
leaq -0x120(%rbp), %rdi
callq 0x3160
leaq -0xb8(%rbp), %rdi
callq 0x41f0
leaq -0x98(%rbp), %rdi
callq 0x4210
leaq -0x58(%rbp), %rdi
callq 0x4210
movq -0xa0(%rbp), %rdi
callq 0x3370