// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/BamAlignment.h
// Function: bool BamTools::BamAlignment::GetTag<signed char>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<signed char, std::allocator<signed char>>&) const
inline bool BamAlignment::GetTag(const std::string& tag, std::vector<T>& destination) 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;

    // return false if tag not found
    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) {
        // TODO: set error string?
        return false;
    }

    // check that tag is array type
    const char tagType = *(pTagData - 1);
    if ( tagType != Constants::BAM_TAG_TYPE_ARRAY ) {
        SetErrorString("BamAlignment::GetTag", "cannot store a non-array tag in array destination");
        return false;
    }

    // fetch element type
    const char elementType = *pTagData;
    if ( !TagTypeHelper<T>::CanConvertFrom(elementType) ) {
        // TODO: set error string ?
        return false;
    }
    ++pTagData;

    // calculate length of each element in tag's array
    int elementLength = 0;
    switch ( elementType ) {
        case (Constants::BAM_TAG_TYPE_ASCII) :
        case (Constants::BAM_TAG_TYPE_INT8)  :
        case (Constants::BAM_TAG_TYPE_UINT8) :
            elementLength = sizeof(uint8_t);
            break;

        case (Constants::BAM_TAG_TYPE_INT16)  :
        case (Constants::BAM_TAG_TYPE_UINT16) :
            elementLength = sizeof(uint16_t);
            break;

        case (Constants::BAM_TAG_TYPE_INT32)  :
        case (Constants::BAM_TAG_TYPE_UINT32) :
        case (Constants::BAM_TAG_TYPE_FLOAT)  :
            elementLength = sizeof(uint32_t);
            break;

        // var-length types not supported for numeric destination
        case (Constants::BAM_TAG_TYPE_STRING) :
        case (Constants::BAM_TAG_TYPE_HEX)    :
        case (Constants::BAM_TAG_TYPE_ARRAY)  :
            SetErrorString("BamAlignment::GetTag",
                           "invalid array data, variable-length elements are not allowed");
            return false;

        // unknown tag type
        default:
            const std::string message = std::string("invalid array element type: ") + elementType;
            SetErrorString("BamAlignment::GetTag", message);
            return false;
    }

    // get number of elements
    int32_t numElements;
    memcpy(&numElements, pTagData, sizeof(int32_t));
    pTagData += 4;
    destination.clear();
    destination.reserve(numElements);

    // read in elements
    T value;
    for ( int i = 0 ; i < numElements; ++i ) {
        memcpy(&value, pTagData, sizeof(T));
        pTagData += sizeof(T);
        destination.push_back(value);
    }

    // return success
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x58, %rsp
cmpb $0x0, 0x130(%rdi)
jne 0x60bf5
movq %rdi, %rbx
movq 0x90(%rdi), %rax
testq %rax, %rax
je 0x60bf5
movq %rdx, %r14
movq 0x88(%rbx), %rcx
leaq 0x8(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x54(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x50(%rsp), %r8
andl $0x0, (%r8)
movq %rbx, %rdi
callq 0x35700
testb %al, %al
je 0x60bf5
movq 0x8(%rsp), %rax
cmpb $0x42, -0x1(%rax)
jne 0x60ba3
movzbl (%rax), %r15d
cmpl $0x63, %r15d
je 0x60b23
cmpl $0x41, %r15d
jne 0x60bf5
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
leal -0x41(%r15), %ecx
cmpl $0x22, %ecx
ja 0x60c65
movabsq $0x400040105, %rdx      # imm = 0x400040105
btq %rcx, %rdx
jae 0x60c06
movslq 0x1(%rax), %rbx
addq $0x5, %rax
movq %rax, 0x8(%rsp)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x60b67
movq %rax, 0x8(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x60d5a
xorl %ebp, %ebp
testl %ebx, %ebx
cmovgl %ebx, %ebp
leaq 0x30(%rsp), %rbx
subl $0x1, %ebp
jb 0x60c02
movq 0x8(%rsp), %rax
movb (%rax), %cl
movb %cl, 0x30(%rsp)
incq %rax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x60dca
jmp 0x60b7e
leaq 0x11a5e(%rip), %rsi     # 0x72608
leaq 0x30(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x35280
leaq 0x1472c(%rip), %rsi     # 0x752ec
leaq 0x10(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x35280
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x35050
leaq 0x10(%rsp), %rdi
callq 0x35730
leaq 0x30(%rsp), %rdi
callq 0x35730
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
jmp 0x60bf7
movl $0x2000082, %eax        # imm = 0x2000082
btq %rcx, %rax
jae 0x60c65
leaq 0x119f0(%rip), %rsi     # 0x72608
leaq 0x30(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x35280
leaq 0x146f0(%rip), %rsi     # 0x7531e
leaq 0x10(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x35280
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x35050
leaq 0x10(%rsp), %rdi
callq 0x35730
leaq 0x30(%rsp), %rdi
callq 0x35730
jmp 0x60bf5
leaq 0x146ef(%rip), %rsi     # 0x7535b
leaq 0x10(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x35280
movsbl %r15b, %edx
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x4acce
leaq 0x10(%rsp), %rdi
callq 0x35730
leaq 0x11969(%rip), %rsi     # 0x72608
leaq 0x10(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x35280
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x35050
leaq 0x10(%rsp), %rdi
callq 0x35730
leaq 0x30(%rsp), %rdi
callq 0x35730
jmp 0x60bf5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35730
jmp 0x60cfa
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35730
jmp 0x60d49
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x35730
jmp 0x60d49
jmp 0x60d37
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35730
jmp 0x60d1c
jmp 0x60d37
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x35730
jmp 0x60d49
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35730
jmp 0x60d3f
movq %rax, %rbx
jmp 0x60d49
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x35730
movq %rbx, %rdi
callq 0x35b50
movq %rax, %rdi
callq 0x3a198
nop