// File: zeeev[P]DASVC/bamtools/src/toolkit/bamtools_resolve.cpp
// Function: BamTools::ResolveTool::ResolveToolPrivate::Run()
bool ResolveTool::ResolveToolPrivate::Run(void) {

    // verify that command line settings are acceptable
    vector<string> errors;
    if ( !CheckSettings(errors) ) {
        cerr << "bamtools resolve ERROR - invalid settings: " << endl;
        vector<string>::const_iterator errorIter = errors.begin();
        vector<string>::const_iterator errorEnd  = errors.end();
        for ( ; errorIter != errorEnd; ++errorIter )
            cerr << (*errorIter) << endl;
        return false;
    }

    // initialize read group map with default (empty name) read group
    m_readGroups.insert( make_pair<string, ReadGroupResolver>("", ReadGroupResolver()) );

    // init readname filename
    // uses (adjusted) stats filename if provided (req'd for makeStats, markPairs modes; optional for twoPass)
    // else keep default filename
    if ( m_settings->HasStatsFile )
        m_settings->ReadNamesFilename = m_settings->StatsFilename + READNAME_FILE_SUFFIX;

    // -makeStats mode
    if ( m_settings->IsMakeStats ) {

        // generate stats data
        if ( !MakeStats() ) {
            cerr << "bamtools resolve ERROR - could not generate stats" << endl;
            return false;
        }

        // write stats to file
        if ( !WriteStatsFile() ) {
            cerr << "bamtools resolve ERROR - could not write stats file: "
                 << m_settings->StatsFilename << endl;
            return false;
        }
    }

    // -markPairs mode
    else if ( m_settings->IsMarkPairs ) {

        // read stats from file
        if ( !ReadStatsFile() ) {
            cerr << "bamtools resolve ERROR - could not read stats file: "
                 << m_settings->StatsFilename << endl;
            return false;
        }

        // do paired-end resolution
        if ( !ResolvePairs() ) {
            cerr << "bamtools resolve ERROR - could not resolve pairs" << endl;
            return false;
        }
    }

    // -twoPass mode
    else {

        // generate stats data
        if ( !MakeStats() ) {
            cerr << "bamtools resolve ERROR - could not generate stats" << endl;
            return false;
        }

        // if stats file requested
        if ( m_settings->HasStatsFile ) {

            // write stats to file
            // emit warning if write fails, but paired-end resolution should be allowed to proceed
            if ( !WriteStatsFile() )
                cerr << "bamtools resolve WARNING - could not write stats file: "
                     << m_settings->StatsFilename << endl;
        }

        // do paired-end resolution
        if ( !ResolvePairs() ) {
            cerr << "bamtools resolve ERROR - could not resolve pairs" << endl;
            return false;
        }
    }

    // return success
    return true;
}

