// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/BamAlignment.cpp
// Function: BamTools::BamAlignment::GetTagType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, char&) const
bool BamAlignment::GetTagType(const std::string& tag, char& type) const {
  
    // skip if alignment is core-only
    if ( SupportData.HasCoreOnly ) {
        // TODO: set error string?
        return false;
    }

    // skip if no tags present
    if ( TagData.empty() ) {
        // TODO: set error string?
        return false;
    }

    // localize the tag data
    char* pTagData = (char*)TagData.data();
    const unsigned int tagDataLength = TagData.size();
    unsigned int numBytesParsed = 0;
    
    // if tag not found, return failure
    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ){
        // TODO: set error string?
        return false;
    }

    // otherwise, retrieve & validate tag type code
    type = *(pTagData - 1);
    switch ( type ) {
        case (Constants::BAM_TAG_TYPE_ASCII)  :
        case (Constants::BAM_TAG_TYPE_INT8)   :
        case (Constants::BAM_TAG_TYPE_UINT8)  :
        case (Constants::BAM_TAG_TYPE_INT16)  :
        case (Constants::BAM_TAG_TYPE_UINT16) :
        case (Constants::BAM_TAG_TYPE_INT32)  :
        case (Constants::BAM_TAG_TYPE_UINT32) :
        case (Constants::BAM_TAG_TYPE_FLOAT)  :
        case (Constants::BAM_TAG_TYPE_STRING) :
        case (Constants::BAM_TAG_TYPE_HEX)    :
        case (Constants::BAM_TAG_TYPE_ARRAY)  :
            return true;

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

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x50, %rsp
cmpb $0x0, 0x130(%rdi)
jne 0x2ed30
movq %rdi, %rbx
movq 0x90(%rdi), %rax
testq %rax, %rax
je 0x2ed30
movq %rdx, %r14
movq 0x88(%rbx), %rcx
leaq 0x20(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x2c(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x28(%rsp), %r8
movl $0x0, (%r8)
movq %rbx, %rdi
callq 0x27c10
testb %al, %al
je 0x2ed30
movq 0x20(%rsp), %rax
movb -0x1(%rax), %cl
movb %cl, (%r14)
addb $-0x41, %cl
cmpb $0x33, %cl
jae 0x2eca8
movb $0x1, %al
movzbl %cl, %ecx
movabsq $0x4012402040187, %rdx  # imm = 0x4012402040187
btq %rcx, %rdx
jb 0x2ed32
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2641a(%rip), %rsi     # 0x550d2
leaq 0x26425(%rip), %rdx     # 0x550e4
movq %rsp, %rdi
callq 0x26750
movsbl (%r14), %edx
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x26e90
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2ece6
callq 0x27560
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x263f2(%rip), %rsi     # 0x550e5
leaq 0x26403(%rip), %rdx     # 0x550fd
callq 0x26750
movq %rsp, %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x260e0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2ed1d
callq 0x27560
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2ed30
callq 0x27560
xorl %eax, %eax
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2ed52
callq 0x27560
jmp 0x2ed52
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x2ed6e
jmp 0x2ed78
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2ed78
callq 0x27560
jmp 0x2ed78
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c20