// File: 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:
subq $0x528, %rsp            # imm = 0x528
movq %rdi, 0x518(%rsp)
movq 0x518(%rsp), %rsi
movq %rsi, 0x90(%rsp)
leaq 0x4f8(%rsp), %rdi
callq 0x9a6f0
leaq 0x4e0(%rsp), %rdi
xorl %esi, %esi
callq 0x1212e0
jmp 0x9d0cd
leaq 0x3c0(%rsp), %rdi
callq 0x1163d0
jmp 0x9d0dc
leaq 0x3c0(%rsp), %rdi
leaq 0x4f8(%rsp), %rsi
leaq 0x4e0(%rsp), %rdx
movl $0x1, %ecx
callq 0x116680
movb %al, 0x8f(%rsp)
jmp 0x9d107
movb 0x8f(%rsp), %al
testb $0x1, %al
jne 0x9d215
jmp 0x9d118
movq 0xc7ec1(%rip), %rdi     # 0x164fe0
leaq 0x92415(%rip), %rsi     # 0x12f53b
callq 0x86700
movq %rax, 0x80(%rsp)
jmp 0x9d135
movq 0x80(%rsp), %rdi
movq 0xc7e2c(%rip), %rsi     # 0x164f70
callq 0x86770
movq %rax, 0x78(%rsp)
jmp 0x9d150
leaq 0x3a0(%rsp), %rdi
leaq 0x3c0(%rsp), %rsi
callq 0x11a020
jmp 0x9d167
movq 0x78(%rsp), %rdi
leaq 0x3a0(%rsp), %rsi
callq 0x86640
jmp 0x9d17b
leaq 0x3a0(%rsp), %rdi
callq 0x86f68
jmp 0x9d18a
movb $0x0, 0x527(%rsp)
movl $0x1, 0x39c(%rsp)
jmp 0x9d8dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d93a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d929
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d8fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x3a0(%rsp), %rdi
callq 0x86f68
jmp 0x9d210
jmp 0x9d8fa
movb $0x1, 0x39b(%rsp)
leaq 0x92362(%rip), %rsi     # 0x12f586
leaq 0x4e0(%rsp), %rdi
callq 0x1239b0
movq %rax, 0x70(%rsp)
jmp 0x9d238
movq 0x70(%rsp), %rsi
leaq 0x380(%rsp), %rdi
callq 0x1216e0
jmp 0x9d24c
leaq 0x380(%rsp), %rdi
callq 0x123330
movb %al, 0x6f(%rsp)
jmp 0x9d25f
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0x9d7da
jmp 0x9d26d
movl $0x0, 0x37c(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x124a50
movb %dl, 0x5f(%rsp)
movq %rax, 0x60(%rsp)
jmp 0x9d290
movb 0x5f(%rsp), %al
movq 0x60(%rsp), %rcx
movq %rcx, 0x358(%rsp)
movb %al, 0x360(%rsp)
movb 0x360(%rsp), %al
movb %al, 0x370(%rsp)
movq 0x358(%rsp), %rax
movq %rax, 0x368(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x124ac0
movb %dl, 0x4f(%rsp)
movq %rax, 0x50(%rsp)
jmp 0x9d2de
movb 0x4f(%rsp), %al
movq 0x50(%rsp), %rcx
movq %rcx, 0x338(%rsp)
movb %al, 0x340(%rsp)
movq 0x338(%rsp), %rax
movq %rax, 0x348(%rsp)
movb 0x340(%rsp), %al
movb %al, 0x350(%rsp)
leaq 0x368(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0xa77c0
movb %al, 0x4e(%rsp)
jmp 0x9d32f
movb 0x4e(%rsp), %al
testb $0x1, %al
jne 0x9d33c
jmp 0x9d61a
leaq 0x368(%rsp), %rdi
callq 0xa77f0
movq %rax, 0x40(%rsp)
jmp 0x9d350
movq 0x40(%rsp), %rsi
leaq 0x320(%rsp), %rdi
callq 0x1216e0
jmp 0x9d364
leaq 0x300(%rsp), %rdi
callq 0x86a30
jmp 0x9d373
leaq 0x91033(%rip), %rsi     # 0x12e3ad
leaq 0x320(%rsp), %rdi
callq 0x1239b0
movq %rax, 0x38(%rsp)
jmp 0x9d38e
movq 0x38(%rsp), %rsi
leaq 0x2e8(%rsp), %rdi
callq 0x1216e0
jmp 0x9d3a2
leaq 0x2e8(%rsp), %rdi
callq 0x123330
movb %al, 0x37(%rsp)
jmp 0x9d3b5
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x9d491
jmp 0x9d3c3
leaq 0x2c8(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x122160
jmp 0x9d3da
leaq 0x300(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
callq 0x86070
jmp 0x9d3f1
leaq 0x2c8(%rsp), %rdi
callq 0x86f68
jmp 0x9d400
jmp 0x9d553
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d8cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d606
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d5f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d5e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0x86f68
jmp 0x9d48c
jmp 0x9d5e4
leaq 0x140(%rsp), %rdi
callq 0x86520
jmp 0x9d4a0
leaq 0x150(%rsp), %rdi
movl 0x37c(%rsp), %esi
callq 0x86d40
jmp 0x9d4b6
leaq 0x120(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x866f0
jmp 0x9d4cd
leaq 0x300(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x86070
jmp 0x9d4e4
leaq 0x120(%rsp), %rdi
callq 0x86f68
jmp 0x9d4f3
leaq 0x140(%rsp), %rdi
callq 0x86580
jmp 0x9d502
jmp 0x9d553
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d53f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x86f68
jmp 0x9d53d
jmp 0x9d53f
leaq 0x140(%rsp), %rdi
callq 0x86580
jmp 0x9d54e
jmp 0x9d5e4
movq 0x90(%rsp), %rdi
leaq 0x300(%rsp), %rsi
leaq 0x320(%rsp), %rdx
callq 0x9cc50
movb %al, 0x36(%rsp)
jmp 0x9d576
movb 0x36(%rsp), %al
movzbl %al, %eax
movzbl 0x39b(%rsp), %ecx
andl %ecx, %eax
andb $0x1, %al
movb %al, 0x39b(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0x121950
jmp 0x9d59f
leaq 0x300(%rsp), %rdi
callq 0x86f68
jmp 0x9d5ae
leaq 0x320(%rsp), %rdi
callq 0x121950
jmp 0x9d5bd
jmp 0x9d5bf
leaq 0x368(%rsp), %rdi
callq 0xa7800
jmp 0x9d5ce
movl 0x37c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x37c(%rsp)
jmp 0x9d314
leaq 0x2e8(%rsp), %rdi
callq 0x121950
jmp 0x9d5f3
jmp 0x9d5f5
leaq 0x300(%rsp), %rdi
callq 0x86f68
jmp 0x9d604
jmp 0x9d606
leaq 0x320(%rsp), %rdi
callq 0x121950
jmp 0x9d615
jmp 0x9d8cb
leaq 0xff(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x86da0
movq 0x28(%rsp), %rdx
leaq 0x9763b(%rip), %rsi     # 0x134c73
leaq 0x100(%rsp), %rdi
callq 0x86a00
jmp 0x9d647
leaq 0xff(%rsp), %rdi
callq 0x867b0
leaq 0x91f33(%rip), %rsi     # 0x12f58e
leaq 0x4e0(%rsp), %rdi
callq 0x1239b0
movq %rax, 0x20(%rsp)
jmp 0x9d66f
movq 0x20(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x1216e0
jmp 0x9d683
leaq 0xe0(%rsp), %rdi
callq 0x1246f0
movb %al, 0x1f(%rsp)
jmp 0x9d696
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x9d6a3
jmp 0x9d75c
leaq 0xc0(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x122160
jmp 0x9d6ba
leaq 0x100(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x86070
jmp 0x9d6d1
leaq 0xc0(%rsp), %rdi
callq 0x86f68
jmp 0x9d6e0
jmp 0x9d75c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0xff(%rsp), %rdi
callq 0x867b0
jmp 0x9d8cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d7c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d7b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x86f68
jmp 0x9d75a
jmp 0x9d7b0
movq 0x90(%rsp), %rdi
addq $0x20, %rdi
leaq 0x100(%rsp), %rsi
callq 0xa7830
jmp 0x9d777
movb 0x39b(%rsp), %al
andb $0x1, %al
movb %al, 0x527(%rsp)
movl $0x1, 0x39c(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x121950
jmp 0x9d7a1
leaq 0x100(%rsp), %rdi
callq 0x86f68
jmp 0x9d7c1
leaq 0xe0(%rsp), %rdi
callq 0x121950
jmp 0x9d7bf
jmp 0x9d7c6
jmp 0x9d8ba
leaq 0x100(%rsp), %rdi
callq 0x86f68
jmp 0x9d7d5
jmp 0x9d8cb
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x86da0
movq 0x10(%rsp), %rdx
leaq 0x91d9b(%rip), %rsi     # 0x12f593
leaq 0xa0(%rsp), %rdi
callq 0x86a00
jmp 0x9d807
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x4e0(%rsp), %rdx
callq 0x9cc50
movb %al, 0xf(%rsp)
jmp 0x9d82a
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x39b(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x86f68
jmp 0x9d846
leaq 0x9f(%rsp), %rdi
callq 0x867b0
jmp 0x9d89f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x9d890
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x86f68
jmp 0x9d88e
jmp 0x9d890
leaq 0x9f(%rsp), %rdi
callq 0x867b0
jmp 0x9d8cb
movb 0x39b(%rsp), %al
andb $0x1, %al
movb %al, 0x527(%rsp)
movl $0x1, 0x39c(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x121950
jmp 0x9d8c9
jmp 0x9d8dc
leaq 0x380(%rsp), %rdi
callq 0x121950
jmp 0x9d8da
jmp 0x9d8fa
leaq 0x3c0(%rsp), %rdi
callq 0xa7880
jmp 0x9d8eb
leaq 0x4e0(%rsp), %rdi
callq 0x121950
jmp 0x9d90b
leaq 0x3c0(%rsp), %rdi
callq 0xa7880
jmp 0x9d909
jmp 0x9d929
leaq 0x4f8(%rsp), %rdi
callq 0x86f68
movb 0x527(%rsp), %al
andb $0x1, %al
addq $0x528, %rsp            # imm = 0x528
retq
leaq 0x4e0(%rsp), %rdi
callq 0x121950
jmp 0x9d938
jmp 0x9d93a
leaq 0x4f8(%rsp), %rdi
callq 0x86f68
jmp 0x9d949
jmp 0x9d94b
movq 0x4d8(%rsp), %rdi
callq 0x86d80
movq %rax, %rdi
callq 0x91290