// File: /workspace/github_cpp_makefile_star2_O3/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 0x5db28
movq %rdi, %rbx
movq 0x90(%rdi), %rax
testq %rax, %rax
je 0x5db28
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
movl $0x0, (%r8)
movq %rbx, %rdi
callq 0x27700
testb %al, %al
je 0x5db28
movq 0x8(%rsp), %rax
cmpb $0x42, -0x1(%rax)
jne 0x5dab6
movzbl (%rax), %r15d
cmpl $0x63, %r15d
je 0x5da24
cmpl $0x41, %r15d
jne 0x5db28
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
leal -0x41(%r15), %ecx
cmpl $0x22, %ecx
ja 0x5db99
movabsq $0x400040105, %rdx      # imm = 0x400040105
btq %rcx, %rdx
jae 0x5db35
movl 0x1(%rax), %ebp
movslq %ebp, %rbx
addq $0x5, %rax
movq %rax, 0x8(%rsp)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x5da6a
movq %rax, 0x8(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5dc9c
testl %ebx, %ebx
jle 0x5dab2
leaq 0x30(%rsp), %rbx
movq 0x8(%rsp), %rcx
movb (%rcx), %al
movb %al, 0x30(%rsp)
incq %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x5daa3
movb %al, (%rsi)
incq 0x8(%r14)
jmp 0x5daae
movq %r14, %rdi
movq %rbx, %rdx
callq 0x5dd50
decl %ebp
jne 0x5da7e
movb $0x1, %al
jmp 0x5db2a
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x14bb5(%rip), %rsi     # 0x7267b
leaq 0x14bc2(%rip), %rdx     # 0x7268f
leaq 0x30(%rsp), %rdi
callq 0x2f1a0
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1783a(%rip), %rsi     # 0x75321
leaq 0x17864(%rip), %rdx     # 0x75352
leaq 0x10(%rsp), %rdi
callq 0x2f1a0
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x27060
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x5db19
callq 0x27560
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x5db28
callq 0x27560
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x2000082, %eax        # imm = 0x2000082
btq %rcx, %rax
jae 0x5db99
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x14b2b(%rip), %rsi     # 0x7267b
leaq 0x14b38(%rip), %rdx     # 0x7268f
leaq 0x30(%rsp), %rdi
callq 0x2f1a0
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x177e2(%rip), %rsi     # 0x75353
leaq 0x17817(%rip), %rdx     # 0x7538f
leaq 0x10(%rsp), %rdi
callq 0x2f1a0
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x27060
jmp 0x5db0a
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x177e7(%rip), %rsi     # 0x75390
leaq 0x177fc(%rip), %rdx     # 0x753ac
leaq 0x10(%rsp), %rdi
callq 0x2f1a0
movsbl %r15b, %edx
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x41f6e
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x5dbdc
callq 0x27560
leaq 0x10(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x14a90(%rip), %rsi     # 0x7267b
leaq 0x14a9d(%rip), %rdx     # 0x7268f
callq 0x2f1a0
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x27060
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x5dc18
callq 0x27560
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x5db23
jmp 0x5db28
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x5dc46
callq 0x27560
jmp 0x5dc46
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x5dc89
jmp 0x5dc93
movq %rax, %rbx
movq 0x10(%rsp), %rdi
jmp 0x5dc84
jmp 0x5dc90
jmp 0x5dc68
jmp 0x5dc7c
jmp 0x5dc90
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x5dc7f
callq 0x27560
jmp 0x5dc7f
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x5dc93
callq 0x27560
jmp 0x5dc93
movq %rax, %rbx
movq %rbx, %rdi
callq 0x27b10
nop