// File: 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:
subq $0xd8, %rsp
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movq %rdx, 0xb8(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x20(%rsp)
testb $0x1, 0x130(%rax)
je 0x88412
movb $0x0, 0xd7(%rsp)
jmp 0x88680
movq 0x20(%rsp), %rdi
addq $0x88, %rdi
callq 0x7aba0
testb $0x1, %al
jne 0x88429
jmp 0x88436
movb $0x0, 0xd7(%rsp)
jmp 0x88680
movq 0x20(%rsp), %rdi
addq $0x88, %rdi
callq 0x785e0
movq 0x20(%rsp), %rdi
movq %rax, 0xb0(%rsp)
addq $0x88, %rdi
callq 0x74cd0
movq 0x20(%rsp), %rdi
movl %eax, 0xac(%rsp)
movl $0x0, 0xa8(%rsp)
movq 0xc0(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0xac(%rsp), %rcx
leaq 0xa8(%rsp), %r8
callq 0x77c80
testb $0x1, %al
jne 0x884ad
movb $0x0, 0xd7(%rsp)
jmp 0x88680
movq 0xb0(%rsp), %rax
movb -0x1(%rax), %cl
movq 0xb8(%rsp), %rax
movb %cl, (%rax)
movq 0xb8(%rsp), %rax
movsbl (%rax), %eax
movl %eax, 0x1c(%rsp)
addl $-0x41, %eax
subl $0x3, %eax
jb 0x8852b
jmp 0x884db
movl 0x1c(%rsp), %eax
addl $-0x48, %eax
subl $0x2, %eax
jb 0x8852b
jmp 0x884e9
movl 0x1c(%rsp), %eax
subl $0x53, %eax
je 0x8852b
jmp 0x884f4
movl 0x1c(%rsp), %eax
subl $0x5a, %eax
je 0x8852b
jmp 0x884ff
movl 0x1c(%rsp), %eax
subl $0x63, %eax
je 0x8852b
jmp 0x8850a
movl 0x1c(%rsp), %eax
subl $0x66, %eax
je 0x8852b
jmp 0x88515
movl 0x1c(%rsp), %eax
subl $0x69, %eax
je 0x8852b
jmp 0x88520
movl 0x1c(%rsp), %eax
subl $0x73, %eax
jne 0x88538
jmp 0x8852b
movb $0x1, 0xd7(%rsp)
jmp 0x88680
leaq 0x67(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x61d1f(%rip), %rsi     # 0xea272
leaq 0x68(%rsp), %rdi
callq 0x78e70
jmp 0x8855f
movq 0xb8(%rsp), %rax
movsbl (%rax), %edx
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x74830
jmp 0x8857e
leaq 0x68(%rsp), %rdi
callq 0x7cce8
jmp 0x8858a
leaq 0x67(%rsp), %rdi
callq 0x76f80
leaq 0x2f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq 0x8(%rsp), %rdx
leaq 0x61cd6(%rip), %rsi     # 0xea285
leaq 0x30(%rsp), %rdi
callq 0x78e70
jmp 0x885bb
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x71210
jmp 0x885d4
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0x885e0
leaq 0x2f(%rsp), %rdi
callq 0x76f80
movb $0x0, 0xd7(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0x88680
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
jmp 0x8862d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x7cce8
jmp 0x8862b
jmp 0x8862d
leaq 0x67(%rsp), %rdi
callq 0x76f80
jmp 0x88691
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
jmp 0x88665
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0x88663
jmp 0x88665
leaq 0x2f(%rsp), %rdi
callq 0x76f80
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0x8867e
jmp 0x88691
movb 0xd7(%rsp), %al
andb $0x1, %al
addq $0xd8, %rsp
retq
movq 0x58(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)