// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/toolkit/bamtools_split.cpp
// Function: bool BamTools::SplitTool::SplitToolPrivate::SplitListTagImpl<signed char>(BamTools::BamAlignment&)
bool SplitTool::SplitToolPrivate::SplitListTagImpl(BamAlignment& al) {

    typedef T         TagElementType;
    typedef vector<T> TagValueType;
    typedef map<string, BamWriter*> WriterMap;
    typedef typename WriterMap::iterator WriterMapIterator;

    // set up splitting data structure
    WriterMap outputFiles;
    WriterMapIterator writerIter;

    // determine tag prefix
    string tagPrefix = SPLIT_TAG_TOKEN;
    if ( m_settings->HasCustomTagPrefix )
        tagPrefix = m_settings->CustomTagPrefix;

    // make sure prefix starts with '.'
    const size_t dotFound = tagPrefix.find('.');
    if ( dotFound != 0 )
        tagPrefix = string(".") + tagPrefix;

    const string tag = m_settings->TagToSplit;
    BamWriter* writer;
    TagValueType currentValue;
    while (m_reader.GetNextAlignment(al)) {

        string listTagLabel;
        if (!al.GetTag(tag, currentValue))
            listTagLabel = "none";
        else {
            // make list label from tag data
            stringstream listTagLabelStream;
            typename TagValueType::const_iterator tagValueIter = currentValue.begin();
            typename TagValueType::const_iterator tagValueEnd  = currentValue.end();
            for (; tagValueIter != tagValueEnd; ++tagValueIter)
                listTagLabelStream << (*tagValueIter) << m_settings->ListTagDelimiter;
            listTagLabel = listTagLabelStream.str();
            if (!listTagLabel.empty())
                listTagLabel = listTagLabel.substr(0, listTagLabel.size() - m_settings->ListTagDelimiter.size()); // pop last delimiter
        }

        // lookup writer for label
        writerIter = outputFiles.find(listTagLabel);

        // if not found, create one
        if (writerIter == outputFiles.end()) {

            // open new BamWriter, save first alignment
            stringstream outputFilenameStream;
            outputFilenameStream << m_outputFilenameStub << tagPrefix << tag << "_" << listTagLabel << ".bam";
            writer = new BamWriter;
            if ( !writer->Open(outputFilenameStream.str(), m_header, m_references) ) {
                cerr << "bamtools split ERROR: could not open " << outputFilenameStream.str()
                     << " for writing." << endl;
                return false;
            }

            // store in map
            outputFiles.insert( make_pair(listTagLabel, writer) );
        }

        // else grab existing writer
        else writer = (*writerIter).second;

        // store alignment in proper BAM output file
        if ( writer )
            writer->SaveAlignment(al);
    }

    // clean up & return success
    CloseWriters(outputFiles);
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rsi, 0x50(%rsp)
movq %rdi, %rbx
leaq 0x118(%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 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x37199(%rip), %rsi     # 0x90348
movq 0x3719a(%rip), %rdx     # 0x90350
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x2f10a
movq (%rbx), %rsi
cmpb $0x1, 0x3(%rsi)
jne 0x591da
addq $0x50, %rsi
leaq 0x58(%rsp), %rdi
callq 0x27350
leaq 0x58(%rsp), %rdi
movl $0x2e, %esi
xorl %edx, %edx
callq 0x27770
testq %rax, %rax
je 0x5925f
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1cf61(%rip), %rsi     # 0x76161
leaq 0x1cf5b(%rip), %rdx     # 0x76162
leaq 0x8(%rsp), %rdi
callq 0x2f1a0
leaq 0x140(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x4aed0
leaq 0x58(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x27350
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59250
callq 0x27560
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x5925f
callq 0x27560
movq (%rbx), %rax
leaq 0xa8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq 0x90(%rax), %rsi
movq 0x98(%rax), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x2f10a
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x28(%rbx), %rax
movq %rax, 0x108(%rsp)
leaq 0x40(%rsp), %r14
leaq 0x30(%rbx), %rax
movq %rax, 0x100(%rsp)
leaq 0x50(%rbx), %rax
movq %rax, 0xf8(%rsp)
leaq 0x8(%rsp), %r15
leaq 0x30(%rsp), %r13
movq 0x108(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x27980
movb %al, 0x7(%rsp)
testb %al, %al
je 0x596f1
movq %r14, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0x5d9a2
testb %al, %al
je 0x59383
leaq 0x140(%rsp), %rdi
callq 0x27440
movq %r13, %rbp
movq 0xe0(%rsp), %r14
movq 0xe8(%rsp), %r12
cmpq %r12, %r14
je 0x593a4
movb (%r14), %al
movb %al, 0x8(%rsp)
movl $0x1, %edx
leaq 0x150(%rsp), %rdi
movq %r15, %rsi
callq 0x276b0
movq (%rbx), %rcx
movq 0xb0(%rcx), %rsi
movq 0xb8(%rcx), %rdx
movq %rax, %rdi
callq 0x276b0
incq %r14
jmp 0x59344
movq 0x38(%rsp), %rdx
movl $0x4, %r8d
movq %r13, %rdi
xorl %esi, %esi
leaq 0x1bf82(%rip), %rcx     # 0x7531c
callq 0x278f0
jmp 0x59425
movq %r15, %rdi
leaq 0x158(%rsp), %rsi
callq 0x27990
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %r14
callq 0x27350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x593d8
callq 0x27560
movq 0x38(%rsp), %rcx
testq %rcx, %rcx
je 0x59418
movq (%rbx), %rax
subq 0xb8(%rax), %rcx
movq %r15, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x27600
movq %rbp, %rdi
movq %r15, %rsi
callq 0x27350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x59418
callq 0x27560
leaq 0x140(%rsp), %rdi
callq 0x27490
leaq 0x110(%rsp), %rdi
movq %r13, %rsi
callq 0x5d8f6
leaq 0x118(%rsp), %rcx
cmpq %rcx, %rax
je 0x59457
movq 0x40(%rax), %r12
testq %r12, %r12
jne 0x596c3
movb $0x1, %bpl
jmp 0x596d7
leaq 0x140(%rsp), %rdi
callq 0x27440
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
leaq 0x150(%rsp), %rdi
callq 0x276b0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq %rax, %rdi
callq 0x276b0
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq %rax, %rdi
callq 0x276b0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1b83f(%rip), %rsi     # 0x74cf4
callq 0x276b0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r14, %rdi
callq 0x276b0
movl $0x4, %edx
movq %rax, %rdi
leaq 0x1b633(%rip), %rsi     # 0x74b0e
callq 0x276b0
movl $0x8, %edi
callq 0x275c0
movq %rax, %r12
movq %rax, %rdi
callq 0x27360
movq %r15, %rdi
leaq 0x158(%rsp), %rsi
callq 0x27990
movq %r12, %rdi
movq %r15, %rsi
movq 0x100(%rsp), %rdx
movq 0xf8(%rsp), %rcx
callq 0x279a0
movl %eax, %r14d
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x59537
callq 0x27560
testb %r14b, %r14b
je 0x5961b
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x2f10a
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x2f10a
movq %r12, 0xd8(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2f10a
movq 0xd8(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x110(%rsp), %rdi
movq %r15, %rsi
callq 0x5d752
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x595ef
callq 0x27560
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x59609
callq 0x27560
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
jmp 0x596a2
movl $0x25, %edx
movq 0x359b9(%rip), %rdi     # 0x8efe0
leaq 0x1b78e(%rip), %rsi     # 0x74dbc
callq 0x276b0
movq %r15, %rdi
leaq 0x158(%rsp), %rsi
callq 0x27990
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x3598c(%rip), %rdi     # 0x8efe0
callq 0x276b0
movq %rax, %rbp
movl $0xd, %edx
movq %rax, %rdi
leaq 0x18805(%rip), %rsi     # 0x71e70
callq 0x276b0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x27590
movsbl %al, %esi
movq %rbp, %rdi
callq 0x27040
movq %rax, %rdi
callq 0x27410
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x596ac
callq 0x27560
leaq 0x140(%rsp), %rdi
callq 0x27490
testb %r14b, %r14b
leaq 0x40(%rsp), %r14
je 0x596d5
movb $0x1, %bpl
movq %r12, %rdi
movq 0x50(%rsp), %rsi
callq 0x27bd0
jmp 0x596d7
xorl %ebp, %ebp
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x596e6
callq 0x27560
testb %bpl, %bpl
jne 0x592d5
jmp 0x59701
leaq 0x110(%rsp), %rsi
movq %rbx, %rdi
callq 0x5d6cc
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x59713
callq 0x27560
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
movb 0x7(%rsp), %bl
je 0x59731
callq 0x27560
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x59745
callq 0x27560
xorb $0x1, %bl
leaq 0x110(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x5d95a
movl %ebx, %eax
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x597a9
jmp 0x59859
movq %rax, %rbx
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59792
callq 0x27560
jmp 0x59792
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
jne 0x598c5
jmp 0x598ca
jmp 0x597a9
jmp 0x597a9
movq %rax, %rbx
jmp 0x598ca
movq %rax, %rbx
jmp 0x598de
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x597d5
callq 0x27560
jmp 0x597d5
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x597f4
callq 0x27560
jmp 0x597f4
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
jmp 0x59849
jmp 0x59863
jmp 0x59863
jmp 0x59817
jmp 0x5987a
movq %rax, %rbx
movq %r12, %rdi
jmp 0x5984e
jmp 0x5983c
jmp 0x59863
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x5987d
callq 0x27560
jmp 0x5987d
jmp 0x5987a
movq %rax, %rbx
leaq 0x40(%rsp), %r14
jmp 0x5988f
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x59866
callq 0x27560
jmp 0x59866
jmp 0x5985e
jmp 0x5985e
movq %rax, %rbx
jmp 0x5989e
movq %rax, %rbx
jmp 0x5988f
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x27490
leaq 0x40(%rsp), %r14
jmp 0x5988f
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x27490
leaq 0x40(%rsp), %r14
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x5989e
callq 0x27560
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x598b0
callq 0x27560
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x598ca
callq 0x27560
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x598de
callq 0x27560
leaq 0x110(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x5d95a
movq %rbx, %rdi
callq 0x27b10
movq %rax, %rdi
callq 0x2e1cd
nop