// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/toolkit/bamtools_filter.cpp
// Function: BamTools::FilterTool::FilterToolPrivate::ParseScript()
bool FilterTool::FilterToolPrivate::ParseScript(void) {
  
    // read in script contents from file
    const string document = GetScriptContents();
    
    // set up JsonCPP reader and attempt to parse script
    Json::Value root;
    Json::Reader reader;
    if ( !reader.parse(document, root) ) {
        // use built-in error reporting mechanism to alert user what was wrong with the script
        cerr  << "bamtools filter ERROR: failed to parse script - see error message(s) below" << endl
              << reader.getFormatedErrorMessages();
        return false;     
    }

    // initialize return status
    bool success = true;
    
    // see if root object contains multiple filters
    const Json::Value filters = root["filters"];
    if ( !filters.isNull() ) {
      
        // iterate over any filters found
        int filterIndex = 0;
        Json::Value::const_iterator filtersIter = filters.begin();
        Json::Value::const_iterator filtersEnd  = filters.end();
        for ( ; filtersIter != filtersEnd; ++filtersIter, ++filterIndex ) {
            Json::Value filter = (*filtersIter);
            
            // convert filter index to string
            string filterName;
            
            // if id tag supplied
            const Json::Value id = filter["id"];
            if ( !id.isNull() ) 
                filterName = id.asString();
            
            // use array index 
            else {
                stringstream convert;
                convert << filterIndex;
                filterName = convert.str();
            }
            
            // create & parse filter 
            success &= ParseFilterObject(filterName, filter);
        }
        
        // see if user defined a "rule" for these filters
        // otherwise, use filter engine's default rule behavior
        string ruleString("");
        const Json::Value rule = root["rule"];
        if ( rule.isString() )
            ruleString = rule.asString();
        m_filterEngine.setRule(ruleString);
          
        // return success/fail
        return success;
    } 
    
    // otherwise, root is the only filter (just contains properties)
    // create & parse filter named "ROOT"
    else success = ParseFilterObject("ROOT", root);
    
    // return success/failure
    return success;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x388, %rsp            # imm = 0x388
movq %rdi, %rsi
leaq 0xa0(%rsp), %rdi
movq %rsi, 0x8(%rsp)
callq 0x3d284
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x6c604
leaq 0x278(%rsp), %rdi
callq 0x67f14
leaq 0x278(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x680aa
testb %al, %al
je 0x3eb40
leaq 0x3326d(%rip), %rsi     # 0x71d3e
leaq 0x30(%rsp), %rdi
callq 0x6d504
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x6c760
leaq 0x48(%rsp), %rdi
callq 0x6d268
testb %al, %al
je 0x3eb9d
leaq 0x3324a(%rip), %rsi     # 0x71d4b
leaq 0xf0(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x35280
leaq 0xf0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x3e84a
movl %eax, 0x4(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x35730
jmp 0x3edb6
movq 0x56499(%rip), %rdi     # 0x94fe0
leaq 0x331a5(%rip), %rsi     # 0x71cf3
callq 0x355b0
movq %rax, %rdi
callq 0x35300
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
leaq 0x278(%rsp), %rsi
callq 0x69ae4
leaq 0xf0(%rsp), %rsi
movq %rbx, %rdi
callq 0x35510
leaq 0xf0(%rsp), %rdi
callq 0x35730
movl $0x0, 0x4(%rsp)
jmp 0x3edc0
leaq 0x48(%rsp), %rdi
callq 0x6daba
movq %rax, 0x80(%rsp)
movb %dl, 0x88(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x6db06
leaq 0x90(%rsp), %rcx
movq %rax, (%rcx)
movb %dl, 0x8(%rcx)
xorl %r12d, %r12d
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0x80(%rsp), %r15
leaq 0xd8(%rsp), %r13
leaq 0xc0(%rsp), %r14
leaq 0x10(%rsp), %rbx
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x43512
testb %al, %al
je 0x3ed19
movq %r15, %rdi
callq 0x6c20a
movq %r13, %rdi
movq %rax, %rsi
callq 0x6c760
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq %r13, %rdi
leaq 0x3261f(%rip), %rsi     # 0x7125d
callq 0x6d504
movq %r14, %rdi
movq %rax, %rsi
callq 0x6c760
movq %r14, %rdi
callq 0x6d268
testb %al, %al
je 0x3ecae
leaq 0xf0(%rsp), %rdi
callq 0x35430
leaq 0x100(%rsp), %rdi
movl %r12d, %esi
callq 0x35b00
leaq 0x60(%rsp), %rbp
movq %rbp, %rdi
leaq 0x108(%rsp), %rsi
callq 0x359c0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x35340
movq %rbp, %rdi
callq 0x35730
leaq 0xf0(%rsp), %rdi
callq 0x35490
jmp 0x3ecd4
leaq 0xf0(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x6cb36
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x35340
movq %rbp, %rdi
callq 0x35730
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x3e84a
movl %eax, %ebp
movq %r14, %rdi
callq 0x6c88a
movq %rbx, %rdi
callq 0x35730
movq %r13, %rdi
callq 0x6c88a
movq %r15, %rdi
callq 0x6c212
movl 0x4(%rsp), %eax
andb %bpl, %al
movl %eax, 0x4(%rsp)
incl %r12d
jmp 0x3ebf4
leaq 0x37ad7(%rip), %rsi     # 0x767f7
leaq 0xf0(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x35280
leaq 0x3300d(%rip), %rsi     # 0x71d46
leaq 0x30(%rsp), %rdi
callq 0x6d504
leaq 0x60(%rsp), %rdi
movq %rax, %rsi
callq 0x6c760
leaq 0x60(%rsp), %rdi
callq 0x6d958
testb %al, %al
je 0x3ed89
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x6cb36
leaq 0xf0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x35340
leaq 0x10(%rsp), %rdi
callq 0x35730
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x4351c
leaq 0x60(%rsp), %rdi
callq 0x6c88a
leaq 0xf0(%rsp), %rdi
callq 0x35730
leaq 0x48(%rsp), %rdi
callq 0x6c88a
leaq 0x278(%rsp), %rdi
callq 0x43556
leaq 0x30(%rsp), %rdi
callq 0x6c88a
leaq 0xa0(%rsp), %rdi
callq 0x35730
movl 0x4(%rsp), %eax
andb $0x1, %al
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35730
jmp 0x3ee39
jmp 0x3ef00
jmp 0x3ee36
jmp 0x3ef00
jmp 0x3ef00
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x35730
jmp 0x3ef03
jmp 0x3ef00
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x6c88a
jmp 0x3ee67
jmp 0x3ef00
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x35730
jmp 0x3ef0d
jmp 0x3ef00
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x35730
jmp 0x3ef03
jmp 0x3ee8d
jmp 0x3ee8d
movq %rax, %rbx
jmp 0x3ef24
movq %rax, %rbx
jmp 0x3ef1a
movq %rax, %rbx
jmp 0x3ef0d
jmp 0x3eeb5
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x35730
jmp 0x3eeb8
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x35730
jmp 0x3eed3
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x35490
jmp 0x3eed3
movq %rax, %rbx
jmp 0x3eef1
jmp 0x3eed0
jmp 0x3eed0
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x6c88a
jmp 0x3eee7
jmp 0x3ef00
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35730
leaq 0xd8(%rsp), %rdi
callq 0x6c88a
jmp 0x3ef03
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x6c88a
leaq 0x278(%rsp), %rdi
callq 0x43556
leaq 0x30(%rsp), %rdi
callq 0x6c88a
leaq 0xa0(%rsp), %rdi
callq 0x35730
movq %rbx, %rdi
callq 0x35b50
movq %rax, %rdi
callq 0x3a198
nop