// File: /workspace/github_cpp_makefile_star2_O1/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 0x38085(%rip), %rsi     # 0x91350
movq 0x38086(%rip), %rdx     # 0x91358
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x2f122
movq (%rbx), %rsi
cmpb $0x1, 0x3(%rsi)
jne 0x592f6
addq $0x50, %rsi
leaq 0x58(%rsp), %rdi
callq 0x27350
leaq 0x58(%rsp), %rdi
movl $0x2e, %esi
xorl %edx, %edx
callq 0x27780
testq %rax, %rax
je 0x5937b
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1de45(%rip), %rsi     # 0x77161
leaq 0x1de3f(%rip), %rdx     # 0x77162
leaq 0x8(%rsp), %rdi
callq 0x2f1b2
leaq 0x140(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x4af9e
leaq 0x58(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x27350
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5936c
callq 0x27560
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x5937b
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 0x2f122
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 0x150(%rsp), %r13
leaq 0x30(%rbx), %rax
movq %rax, 0x100(%rsp)
leaq 0x50(%rbx), %rax
movq %rax, 0xf8(%rsp)
leaq 0x8(%rsp), %r15
movq 0x108(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x27990
movb %al, 0x7(%rsp)
testb %al, %al
je 0x5980c
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 0x5dd58
testb %al, %al
je 0x5949a
leaq 0x140(%rsp), %rdi
callq 0x27440
movq 0xe0(%rsp), %r14
movq 0xe8(%rsp), %r12
cmpq %r12, %r14
je 0x594bd
movb (%r14), %al
movb %al, 0x8(%rsp)
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rsi
callq 0x276c0
movq (%rbx), %rcx
movq 0xb0(%rcx), %rsi
movq 0xb8(%rcx), %rdx
movq %rax, %rdi
callq 0x276c0
incq %r14
jmp 0x59460
movq 0x38(%rsp), %rdx
movl $0x4, %r8d
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
leaq 0x1ce77(%rip), %rcx     # 0x7632a
callq 0x27900
jmp 0x59545
movq %r15, %rdi
leaq 0x158(%rsp), %rsi
callq 0x279a0
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %r14
callq 0x27350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x594f3
callq 0x27560
movq 0x38(%rsp), %rcx
testq %rcx, %rcx
je 0x59538
movq (%rbx), %rax
subq 0xb8(%rax), %rcx
movq %r15, %rdi
leaq 0x30(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0x27600
movq %r12, %rdi
movq %r15, %rsi
callq 0x27350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x59538
callq 0x27560
leaq 0x140(%rsp), %rdi
callq 0x27490
leaq 0x110(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5dca8
leaq 0x118(%rsp), %rcx
cmpq %rcx, %rax
je 0x5956d
movq 0x40(%rax), %r12
jmp 0x597d9
leaq 0x140(%rsp), %rdi
callq 0x27440
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
leaq 0x150(%rsp), %rdi
callq 0x276c0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq %rax, %rdi
callq 0x276c0
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq %rax, %rdi
callq 0x276c0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1c737(%rip), %rsi     # 0x75d02
callq 0x276c0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r14, %rdi
callq 0x276c0
movl $0x4, %edx
movq %rax, %rdi
leaq 0x1c505(%rip), %rsi     # 0x75af6
callq 0x276c0
movl $0x8, %edi
callq 0x275c0
movq %rax, %r12
movq %rax, %rdi
callq 0x27360
movq %r15, %rdi
leaq 0x158(%rsp), %rsi
callq 0x279a0
movq %r12, %rdi
movq %r15, %rsi
movq 0x100(%rsp), %rdx
movq 0xf8(%rsp), %rcx
callq 0x279b0
movl %eax, %r14d
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x5964d
callq 0x27560
testb %r14b, %r14b
je 0x59731
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x2f122
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x2f122
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 0x2f122
movq 0xd8(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x110(%rsp), %rdi
movq %r15, %rsi
callq 0x5db00
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x59705
callq 0x27560
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x5971f
callq 0x27560
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
jmp 0x597b8
movl $0x25, %edx
movq 0x368a3(%rip), %rdi     # 0x8ffe0
leaq 0x1c686(%rip), %rsi     # 0x75dca
callq 0x276c0
movq %r15, %rdi
leaq 0x158(%rsp), %rsi
callq 0x279a0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x36876(%rip), %rdi     # 0x8ffe0
callq 0x276c0
movq %rax, %rbp
movl $0xd, %edx
movq %rax, %rdi
leaq 0x196ef(%rip), %rsi     # 0x72e70
callq 0x276c0
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 0x597c2
callq 0x27560
leaq 0x140(%rsp), %rdi
callq 0x27490
testb %r14b, %r14b
leaq 0x40(%rsp), %r14
je 0x597f0
movb $0x1, %bpl
testq %r12, %r12
je 0x597f2
movq %r12, %rdi
movq 0x50(%rsp), %rsi
callq 0x27be0
jmp 0x597f2
xorl %ebp, %ebp
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x59801
callq 0x27560
testb %bpl, %bpl
jne 0x593f4
jmp 0x5981c
leaq 0x110(%rsp), %rsi
movq %rbx, %rdi
callq 0x5da7a
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x5982e
callq 0x27560
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
movb 0x7(%rsp), %bl
je 0x5984c
callq 0x27560
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x59860
callq 0x27560
xorb $0x1, %bl
leaq 0x110(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x5dd10
movl %ebx, %eax
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x598c4
jmp 0x59974
movq %rax, %rbx
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x598ad
callq 0x27560
jmp 0x598ad
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
jne 0x599e0
jmp 0x599e5
jmp 0x598c4
jmp 0x598c4
movq %rax, %rbx
jmp 0x599e5
movq %rax, %rbx
jmp 0x599f9
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x598f0
callq 0x27560
jmp 0x598f0
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x5990f
callq 0x27560
jmp 0x5990f
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
jmp 0x59964
jmp 0x5997e
jmp 0x5997e
jmp 0x59932
jmp 0x59995
movq %rax, %rbx
movq %r12, %rdi
jmp 0x59969
jmp 0x59957
jmp 0x5997e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x59998
callq 0x27560
jmp 0x59998
jmp 0x59995
movq %rax, %rbx
leaq 0x40(%rsp), %r14
jmp 0x599aa
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x59981
callq 0x27560
jmp 0x59981
jmp 0x59979
jmp 0x59979
movq %rax, %rbx
jmp 0x599b9
movq %rax, %rbx
jmp 0x599aa
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x27490
leaq 0x40(%rsp), %r14
jmp 0x599aa
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x27490
leaq 0x40(%rsp), %r14
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x599b9
callq 0x27560
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x599cb
callq 0x27560
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x599e5
callq 0x27560
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x599f9
callq 0x27560
leaq 0x110(%rsp), %rdi
movq 0x10(%rdi), %rsi
callq 0x5dd10
movq %rbx, %rdi
callq 0x27b20
movq %rax, %rdi
callq 0x2e1ed