// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/internal/bam/BamWriter_p.cpp
// Function: BamTools::Internal::BamWriterPrivate::CreatePackedCigar(std::vector<BamTools::CigarOp, std::allocator<BamTools::CigarOp>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void BamWriterPrivate::CreatePackedCigar(const vector<CigarOp>& cigarOperations, string& packedCigar) {

    // initialize
    const size_t numCigarOperations = cigarOperations.size();
    packedCigar.resize(numCigarOperations * Constants::BAM_SIZEOF_INT);

    // pack the cigar data into the string
    unsigned int* pPackedCigar = (unsigned int*)packedCigar.data();

    // iterate over cigar operations
    vector<CigarOp>::const_iterator coIter = cigarOperations.begin();
    vector<CigarOp>::const_iterator coEnd  = cigarOperations.end();
    for ( ; coIter != coEnd; ++coIter ) {

        // store op in packedCigar
        uint8_t cigarOp;
        switch ( coIter->Type ) {
            case (Constants::BAM_CIGAR_MATCH_CHAR)    : cigarOp = Constants::BAM_CIGAR_MATCH;    break;
            case (Constants::BAM_CIGAR_INS_CHAR)      : cigarOp = Constants::BAM_CIGAR_INS;      break;
            case (Constants::BAM_CIGAR_DEL_CHAR)      : cigarOp = Constants::BAM_CIGAR_DEL;      break;
            case (Constants::BAM_CIGAR_REFSKIP_CHAR)  : cigarOp = Constants::BAM_CIGAR_REFSKIP;  break;
            case (Constants::BAM_CIGAR_SOFTCLIP_CHAR) : cigarOp = Constants::BAM_CIGAR_SOFTCLIP; break;
            case (Constants::BAM_CIGAR_HARDCLIP_CHAR) : cigarOp = Constants::BAM_CIGAR_HARDCLIP; break;
            case (Constants::BAM_CIGAR_PAD_CHAR)      : cigarOp = Constants::BAM_CIGAR_PAD;      break;
            case (Constants::BAM_CIGAR_SEQMATCH_CHAR) : cigarOp = Constants::BAM_CIGAR_SEQMATCH; break;
            case (Constants::BAM_CIGAR_MISMATCH_CHAR) : cigarOp = Constants::BAM_CIGAR_MISMATCH; break;
            default:
                const string message = string("invalid CIGAR operation type") + coIter->Type;
                throw BamException("BamWriter::CreatePackedCigar", message);
        }

        *pPackedCigar = coIter->Length << Constants::BAM_CIGAR_SHIFT | cigarOp;
        pPackedCigar++;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq 0x8(%rsi), %rsi
subq (%r14), %rsi
sarq %rsi
movq %rdx, %rdi
xorl %edx, %edx
callq 0x26590
movq (%r14), %r15
movq 0x8(%r14), %rax
cmpq %rax, %r15
je 0x3cac9
movq (%rbx), %rcx
leaq 0x19224(%rip), %rdx     # 0x55c7c
movzbl (%r15), %esi
leal -0x48(%rsi), %edi
cmpl $0x10, %edi
ja 0x3ca74
movslq (%rdx,%rdi,4), %rsi
addq %rdx, %rsi
jmpq *%rsi
movl $0x5, %esi
jmp 0x3cab1
cmpl $0x3d, %esi
je 0x3caac
cmpl $0x44, %esi
jne 0x3cad6
movl $0x2, %esi
jmp 0x3cab1
movl $0x6, %esi
jmp 0x3cab1
movl $0x1, %esi
jmp 0x3cab1
movl $0x8, %esi
jmp 0x3cab1
xorl %esi, %esi
jmp 0x3cab1
movl $0x3, %esi
jmp 0x3cab1
movl $0x4, %esi
jmp 0x3cab1
movl $0x7, %esi
movl 0x4(%r15), %edi
shll $0x4, %edi
orl %esi, %edi
movl %edi, (%rcx)
addq $0x4, %rcx
addq $0x8, %r15
cmpq %rax, %r15
jne 0x3ca58
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x19281(%rip), %rsi     # 0x55d68
leaq 0x19296(%rip), %rdx     # 0x55d84
movq %rsp, %rdi
callq 0x26750
movsbl (%r15), %edx
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x26e90
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x3cb15
callq 0x27560
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
movq %rsp, %rdi
movq %r12, (%rdi)
leaq 0x19256(%rip), %rsi     # 0x55d85
leaq 0x1926b(%rip), %rdx     # 0x55da1
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x2e3e1(%rip), %rsi     # 0x6af38
movq 0x2e41a(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a30
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x3cb7f
callq 0x27560
jmp 0x3cb7f
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x3cb8c
movq %rbx, %rdi
callq 0x27070
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x3cba8
jmp 0x3cbb2
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x3cbb2
callq 0x27560
jmp 0x3cbb2
movq %rax, %r14
movq %r14, %rdi
callq 0x28c20