// File: iZhangHui[P]CppPrimer/CH15_ObjectOrientedProgramming/examples/Query.cc
// Function: NotQuery::eval(TextQuery const&) const
QueryResult
NotQuery::eval(const TextQuery& text) const
{
    // virtual call to eval through the Query operand 
    auto result = query.eval(text);

	// start out with an empty result set
    auto ret_lines = make_shared<set<line_no>>();

	// we have to iterate through the lines on which our operand appears
	auto beg = result.begin(), end = result.end();

    // for each line in the input file, if that line is not in result,
    // add that line number to ret_lines
	auto sz = result.get_file()->size();
    for (size_t n = 0; n != sz; ++n) {
		// if we haven't processed all the lines in result
		// check whether this line is present
		if (beg == end || *beg != n) 
			ret_lines->insert(n);  // if not in result, add this line 
		else if (beg != end) 
			++beg; // otherwise get the next line number in result if there is one
	}
	return QueryResult(rep(), ret_lines, result.get_file());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x110(%rbp)
movq %rdi, %rax
movq %rax, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x100(%rbp)
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x3e80
leaq -0x68(%rbp), %rdi
callq 0x3ed0
jmp 0x362f
leaq -0x58(%rbp), %rdi
callq 0x3f40
movq %rax, -0x118(%rbp)
jmp 0x3641
movq -0x118(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3f70
movq %rax, -0x120(%rbp)
jmp 0x365e
movq -0x120(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3fa0
jmp 0x367e
leaq -0xa0(%rbp), %rdi
callq 0x3fd0
movq %rax, %rdi
callq 0x3ff0
movq %rax, -0x128(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4010
movq -0x128(%rbp), %rax
movq %rax, -0x90(%rbp)
movq $0x0, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
cmpq -0x90(%rbp), %rax
je 0x379a
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x4030
testb $0x1, %al
jne 0x36fb
leaq -0x80(%rbp), %rdi
callq 0x4060
movq (%rax), %rax
cmpq -0xa8(%rbp), %rax
je 0x3760
leaq -0x68(%rbp), %rdi
callq 0x4090
movq %rax, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x40b0
movb %dl, -0x131(%rbp)
movq %rax, -0x130(%rbp)
jmp 0x3722
movb -0x131(%rbp), %al
movq -0x130(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movb %al, -0xb0(%rbp)
jmp 0x3781
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3885
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x387c
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x4100
testb $0x1, %al
jne 0x3776
jmp 0x377f
leaq -0x80(%rbp), %rdi
callq 0x4130
jmp 0x3781
jmp 0x3783
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0x36be
movq -0x100(%rbp), %rsi
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0xd8(%rbp), %rdi
callq *%rax
jmp 0x37b3
leaq -0xe8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x4160
leaq -0xf8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3fa0
jmp 0x37d5
movq -0x110(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
leaq -0xf8(%rbp), %rcx
callq 0x4190
jmp 0x37f8
leaq -0xf8(%rbp), %rdi
callq 0x4010
leaq -0xe8(%rbp), %rdi
callq 0x41f0
leaq -0xd8(%rbp), %rdi
callq 0x3160
leaq -0x68(%rbp), %rdi
callq 0x41f0
leaq -0x58(%rbp), %rdi
callq 0x4210
movq -0x108(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3864
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x4010
leaq -0xe8(%rbp), %rdi
callq 0x41f0
leaq -0xd8(%rbp), %rdi
callq 0x3160
leaq -0x68(%rbp), %rdi
callq 0x41f0
leaq -0x58(%rbp), %rdi
callq 0x4210
movq -0x70(%rbp), %rdi
callq 0x3370
nopw (%rax,%rax)