// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movq %rdi, %r14
cmpb $0x0, 0xb8(%rdi)
jne 0x3bff6
movq %r14, %rdi
callq 0x3c326
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %r15
movaps %xmm0, 0x40(%r15)
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movq %r15, %rdi
xorl %esi, %esi
callq 0x3f818
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x3f982
leaq 0x60(%rsp), %rdi
callq 0x3fa74
leaq 0x68(%r14), %rsi
leaq 0x60(%rsp), %rdi
callq 0x3aa1a
leaq 0xc0(%r14), %r15
leaq 0x60(%rsp), %r12
movq 0x70(%rsp), %r13
cmpq %r13, 0x90(%rsp)
je 0x3c2a2
movq 0x8(%r13), %rbp
cmpq 0x110(%r14), %rbp
jne 0x3c095
testq %rbp, %rbp
je 0x3c135
movq 0x108(%r14), %rsi
movq (%r13), %rdi
movq %rbp, %rdx
callq 0x275f0
testl %eax, %eax
je 0x3c135
cmpq 0xd0(%r14), %rbp
jne 0x3c0c2
testq %rbp, %rbp
je 0x3c14e
movq 0xc8(%r14), %rsi
movq (%r13), %rdi
movq %rbp, %rdx
callq 0x275f0
testl %eax, %eax
je 0x3c14e
cmpq 0xf0(%r14), %rbp
jne 0x3c0ef
testq %rbp, %rbp
je 0x3c18c
movq 0xe8(%r14), %rsi
movq (%r13), %rdi
movq %rbp, %rdx
callq 0x275f0
testl %eax, %eax
je 0x3c18c
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b06a
addq $0x40, %rax
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x3c402
movb %al, 0xf(%rsp)
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rdx
decq %rdx
cmpq %rdx, %rcx
je 0x3c1ca
movb %al, (%rcx)
incq %rcx
movq %rcx, 0x40(%rsp)
jmp 0x3c295
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
je 0x3c1de
leaq -0x1(%rax), %rcx
jmp 0x3c1f4
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdi
cmpq %rdi, %rax
je 0x3c201
movb -0x1(%rax), %bpl
decq %rax
movq %rax, 0x40(%rsp)
cmpq %rdi, %rax
jne 0x3c246
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
jmp 0x3c246
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdi
cmpq %rdi, %rax
je 0x3c24c
movb -0x1(%rax), %bpl
decq %rax
movq %rax, 0x40(%rsp)
cmpq %rdi, %rax
jne 0x3c291
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
jmp 0x3c291
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rsi
callq 0x4227e
jmp 0x3c295
movq 0x58(%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)
jmp 0x3c295
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movb 0x1ff(%rax), %bpl
callq 0x27560
movq 0x58(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x58(%rsp)
movq -0x8(%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x50(%rsp)
movl $0x1ff, %ecx            # imm = 0x1FF
addq %rcx, %rax
movq %rax, 0x40(%rsp)
andb %bpl, -0x1(%rax)
jmp 0x3c295
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movb 0x1ff(%rax), %bpl
callq 0x27560
movq 0x58(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x58(%rsp)
movq -0x8(%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x50(%rsp)
movl $0x1ff, %ecx            # imm = 0x1FF
addq %rcx, %rax
movq %rax, 0x40(%rsp)
orb %bpl, -0x1(%rax)
movq %r12, %rdi
callq 0x4246a
jmp 0x3c051
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
jne 0x3c2bc
movq 0x58(%rsp), %rcx
movl $0x200, %eax            # imm = 0x200
addq -0x8(%rcx), %rax
movb -0x1(%rax), %bl
leaq 0x60(%rsp), %rdi
callq 0x3a806
leaq 0x10(%rsp), %rdi
callq 0x3fa74
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3fa74
jmp 0x3c316
movq %rax, %rbx
jmp 0x3c30c
jmp 0x3c2ff
jmp 0x3c2ff
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3a806
leaq 0x10(%rsp), %rdi
callq 0x3fa74
movq %rbx, %rdi
callq 0x27b10
movq %rax, %rdi
callq 0x2e1cd