// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/utils/bamtools_filter_engine.h
// Function: bool BamTools::FilterEngine<BamTools::BamAlignmentChecker>::evaluateFilterRules<BamTools::BamAlignment>(BamTools::BamAlignment const&)
bool FilterEngine<FilterChecker>::evaluateFilterRules(const T& query) {
  
    // build ruleQueue if not done before
    if ( !m_isRuleQueueGenerated ) 
        buildRuleQueue();
    
    std::stack<bool> resultStack;
    FilterMap::const_iterator filterIter;
    std::queue<std::string> ruleQueueCopy = m_ruleQueue;
    while ( !ruleQueueCopy.empty() ) {
        const std::string& token = ruleQueueCopy.front();
        
        // token is NOT_OPERATOR
        if ( token == FilterEngine<FilterChecker>::NOT_OPERATOR ) {
            BAMTOOLS_ASSERT_MESSAGE( !resultStack.empty(), "Empty result stack - cannot apply operator: !" );
            resultStack.top() = !resultStack.top();
        }
        
        // token is AND_OPERATOR
        else if ( token == FilterEngine<FilterChecker>::AND_OPERATOR ) {
            BAMTOOLS_ASSERT_MESSAGE( resultStack.size() >= 2 , "Not enough operands - cannot apply operator: &" );
            bool topResult = resultStack.top();
            resultStack.pop();
            resultStack.top() &= topResult;
        }
        
        // token is OR_OPERATOR
        else if ( token == FilterEngine<FilterChecker>::OR_OPERATOR ) {
            BAMTOOLS_ASSERT_MESSAGE( resultStack.size() >= 2 , "Not enough operands - cannot apply operator: |" );
            bool topResult = resultStack.top();
            resultStack.pop();
            resultStack.top() |= topResult;
        }
        
        // token is an operand 
        else {
            // look up PropertyFilter that matches this token 
            filterIter = m_filters.find(token);
            BAMTOOLS_ASSERT_MESSAGE( (filterIter != m_filters.end() ), "Filter mentioned in rule, not found in FilterEngine" );
            const PropertyFilter& filter = (*filterIter).second;
            bool result = m_checker.check(filter, query);
            resultStack.push( result );
        }
        
        // pop token from ruleQueue
        ruleQueueCopy.pop();
    }
    
    // return last result
    BAMTOOLS_ASSERT_MESSAGE( resultStack.size() == 1, "Result stack should only have one value remaining - cannot return result" );
    return resultStack.top();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, 0x60(%rsp)
movq %rdi, %r14
cmpb $0x0, 0xb8(%rdi)
jne 0x4564e
movq %r14, %rdi
callq 0x45884
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0x488de
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x48aca
leaq 0x68(%rsp), %rdi
callq 0x48bac
leaq 0x68(%r14), %rsi
leaq 0x68(%rsp), %rdi
callq 0x441c0
leaq 0x108(%r14), %r15
leaq 0xc8(%r14), %r12
leaq 0xe8(%r14), %r13
leaq 0xc0(%r14), %rax
movq %rax, 0x58(%rsp)
leaq 0x68(%rsp), %rbx
movq 0x78(%rsp), %rbp
cmpq %rbp, 0x98(%rsp)
je 0x457fc
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3a2a9
testb %al, %al
je 0x456e1
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x4579b
leaq -0x1(%rax), %rcx
jmp 0x457b1
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3a2a9
testb %al, %al
je 0x4573e
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
jne 0x4570d
movq 0x50(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movb -0x1(%rax), %bpl
leaq 0x8(%rsp), %rdi
callq 0x48de4
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
jne 0x45738
movq 0x50(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
andb %bpl, -0x1(%rax)
jmp 0x457b9
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3a2a9
testb %al, %al
je 0x457c6
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
jne 0x4576a
movq 0x50(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movb -0x1(%rax), %bpl
leaq 0x8(%rsp), %rdi
callq 0x48de4
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
jne 0x45795
movq 0x50(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
orb %bpl, -0x1(%rax)
jmp 0x457b9
movq 0x50(%rsp), %rax
movq -0x8(%rax), %rax
leaq 0x1ff(%rax), %rcx
addq $0x200, %rax            # imm = 0x200
movb (%rcx), %cl
xorb $0x1, %cl
movb %cl, -0x1(%rax)
movq %rbx, %rdi
callq 0x4b128
jmp 0x456a6
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4473c
addq $0x40, %rax
movq 0x58(%rsp), %rdi
movq %rax, %rsi
movq 0x60(%rsp), %rdx
callq 0x45960
movb %al, 0x7(%rsp)
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x4af4a
jmp 0x457b9
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
jne 0x45816
movq 0x50(%rsp), %rcx
movl $0x200, %eax            # imm = 0x200
addq -0x8(%rcx), %rax
movb -0x1(%rax), %bl
leaq 0x68(%rsp), %rdi
callq 0x43f4e
leaq 0x8(%rsp), %rdi
callq 0x48bac
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x48bac
jmp 0x45874
movq %rax, %rbx
jmp 0x4586a
jmp 0x4585d
jmp 0x4585d
jmp 0x4585d
jmp 0x4585d
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x43f4e
leaq 0x8(%rsp), %rdi
callq 0x48bac
movq %rbx, %rdi
callq 0x35b50
movq %rax, %rdi
callq 0x3a198