// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/BamAlignment.cpp
// Function: BamTools::BamAlignment::SkipToNextTag(char, char*&, unsigned int&) const
bool BamAlignment::SkipToNextTag(const char storageType,
                                 char*& pTagData,
                                 unsigned int& numBytesParsed) const
{
    switch (storageType) {

        case (Constants::BAM_TAG_TYPE_ASCII) :
        case (Constants::BAM_TAG_TYPE_INT8)  :
        case (Constants::BAM_TAG_TYPE_UINT8) :
            ++numBytesParsed;
            ++pTagData;
            break;

        case (Constants::BAM_TAG_TYPE_INT16)  :
        case (Constants::BAM_TAG_TYPE_UINT16) :
            numBytesParsed += sizeof(uint16_t);
            pTagData       += sizeof(uint16_t);
            break;

        case (Constants::BAM_TAG_TYPE_FLOAT)  :
        case (Constants::BAM_TAG_TYPE_INT32)  :
        case (Constants::BAM_TAG_TYPE_UINT32) :
            numBytesParsed += sizeof(uint32_t);
            pTagData       += sizeof(uint32_t);
            break;

        case (Constants::BAM_TAG_TYPE_STRING) :
        case (Constants::BAM_TAG_TYPE_HEX)    :
            while( *pTagData ) {
                ++numBytesParsed;
                ++pTagData;
            }
            // increment for null-terminator
            ++numBytesParsed;
            ++pTagData;
            break;

        case (Constants::BAM_TAG_TYPE_ARRAY) :

        {
            // read array type
            const char arrayType = *pTagData;
            ++numBytesParsed;
            ++pTagData;

            // read number of elements
            int32_t numElements;
            memcpy(&numElements, pTagData, sizeof(uint32_t)); // already endian-swapped, if needed
            numBytesParsed += sizeof(uint32_t);
            pTagData       += sizeof(uint32_t);

            // calculate number of bytes to skip
            int bytesToSkip = 0;
            switch (arrayType) {
                case (Constants::BAM_TAG_TYPE_INT8)  :
                case (Constants::BAM_TAG_TYPE_UINT8) :
                    bytesToSkip = numElements;
                    break;
                case (Constants::BAM_TAG_TYPE_INT16)  :
                case (Constants::BAM_TAG_TYPE_UINT16) :
                    bytesToSkip = numElements*sizeof(uint16_t);
                    break;
                case (Constants::BAM_TAG_TYPE_FLOAT)  :
                case (Constants::BAM_TAG_TYPE_INT32)  :
                case (Constants::BAM_TAG_TYPE_UINT32) :
                    bytesToSkip = numElements*sizeof(uint32_t);
                    break;
                default:
                    const string message = string("invalid binary array type: ") + arrayType;
                    SetErrorString("BamAlignment::SkipToNextTag", message);
                    return false;
            }

            // skip binary array contents
            numBytesParsed += bytesToSkip;
            pTagData       += bytesToSkip;
            break;
        }

        default:
            const string message = string("invalid tag type: ") + storageType;
            SetErrorString("BamAlignment::SkipToNextTag", message);
            return false;
    }

    // if we get here, tag skipped OK - return success
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %r14d
movq %rdi, %rbx
cmpl $0x52, %esi
jle 0x2e5ad
cmpl $0x65, %r14d
jg 0x2e5d4
cmpl $0x53, %r14d
je 0x2e5ea
cmpl $0x5a, %r14d
je 0x2e602
cmpl $0x63, %r14d
je 0x2e5ca
jmp 0x2e6a3
leal -0x41(%r14), %eax
cmpl $0x8, %eax
ja 0x2e6a3
leaq 0x26a83(%rip), %rsi     # 0x55044
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
incl (%rcx)
incq (%rdx)
jmp 0x2e76c
cmpl $0x66, %r14d
je 0x2e5f6
cmpl $0x69, %r14d
je 0x2e5f6
cmpl $0x73, %r14d
jne 0x2e6a3
addl $0x2, (%rcx)
addq $0x2, (%rdx)
jmp 0x2e76c
addl $0x4, (%rcx)
addq $0x4, (%rdx)
jmp 0x2e76c
movq (%rdx), %rax
cmpb $0x0, (%rax)
je 0x2e624
movl (%rcx), %esi
incq %rax
incl %esi
movl %esi, (%rcx)
movq %rax, (%rdx)
incl %esi
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x2e611
decq %rax
incl (%rcx)
incq %rax
jmp 0x2e769
movq (%rdx), %rax
movzbl (%rax), %r15d
movl (%rcx), %esi
leal 0x1(%rsi), %edi
movl %edi, (%rcx)
leaq 0x1(%rax), %rdi
movq %rdi, (%rdx)
movl 0x1(%rax), %edi
addl $0x5, %esi
movl %esi, (%rcx)
addq $0x5, %rax
movq %rax, (%rdx)
leal -0x43(%r15), %r8d
cmpl $0x30, %r8d
ja 0x2e77a
movabsq $0x4800000040, %r9      # imm = 0x4800000040
btq %r8, %r9
jb 0x2e75c
movabsq $0x100000001, %r9       # imm = 0x100000001
btq %r8, %r9
jb 0x2e75f
movabsq $0x1000000010000, %r9   # imm = 0x1000000010000
btq %r8, %r9
jae 0x2e77a
addl %edi, %edi
jmp 0x2e75f
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x26a1f(%rip), %rsi     # 0x550d2
leaq 0x26a2a(%rip), %rdx     # 0x550e4
leaq 0x8(%rsp), %rdi
callq 0x26750
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x267c0
leaq 0x28(%rsp), %rdi
movq 0x8(%rdi), %rsi
movsbl %r14b, %r8d
movl $0x1, %ecx
xorl %edx, %edx
callq 0x28f30
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e70d
callq 0x27560
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x269e2(%rip), %rsi     # 0x550fe
leaq 0x269f6(%rip), %rdx     # 0x55119
callq 0x26750
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x260e0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e749
callq 0x27560
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e758
callq 0x27560
xorl %eax, %eax
jmp 0x2e76e
shll $0x2, %edi
addl %edi, %esi
movl %esi, (%rcx)
movslq %edi, %rcx
addq %rcx, %rax
movq %rax, (%rdx)
movb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2692c(%rip), %rsi     # 0x550b6
leaq 0x26940(%rip), %rdx     # 0x550d1
leaq 0x8(%rsp), %rdi
callq 0x26750
movsbl %r15b, %edx
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x26e90
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2e7bd
callq 0x27560
leaq 0x8(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x26932(%rip), %rsi     # 0x550fe
leaq 0x26946(%rip), %rdx     # 0x55119
callq 0x26750
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x260e0
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2e7f9
callq 0x27560
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x2e753
jmp 0x2e758
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2e827
callq 0x27560
jmp 0x2e827
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x2e88c
jmp 0x2e896
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
jne 0x2e88c
jmp 0x2e896
jmp 0x2e893
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e85f
callq 0x27560
jmp 0x2e85f
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
jne 0x2e88c
jmp 0x2e896
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e882
callq 0x27560
jmp 0x2e882
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e896
callq 0x27560
jmp 0x2e896
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c20