// File: /workspace/github_cpp_makefile_star2_O1/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), %r14
movl $0x0, (%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq %r14, 0x10(%r14)
movq %r14, 0x18(%r14)
movq %rax, 0x20(%r14)
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 0x8(%rsp), %rbp
movq 0x68(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x27990
movl %eax, %r15d
testb %al, %al
je 0x53c01
leaq 0xa0(%rsp), %rdi
callq 0x27330
movl %eax, %r13d
movq 0x80(%rsp), %rcx
movq %r14, %rax
testq %rcx, %rcx
je 0x53a8c
movq %r14, %rax
xorl %edx, %edx
cmpb %r13b, 0x20(%rcx)
setb %dl
cmovaeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x53a75
movq %r14, %rcx
cmpq %r14, %rax
je 0x53a9f
cmpb %r13b, 0x20(%rax)
cmovaq %r14, %rax
movq %rax, %rcx
cmpq %r14, %rcx
je 0x53aad
movq 0x28(%rcx), %r12
jmp 0x53be3
testb %r13b, %r13b
leaq 0x3d859(%rip), %rdx     # 0x91310
leaq 0x3d832(%rip), %rax     # 0x912f0
cmovneq %rax, %rdx
leaq 0x28(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x4af9e
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x2f122
movq %rbp, %rdi
leaq 0x21ffc(%rip), %rsi     # 0x75af6
callq 0x27c10
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x53b13
callq 0x27560
movl $0x8, %edi
callq 0x275c0
movq %rax, %r12
movq %rax, %rdi
callq 0x27360
movq %r12, %rdi
movq %rbp, %rsi
movq 0x58(%rsp), %rdx
movq 0x50(%rsp), %rcx
callq 0x279b0
movl %eax, %ebx
testb %al, %al
je 0x53b5e
movb %r13b, 0x28(%rsp)
movq %r12, 0x30(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5cafe
jmp 0x53bcb
movl $0x24, %edx
movq 0x3c476(%rip), %rdi     # 0x8ffe0
leaq 0x2227f(%rip), %rsi     # 0x75df0
callq 0x276c0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x3c459(%rip), %rdi     # 0x8ffe0
callq 0x276c0
movq %rax, %r13
movl $0xd, %edx
movq %rax, %rdi
leaq 0x1f2d2(%rip), %rsi     # 0x72e70
callq 0x276c0
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 0x53bdf
callq 0x27560
testb %bl, %bl
je 0x53c10
testq %r12, %r12
je 0x53a35
movq %r12, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x27be0
jmp 0x53a35
leaq 0x70(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x54fd6
leaq 0xa0(%rsp), %rdi
callq 0x27930
xorb $0x1, %r15b
leaq 0x70(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x5ca92
movl %r15d, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x53c9d
movq %rax, %rbx
jmp 0x53cad
jmp 0x53c84
jmp 0x53c9d
movq %rax, %rbx
jmp 0x53c6b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x53c6b
callq 0x27560
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
jmp 0x53c91
movq %rax, %rbx
movq %r12, %rdi
callq 0x27560
jmp 0x53c87
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x53ca0
callq 0x27560
jmp 0x53ca0
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x27930
leaq 0x70(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x5ca92
movq %rbx, %rdi
callq 0x27b20
movq %rax, %rdi
callq 0x2e1ed
nop