// File: zeeev[P]DASVC/bamtools/src/utils/bamtools_filter_ruleparser.h
// Function: BamTools::RuleParser::parse()
inline
void RuleParser::parse(void) {
  
    // clear out any prior data
    while ( !m_ruleQueue.empty() ) 
        m_ruleQueue.pop();
    
    // skip if no rule to parse
    if ( m_ruleString.empty() ) return;
  
    // start at beginning of ruleString
    m_current = m_begin;
    
    // iterate through tokens in rule string
    RuleToken token;
    while ( readToken(token) ) {
      
        if ( token.Value.empty() ) break;
      
        // if token is an operand
        if ( isOperand(token) )
            m_ruleQueue.push(token.Value);

        // if token is an operator 
        else if ( isOperator(token) ) {

            // pop any operators at top of stack with higher priority
            while ( !m_operatorStack.empty() ) {
                const RuleToken& opToken = m_operatorStack.top();
                if ( (isLeftAssociative(token) && (priority(token) <= priority(opToken))) ||
                     (isRightAssociative(token) && (priority(token) < priority(opToken))) 
                    )
                {
                    m_ruleQueue.push(opToken.Value);
                    m_operatorStack.pop();
                }
                else break;
            }
            
            // push current operator token onto stack
            m_operatorStack.push(token);
        }
        
        // if token is left parenthesis
        else if ( isLeftParenthesis(token) )
            m_operatorStack.push(token);
        
        // if token is right parenthesis
        else if ( isRightParenthesis(token) ) {
          
            bool foundLeftParenthesis = false;
          
            // push operators into rule queue until left parenthesis found
            while ( !m_operatorStack.empty() && !foundLeftParenthesis ) {
                const RuleToken& opToken = m_operatorStack.top();
                if ( !isLeftParenthesis(opToken) )
                    m_ruleQueue.push(opToken.Value);
                else 
                    foundLeftParenthesis = true;
                m_operatorStack.pop();
            }
          
            // no left parenthesis found, error
            BAMTOOLS_ASSERT_MESSAGE( foundLeftParenthesis, "ERROR: Mismatched parenthesis in rule string.1");
        }
        
        // error: unknown operand
        else BAMTOOLS_ASSERT_UNREACHABLE;
    }    
    
    // while there are still operators on stack
    while ( !m_operatorStack.empty() ) {
        const RuleToken& token = m_operatorStack.top();
        BAMTOOLS_ASSERT_MESSAGE( (!isLeftParenthesis(token) && !isRightParenthesis(token)), "ERROR: Mismatched parenthesis in rule string.2");
        m_ruleQueue.push(token.Value);
        m_operatorStack.pop();
    }
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
addq $0x38, %rdi
callq 0xafa20
xorb $-0x1, %al
testb $0x1, %al
jne 0xb0e42
jmp 0xb0e52
movq 0x50(%rsp), %rdi
addq $0x38, %rdi
callq 0xb08e0
jmp 0xb0e2c
movq 0x50(%rsp), %rdi
callq 0x86c90
testb $0x1, %al
jne 0xb0e62
jmp 0xb0e67
jmp 0xb1234
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rcx
movq %rcx, 0x28(%rax)
leaq 0x88(%rsp), %rdi
callq 0xb2c60
movq 0x50(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xb2c80
movb %al, 0x4f(%rsp)
jmp 0xb0e99
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0xb0ea6
jmp 0xb11ab
leaq 0x90(%rsp), %rdi
callq 0x86c90
movb %al, 0x4e(%rsp)
jmp 0xb0eb9
movb 0x4e(%rsp), %al
testb $0x1, %al
jne 0xb0ec3
jmp 0xb0eeb
jmp 0xb11ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xb2910
jmp 0xb123c
leaq 0x88(%rsp), %rdi
callq 0xb2ef0
movb %al, 0x4d(%rsp)
jmp 0xb0efe
movb 0x4d(%rsp), %al
testb $0x1, %al
jne 0xb0f08
jmp 0xb0f25
movq 0x50(%rsp), %rdi
addq $0x38, %rdi
leaq 0x90(%rsp), %rsi
callq 0xb2f10
jmp 0xb0f20
jmp 0xb11a6
leaq 0x88(%rsp), %rdi
callq 0xb2f40
movb %al, 0x4c(%rsp)
jmp 0xb0f38
movb 0x4c(%rsp), %al
testb $0x1, %al
jne 0xb0f45
jmp 0xb107c
jmp 0xb0f47
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb2f80
movb %al, 0x4b(%rsp)
jmp 0xb0f5e
movb 0x4b(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xb0f6d
jmp 0xb105c
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb2fa0
movq %rax, 0x40(%rsp)
jmp 0xb0f85
movq 0x40(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xb2fb0
movb %al, 0x3f(%rsp)
jmp 0xb0fa2
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0xb0fac
jmp 0xb0fdb
leaq 0x88(%rsp), %rdi
callq 0xb2fd0
movl %eax, 0x38(%rsp)
jmp 0xb0fbf
movq 0x70(%rsp), %rdi
callq 0xb2fd0
movl %eax, 0x34(%rsp)
jmp 0xb0fcf
movl 0x38(%rsp), %eax
movl 0x34(%rsp), %ecx
cmpl %ecx, %eax
jle 0xb1027
leaq 0x88(%rsp), %rdi
callq 0xb3050
movb %al, 0x33(%rsp)
jmp 0xb0fee
movb 0x33(%rsp), %al
testb $0x1, %al
jne 0xb0ff8
jmp 0xb1055
leaq 0x88(%rsp), %rdi
callq 0xb2fd0
movl %eax, 0x2c(%rsp)
jmp 0xb100b
movq 0x70(%rsp), %rdi
callq 0xb2fd0
movl %eax, 0x28(%rsp)
jmp 0xb101b
movl 0x2c(%rsp), %eax
movl 0x28(%rsp), %ecx
cmpl %ecx, %eax
jge 0xb1055
movq 0x50(%rsp), %rdi
addq $0x38, %rdi
movq 0x70(%rsp), %rsi
addq $0x8, %rsi
callq 0xb2f10
jmp 0xb1040
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb3080
jmp 0xb1053
jmp 0xb1057
jmp 0xb105c
jmp 0xb0f47
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
leaq 0x88(%rsp), %rsi
callq 0xb3090
jmp 0xb1077
jmp 0xb11a4
leaq 0x88(%rsp), %rdi
callq 0xb30c0
movb %al, 0x27(%rsp)
jmp 0xb108f
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0xb1099
jmp 0xb10b9
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
leaq 0x88(%rsp), %rsi
callq 0xb3090
jmp 0xb10b4
jmp 0xb11a2
leaq 0x88(%rsp), %rdi
callq 0xb30e0
movb %al, 0x26(%rsp)
jmp 0xb10cc
movb 0x26(%rsp), %al
testb $0x1, %al
jne 0xb10d9
jmp 0xb1197
movb $0x0, 0x6f(%rsp)
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb2f80
movb %al, 0x25(%rsp)
jmp 0xb10f5
movb 0x25(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x24(%rsp)
jne 0xb1110
jmp 0xb1106
movb 0x6f(%rsp), %al
xorb $-0x1, %al
movb %al, 0x24(%rsp)
movb 0x24(%rsp), %al
testb $0x1, %al
jne 0xb111a
jmp 0xb118e
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb2fa0
movq %rax, 0x18(%rsp)
jmp 0xb1132
movq 0x18(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0xb30c0
movb %al, 0x17(%rsp)
jmp 0xb114c
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0xb1171
jmp 0xb1156
movq 0x50(%rsp), %rdi
addq $0x38, %rdi
movq 0x60(%rsp), %rsi
addq $0x8, %rsi
callq 0xb2f10
jmp 0xb116f
jmp 0xb1176
movb $0x1, 0x6f(%rsp)
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb3080
jmp 0xb1189
jmp 0xb10de
callq 0xafa50
jmp 0xb1195
jmp 0xb11a0
callq 0xafa50
jmp 0xb119e
jmp 0xb11a0
jmp 0xb11a2
jmp 0xb11a4
jmp 0xb11a6
jmp 0xb0e81
jmp 0xb11ad
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb2f80
movb %al, 0x16(%rsp)
jmp 0xb11c4
movb 0x16(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xb11d0
jmp 0xb1227
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb2fa0
movq %rax, 0x8(%rsp)
jmp 0xb11e8
movq 0x8(%rsp), %rax
movq %rax, 0x58(%rsp)
callq 0xafa50
jmp 0xb11f9
movq 0x50(%rsp), %rdi
addq $0x38, %rdi
movq 0x58(%rsp), %rsi
addq $0x8, %rsi
callq 0xb2f10
jmp 0xb1212
movq 0x50(%rsp), %rdi
addq $0x88, %rdi
callq 0xb3080
jmp 0xb1225
jmp 0xb11ad
leaq 0x88(%rsp), %rdi
callq 0xb2910
addq $0xb8, %rsp
retq
jmp 0xb123e
movq 0x80(%rsp), %rdi
callq 0x86d80
movq %rax, %rdi
callq 0x91290
nopw %cs:(%rax,%rax)
nopl (%rax)