// File: /workspace/github_cpp_makefile_star2_O2/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 $0x50, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq 0x8(%rsi), %rsi
subq (%r14), %rsi
sarq %rsi
movq %rdx, %rdi
callq 0x34000
movq (%rbx), %rax
movq (%r14), %rbx
movq 0x8(%r14), %rcx
pushq $0x7
popq %rdx
pushq $0x2
popq %rsi
leaq 0x16425(%rip), %rdi     # 0x5bcc0
pushq $0x5
popq %r8
pushq $0x1
popq %r9
pushq $0x3
popq %r10
pushq $0x6
popq %r11
pushq $0x4
popq %rbp
pushq $0x8
popq %r14
cmpq %rcx, %rbx
je 0x4591e
movzbl (%rbx), %r15d
leal -0x48(%r15), %r12d
cmpl $0x10, %r12d
ja 0x458d4
movslq (%rdi,%r12,4), %r15
addq %rdi, %r15
jmpq *%r15
movl %r8d, %r15d
jmp 0x45906
cmpl $0x3d, %r15d
je 0x45903
cmpl $0x44, %r15d
jne 0x4592b
movl %esi, %r15d
jmp 0x45906
movl %r11d, %r15d
jmp 0x45906
movl %r9d, %r15d
jmp 0x45906
movl %r14d, %r15d
jmp 0x45906
xorl %r15d, %r15d
jmp 0x45906
movl %r10d, %r15d
jmp 0x45906
movl %ebp, %r15d
jmp 0x45906
movl %edx, %r15d
movl 0x4(%rbx), %r12d
shll $0x4, %r12d
orl %r15d, %r12d
movl %r12d, (%rax)
addq $0x4, %rax
addq $0x8, %rbx
jmp 0x458b2
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1646a(%rip), %rsi     # 0x5bd9c
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
movsbl (%rbx), %edx
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x32560
leaq 0x10(%rsp), %rdi
callq 0x33a00
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x1644a(%rip), %rsi     # 0x5bdb9
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2f59c(%rip), %rsi     # 0x74f38
movq 0x2f5d5(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x459c2
jmp 0x459ca
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x459f0
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x459f0
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %r14, %rdi
callq 0x34ed0