// File: /workspace/github_cpp_makefile_star2_O3/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 0x2e541
cmpl $0x65, %r14d
jg 0x2e568
cmpl $0x53, %r14d
je 0x2e57e
cmpl $0x5a, %r14d
je 0x2e596
cmpl $0x63, %r14d
je 0x2e55e
jmp 0x2e63a
leal -0x41(%r14), %eax
cmpl $0x8, %eax
ja 0x2e63a
leaq 0x26aef(%rip), %rsi     # 0x55044
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
incl (%rcx)
incq (%rdx)
jmp 0x2e703
cmpl $0x66, %r14d
je 0x2e58a
cmpl $0x69, %r14d
je 0x2e58a
cmpl $0x73, %r14d
jne 0x2e63a
addl $0x2, (%rcx)
addq $0x2, (%rdx)
jmp 0x2e703
addl $0x4, (%rcx)
addq $0x4, (%rdx)
jmp 0x2e703
movq (%rdx), %rsi
movl (%rcx), %eax
cmpb $0x0, (%rsi)
je 0x2e5b6
incq %rsi
incl %eax
movl %eax, (%rcx)
movq %rsi, (%rdx)
cmpb $0x0, (%rsi)
leaq 0x1(%rsi), %rsi
jne 0x2e5a3
decq %rsi
incl %eax
movl %eax, (%rcx)
incq %rsi
movq %rsi, (%rdx)
jmp 0x2e703
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 0x2e711
movabsq $0x4800000040, %r9      # imm = 0x4800000040
btq %r8, %r9
jb 0x2e6f3
movabsq $0x100000001, %r9       # imm = 0x100000001
btq %r8, %r9
jb 0x2e6f6
movabsq $0x1000000010000, %r9   # imm = 0x1000000010000
btq %r8, %r9
jae 0x2e711
addl %edi, %edi
jmp 0x2e6f6
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x26a88(%rip), %rsi     # 0x550d2
leaq 0x26a93(%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 0x28f20
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e6a4
callq 0x27560
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x26a4b(%rip), %rsi     # 0x550fe
leaq 0x26a5f(%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 0x2e6e0
callq 0x27560
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e6ef
callq 0x27560
xorl %eax, %eax
jmp 0x2e705
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 0x26995(%rip), %rsi     # 0x550b6
leaq 0x269a9(%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 0x2e754
callq 0x27560
leaq 0x8(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x2699b(%rip), %rsi     # 0x550fe
leaq 0x269af(%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 0x2e790
callq 0x27560
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x2e6ea
jmp 0x2e6ef
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2e7be
callq 0x27560
jmp 0x2e7be
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x2e823
jmp 0x2e82d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
jne 0x2e823
jmp 0x2e82d
jmp 0x2e82a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e7f6
callq 0x27560
jmp 0x2e7f6
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
jne 0x2e823
jmp 0x2e82d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e819
callq 0x27560
jmp 0x2e819
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e82d
callq 0x27560
jmp 0x2e82d
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c10
nop