// Assembly:
subq $0x308, %rsp            # imm = 0x308
movq %rdi, 0x2f8(%rsp)
movq 0x2f8(%rsp), %rax
movq %rax, 0xd8(%rsp)
leaq 0x2e0(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0x92a40
movq 0xd8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0xc9c80
movb %al, 0xef(%rsp)
jmp 0xcc442
movb 0xef(%rsp), %al
testb $0x1, %al
jne 0xcc5c1
jmp 0xcc453
movq 0x98b86(%rip), %rdi     # 0x164fe0
leaq 0x64ea5(%rip), %rsi     # 0x131306
callq 0x86700
movq %rax, 0xd0(%rsp)
jmp 0xcc470
movq 0xd0(%rsp), %rdi
movq 0x98af1(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xcc486
leaq 0x2e0(%rsp), %rdi
callq 0x935d0
movq %rax, 0xc8(%rsp)
jmp 0xcc49d
movq 0xc8(%rsp), %rax
movq %rax, 0x2c0(%rsp)
leaq 0x2c8(%rsp), %rdi
leaq 0x2c0(%rsp), %rsi
callq 0xa7230
jmp 0xcc4c4
leaq 0x2e0(%rsp), %rdi
callq 0x93440
movq %rax, 0xc0(%rsp)
jmp 0xcc4db
movq 0xc0(%rsp), %rax
movq %rax, 0x2b0(%rsp)
leaq 0x2b8(%rsp), %rdi
leaq 0x2b0(%rsp), %rsi
callq 0xa7230
jmp 0xcc502
jmp 0xcc504
leaq 0x2c8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x96260
movb %al, 0xbf(%rsp)
jmp 0xcc522
movb 0xbf(%rsp), %al
testb $0x1, %al
jne 0xcc52f
jmp 0xcc5a9
leaq 0x2c8(%rsp), %rdi
callq 0x962a0
movq %rax, 0xb0(%rsp)
jmp 0xcc546
movq 0xb0(%rsp), %rsi
movq 0x98a8b(%rip), %rdi     # 0x164fe0
callq 0x86640
movq %rax, 0xa8(%rsp)
jmp 0xcc564
movq 0xa8(%rsp), %rdi
movq 0x989fd(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xcc57a
jmp 0xcc57c
leaq 0x2c8(%rsp), %rdi
callq 0x962b0
jmp 0xcc58b
jmp 0xcc504
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0xccbaf
movb $0x0, 0x307(%rsp)
movl $0x1, 0x2ac(%rsp)
jmp 0xccb91
movq 0xd8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x98(%rsp)
leaq 0x187(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x86da0
movq 0xa0(%rsp), %rdx
leaq 0x6867a(%rip), %rsi     # 0x134c73
leaq 0x188(%rsp), %rdi
callq 0x86a00
jmp 0xcc608
leaq 0x120(%rsp), %rdi
callq 0xc75c0
jmp 0xcc617
leaq 0x1a8(%rsp), %rdi
leaq 0x188(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0xcf980
jmp 0xcc636
leaq 0x228(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0xcfa40
jmp 0xcc64d
movq 0x98(%rsp), %rdi
leaq 0x228(%rsp), %rsi
callq 0xcf930
movb %dl, 0x8f(%rsp)
movq %rax, 0x90(%rsp)
jmp 0xcc673
movb 0x8f(%rsp), %al
movq 0x90(%rsp), %rcx
movq %rcx, 0x110(%rsp)
movb %al, 0x118(%rsp)
leaq 0x228(%rsp), %rdi
callq 0xcfab0
jmp 0xcc6a0
leaq 0x1a8(%rsp), %rdi
callq 0xcfb10
jmp 0xcc6af
leaq 0x120(%rsp), %rdi
callq 0xcfb70
jmp 0xcc6be
leaq 0x188(%rsp), %rdi
callq 0x86f68
jmp 0xcc6cd
leaq 0x187(%rsp), %rdi
callq 0x867b0
movq 0xd8(%rsp), %rax
movq (%rax), %rax
testb $0x1, 0x5(%rax)
je 0xcc833
movq 0xd8(%rsp), %rax
movq (%rax), %rsi
addq $0x50, %rsi
leaq 0x996db(%rip), %rdx     # 0x165de0
leaq 0xf0(%rsp), %rdi
callq 0xd0140
jmp 0xcc714
movq 0xd8(%rsp), %rax
movq (%rax), %rdi
addq $0x70, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x86070
jmp 0xcc732
leaq 0xf0(%rsp), %rdi
callq 0x86f68
jmp 0xcc741
jmp 0xcc833
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0xcc7f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0xcc7e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0xcc7d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0xcc7c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x228(%rsp), %rdi
callq 0xcfab0
jmp 0xcc7c4
jmp 0xcc7c6
leaq 0x1a8(%rsp), %rdi
callq 0xcfb10
jmp 0xcc7d5
jmp 0xcc7d7
leaq 0x120(%rsp), %rdi
callq 0xcfb70
jmp 0xcc7e6
jmp 0xcc7e8
leaq 0x188(%rsp), %rdi
callq 0x86f68
jmp 0xcc7f7
jmp 0xcc7f9
leaq 0x187(%rsp), %rdi
callq 0x867b0
jmp 0xccbaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x86f68
jmp 0xcc82e
jmp 0xccbaf
movq 0xd8(%rsp), %rax
movq (%rax), %rax
testb $0x1, (%rax)
je 0xcc93c
movq 0xd8(%rsp), %rdi
callq 0xcac00
movb %al, 0x8e(%rsp)
jmp 0xcc85d
movb 0x8e(%rsp), %al
testb $0x1, %al
jne 0xcc8b5
jmp 0xcc86a
movq 0x9876f(%rip), %rdi     # 0x164fe0
leaq 0x64aba(%rip), %rsi     # 0x131332
callq 0x86700
movq %rax, 0x80(%rsp)
jmp 0xcc887
movq 0x80(%rsp), %rdi
movq 0x986da(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xcc89d
movb $0x0, 0x307(%rsp)
movl $0x1, 0x2ac(%rsp)
jmp 0xccb91
movq 0xd8(%rsp), %rdi
callq 0xccbe0
movb %al, 0x7f(%rsp)
jmp 0xcc8c8
movb 0x7f(%rsp), %al
testb $0x1, %al
jne 0xcc937
jmp 0xcc8d2
movq 0x98707(%rip), %rdi     # 0x164fe0
leaq 0x64a84(%rip), %rsi     # 0x131364
callq 0x86700
movq %rax, 0x70(%rsp)
jmp 0xcc8ec
movq 0x70(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq (%rax), %rsi
addq $0x50, %rsi
callq 0x86640
movq %rax, 0x68(%rsp)
jmp 0xcc90c
movq 0x68(%rsp), %rdi
movq 0x98658(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xcc91f
movb $0x0, 0x307(%rsp)
movl $0x1, 0x2ac(%rsp)
jmp 0xccb91
jmp 0xccb7e
movq 0xd8(%rsp), %rax
movq (%rax), %rax
testb $0x1, 0x1(%rax)
je 0xcca3a
movq 0xd8(%rsp), %rdi
callq 0xcb830
movb %al, 0x67(%rsp)
jmp 0xcc964
movb 0x67(%rsp), %al
testb $0x1, %al
jne 0xcc9d3
jmp 0xcc96e
movq 0x9866b(%rip), %rdi     # 0x164fe0
leaq 0x64a1e(%rip), %rsi     # 0x13139a
callq 0x86700
movq %rax, 0x58(%rsp)
jmp 0xcc988
movq 0x58(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq (%rax), %rsi
addq $0x50, %rsi
callq 0x86640
movq %rax, 0x50(%rsp)
jmp 0xcc9a8
movq 0x50(%rsp), %rdi
movq 0x985bc(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xcc9bb
movb $0x0, 0x307(%rsp)
movl $0x1, 0x2ac(%rsp)
jmp 0xccb91
movq 0xd8(%rsp), %rdi
callq 0xcbda0
movb %al, 0x4f(%rsp)
jmp 0xcc9e6
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0xcca35
jmp 0xcc9f0
movq 0x985e9(%rip), %rdi     # 0x164fe0
leaq 0x649d1(%rip), %rsi     # 0x1313cf
callq 0x86700
movq %rax, 0x40(%rsp)
jmp 0xcca0a
movq 0x40(%rsp), %rdi
movq 0x9855a(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xcca1d
movb $0x0, 0x307(%rsp)
movl $0x1, 0x2ac(%rsp)
jmp 0xccb91
jmp 0xccb7c
movq 0xd8(%rsp), %rdi
callq 0xcac00
movb %al, 0x3f(%rsp)
jmp 0xcca4d
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0xcca9c
jmp 0xcca57
movq 0x98582(%rip), %rdi     # 0x164fe0
leaq 0x648cd(%rip), %rsi     # 0x131332
callq 0x86700
movq %rax, 0x30(%rsp)
jmp 0xcca71
movq 0x30(%rsp), %rdi
movq 0x984f3(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xcca84
movb $0x0, 0x307(%rsp)
movl $0x1, 0x2ac(%rsp)
jmp 0xccb91
movq 0xd8(%rsp), %rax
movq (%rax), %rax
testb $0x1, 0x5(%rax)
je 0xccb1b
movq 0xd8(%rsp), %rdi
callq 0xccbe0
movb %al, 0x2f(%rsp)
jmp 0xccac0
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0xccb19
jmp 0xccaca
movq 0x9850f(%rip), %rdi     # 0x164fe0
leaq 0x64928(%rip), %rsi     # 0x131400
callq 0x86700
movq %rax, 0x20(%rsp)
jmp 0xccae4
movq 0x20(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq (%rax), %rsi
addq $0x50, %rsi
callq 0x86640
movq %rax, 0x18(%rsp)
jmp 0xccb04
movq 0x18(%rsp), %rdi
movq 0x98460(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xccb17
jmp 0xccb19
jmp 0xccb1b
movq 0xd8(%rsp), %rdi
callq 0xcbda0
movb %al, 0x17(%rsp)
jmp 0xccb2e
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0xccb7a
jmp 0xccb38
movq 0x984a1(%rip), %rdi     # 0x164fe0
leaq 0x64889(%rip), %rsi     # 0x1313cf
callq 0x86700
movq %rax, 0x8(%rsp)
jmp 0xccb52
movq 0x8(%rsp), %rdi
movq 0x98412(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xccb65
movb $0x0, 0x307(%rsp)
movl $0x1, 0x2ac(%rsp)
jmp 0xccb91
jmp 0xccb7c
jmp 0xccb7e
movb $0x1, 0x307(%rsp)
movl $0x1, 0x2ac(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x92a50
movb 0x307(%rsp), %al
andb $0x1, %al
addq $0x308, %rsp            # imm = 0x308
retq
leaq 0x2e0(%rsp), %rdi
callq 0x92a50
jmp 0xccbbe
jmp 0xccbc0
movq 0x2d8(%rsp), %rdi
callq 0x86d80
movq %rax, %rdi
callq 0x91290
nopw %cs:(%rax,%rax)