// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/toolkit/bamtools_split.cpp
// Function: BamTools::SplitTool::SplitToolPrivate::SplitPaired()
bool SplitTool::SplitToolPrivate::SplitPaired(void) {
  
    // set up splitting data structure
    map<bool, BamWriter*> outputFiles;
    map<bool, BamWriter*>::iterator writerIter;
    
    // iterate through alignments
    BamAlignment al;
    BamWriter* writer;
    bool isCurrentAlignmentPaired;
    while ( m_reader.GetNextAlignment(al) ) {
      
        // see if bool value exists
        isCurrentAlignmentPaired = al.IsPaired();
        writerIter = outputFiles.find(isCurrentAlignmentPaired);
          
        // if no writer associated with this value
        if ( writerIter == outputFiles.end() ) {
        
            // open new BamWriter
            const string outputFilename = m_outputFilenameStub + ( isCurrentAlignmentPaired
                                                                  ? SPLIT_PAIRED_TOKEN
                                                                  : SPLIT_SINGLE_TOKEN ) + ".bam";
            writer = new BamWriter;
            if ( !writer->Open(outputFilename, m_header, m_references) ) {
                cerr << "bamtool split ERROR: could not open " << outputFilename
                     << " for writing." << endl;
                return false;
            }
          
            // store in map
            outputFiles.insert( make_pair(isCurrentAlignmentPaired, writer) );
        } 
        
        // else grab corresponding writer
        else writer = (*writerIter).second;
        
        // store alignment in proper BAM output file 
        if ( writer ) 
            writer->SaveAlignment(al);
    }
    
    // clean up BamWriters 
    CloseWriters(outputFiles);
    
    // return success
    return true;  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, %rbx
leaq 0x78(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0xa0(%rsp), %rdi
callq 0x27220
leaq 0x28(%rbx), %rax
movq %rax, 0x68(%rsp)
leaq 0x8(%rbx), %rax
movq %rax, 0x60(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, 0x58(%rsp)
movq %rbx, 0x48(%rsp)
leaq 0x50(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0xa0(%rsp), %rbp
leaq 0x8(%rsp), %rbx
movq 0x68(%rsp), %rdi
movq %rbp, %rsi
callq 0x27980
movl %eax, %r15d
testb %al, %al
je 0x53aba
movq %rbp, %rdi
callq 0x27330
movl %eax, %r13d
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x53964
leaq 0x78(%rsp), %rax
movq %rax, %rcx
movq %rdi, %rdx
movb 0x20(%rdi), %sil
xorl %edi, %edi
cmpb %r13b, %sil
setb %dil
movq %rdx, %rax
cmovbq %rcx, %rax
movq 0x10(%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0x53925
leaq 0x78(%rsp), %rdi
cmpq %rdi, %rax
je 0x53964
cmpb %r13b, %sil
cmovbq %rcx, %rdx
cmpb %r13b, 0x20(%rdx)
jbe 0x53aac
testb %r13b, %r13b
leaq 0x3c99a(%rip), %rdx     # 0x90308
leaq 0x3c973(%rip), %rax     # 0x902e8
cmovneq %rax, %rdx
leaq 0x28(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x4aed0
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x2f10a
movq %rbx, %rdi
leaq 0x2115d(%rip), %rsi     # 0x74b0e
callq 0x27c00
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x539ca
callq 0x27560
movl $0x8, %edi
callq 0x275c0
movq %rax, %r12
movq %rax, %rdi
callq 0x27360
movq %r12, %rdi
movq %rbx, %rsi
movq 0x58(%rsp), %rdx
movq 0x50(%rsp), %rcx
callq 0x279a0
movl %eax, %r14d
testb %al, %al
je 0x53a16
movb %r13b, 0x28(%rsp)
movq %r12, 0x30(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5c9ce
jmp 0x53a83
movl $0x24, %edx
movq 0x3b5be(%rip), %rdi     # 0x8efe0
leaq 0x213b9(%rip), %rsi     # 0x74de2
callq 0x276b0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x3b5a1(%rip), %rdi     # 0x8efe0
callq 0x276b0
movq %rax, %r13
movl $0xd, %edx
movq %rax, %rdi
leaq 0x1e41a(%rip), %rsi     # 0x71e70
callq 0x276b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x27590
movsbl %al, %esi
movq %r13, %rdi
callq 0x27040
movq %rax, %rdi
callq 0x27410
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x53a97
callq 0x27560
testb %r14b, %r14b
je 0x53ac9
movq %r12, %rdi
movq %rbp, %rsi
callq 0x27bd0
jmp 0x538f0
movq 0x28(%rax), %r12
testq %r12, %r12
jne 0x53a9c
jmp 0x538f0
leaq 0x70(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x54e60
leaq 0xa0(%rsp), %rdi
callq 0x27920
xorb $0x1, %r15b
leaq 0x70(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x5c962
movl %r15d, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x53b3d
movq %rax, %rbx
jmp 0x53b66
jmp 0x53b42
jmp 0x53b3d
movq %rax, %rbx
jmp 0x53b24
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x53b24
callq 0x27560
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
jmp 0x53b4f
movq %rax, %rbx
movq %r12, %rdi
callq 0x27560
jmp 0x53b45
movq %rax, %rbx
jmp 0x53b59
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x53b59
callq 0x27560
leaq 0xa0(%rsp), %rdi
callq 0x27920
leaq 0x70(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x5c962
movq %rbx, %rdi
callq 0x27b10
movq %rax, %rdi
callq 0x2e1cd