// File: zeeev[P]DASVC/bamtools/src/toolkit/bamtools_header.cpp
// Function: BamTools::HeaderTool::HeaderToolPrivate::Run()
bool HeaderTool::HeaderToolPrivate::Run(void) {

    // set to default input if none provided
    if ( !m_settings->HasInput && !m_settings->HasInputFilelist )
        m_settings->InputFiles.push_back(Options::StandardIn());

    // add files in the filelist to the input file list
    if ( m_settings->HasInputFilelist ) {

        ifstream filelist(m_settings->InputFilelist.c_str(), ios::in);
        if ( !filelist.is_open() ) {
            cerr << "bamtools header ERROR: could not open input BAM file list... Aborting." << endl;
            return false;
        }

        string line;
        while ( getline(filelist, line) )
            m_settings->InputFiles.push_back(line);
    }

    // attemp to open BAM files
    BamMultiReader reader;
    if ( !reader.Open(m_settings->InputFiles) ) {
        cerr << "bamtools header ERROR: could not open BAM file(s) for reading... Aborting." << endl;
        return false;
    }

    // dump (merged) header contents to stdout
    cout << reader.GetHeaderText() << endl;

    // clean up & exit
    reader.Close();
    return true;
}

// Assembly:
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rdi, 0x2b8(%rsp)
movq 0x2b8(%rsp), %rax
movq %rax, 0x50(%rsp)
movq (%rax), %rax
testb $0x1, (%rax)
jne 0xc12e5
movq 0x50(%rsp), %rax
movq (%rax), %rax
testb $0x1, 0x1(%rax)
jne 0xc12e5
movq 0x50(%rsp), %rax
movq (%rax), %rax
addq $0x8, %rax
movq %rax, 0x48(%rsp)
callq 0x10f280
movq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x91220
movq 0x50(%rsp), %rax
movq (%rax), %rax
testb $0x1, 0x1(%rax)
je 0xc147e
movq 0x50(%rsp), %rax
movq (%rax), %rdi
addq $0x20, %rdi
callq 0x86320
movq %rax, %rsi
leaq 0xb0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movl $0x8, %edx
callq 0x86e30
movq 0x38(%rsp), %rdi
callq 0x86c10
movb %al, 0x47(%rsp)
jmp 0xc1332
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0xc139a
jmp 0xc133c
movq 0xa3c9d(%rip), %rdi     # 0x164fe0
leaq 0x6ec74(%rip), %rsi     # 0x12ffbe
callq 0x86700
movq %rax, 0x30(%rsp)
jmp 0xc1356
movq 0x30(%rsp), %rdi
movq 0xa3c0e(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xc1369
movb $0x0, 0x2c7(%rsp)
movl $0x1, 0xa0(%rsp)
jmp 0xc1447
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
jmp 0xc146a
leaq 0x80(%rsp), %rdi
callq 0x86a30
jmp 0xc13a9
jmp 0xc13ab
leaq 0xb0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x86140
movq %rax, 0x28(%rsp)
jmp 0xc13c7
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x86b60
movq %rax, 0x20(%rsp)
jmp 0xc13e2
movq 0x20(%rsp), %rax
cmpq $0x0, %rax
je 0xc142d
movq 0x50(%rsp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
leaq 0x80(%rsp), %rsi
callq 0x91220
jmp 0xc1408
jmp 0xc13ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x86f68
jmp 0xc1468
leaq 0x80(%rsp), %rdi
callq 0x86f68
jmp 0xc143c
movl $0x0, 0xa0(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x861c0
movl 0xa0(%rsp), %eax
testl %eax, %eax
je 0xc1466
jmp 0xc1461
jmp 0xc15b4
jmp 0xc147e
jmp 0xc146a
leaq 0xb0(%rsp), %rdi
callq 0x861c0
jmp 0xc1479
jmp 0xc15c5
leaq 0x78(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x86db0
movq 0x50(%rsp), %rax
movq 0x10(%rsp), %rdi
movq (%rax), %rsi
addq $0x8, %rsi
callq 0x864a0
movb %al, 0x1f(%rsp)
jmp 0xc14a9
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0xc1511
jmp 0xc14b3
movq 0xa3b26(%rip), %rdi     # 0x164fe0
leaq 0x6eb44(%rip), %rsi     # 0x130005
callq 0x86700
movq %rax, 0x8(%rsp)
jmp 0xc14cd
movq 0x8(%rsp), %rdi
movq 0xa3a97(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xc14e0
movb $0x0, 0x2c7(%rsp)
movl $0x1, 0xa0(%rsp)
jmp 0xc159a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
jmp 0xc15a6
leaq 0x58(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x865f0
jmp 0xc1522
movq 0xa3a6f(%rip), %rdi     # 0x164f98
leaq 0x58(%rsp), %rsi
callq 0x86640
movq %rax, (%rsp)
jmp 0xc1539
movq (%rsp), %rdi
movq 0xa3a2c(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0xc154b
leaq 0x58(%rsp), %rdi
callq 0x86f68
jmp 0xc1557
leaq 0x78(%rsp), %rdi
callq 0x861e0
jmp 0xc1563
movb $0x1, 0x2c7(%rsp)
movl $0x1, 0xa0(%rsp)
jmp 0xc159a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x86f68
jmp 0xc1598
jmp 0xc15a6
leaq 0x78(%rsp), %rdi
callq 0x86150
jmp 0xc15b4
leaq 0x78(%rsp), %rdi
callq 0x86150
jmp 0xc15b2
jmp 0xc15c5
movb 0x2c7(%rsp), %al
andb $0x1, %al
addq $0x2c8, %rsp            # imm = 0x2C8
retq
movq 0xa8(%rsp), %rdi
callq 0x86d80
movq %rax, %rdi
callq 0x91290
nopw (%rax,%rax)