// File: zeeev[P]DASVC/bamtools/include/api/BamAlignment.h
// Function: bool BamTools::BamAlignment::GetTag<int>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int&) const
inline bool BamAlignment::GetTag(const std::string& tag, 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 failure if tag not found
    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) {
        // TODO: set error string?
        return false;
    }

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

    // determine data length
    int destinationLength = 0;
    switch ( type ) {

        // 1 byte data
        case (Constants::BAM_TAG_TYPE_ASCII) :
        case (Constants::BAM_TAG_TYPE_INT8)  :
        case (Constants::BAM_TAG_TYPE_UINT8) :
            destinationLength = 1;
            break;

        // 2 byte data
        case (Constants::BAM_TAG_TYPE_INT16)  :
        case (Constants::BAM_TAG_TYPE_UINT16) :
            destinationLength = 2;
            break;

        // 4 byte data
        case (Constants::BAM_TAG_TYPE_INT32)  :
        case (Constants::BAM_TAG_TYPE_UINT32) :
        case (Constants::BAM_TAG_TYPE_FLOAT)  :
            destinationLength = 4;
            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",
                           "cannot store variable length tag data into a numeric destination");
            return false;

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

    // store data in destination
    destination = 0;
    memcpy(&destination, pTagData, destinationLength);

    // return success
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x110(%rbp)
testb $0x1, 0x130(%rax)
je 0x111f4
movb $0x0, -0x1(%rbp)
jmp 0x11554
movq -0x110(%rbp), %rdi
addq $0x88, %rdi
callq 0x69a0
testb $0x1, %al
jne 0x1120d
jmp 0x11216
movb $0x0, -0x1(%rbp)
jmp 0x11554
movq -0x110(%rbp), %rdi
addq $0x88, %rdi
callq 0x6780
movq -0x110(%rbp), %rdi
movq %rax, -0x28(%rbp)
addq $0x88, %rdi
callq 0x6390
movq -0x110(%rbp), %rdi
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x28(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
leaq -0x30(%rbp), %r8
callq 0x2c5f0
testb $0x1, %al
jne 0x11273
movb $0x0, -0x1(%rbp)
jmp 0x11554
movq -0x28(%rbp), %rax
movb -0x1(%rax), %al
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %edi
callq 0x137e0
testb $0x1, %al
jne 0x11293
movb $0x0, -0x1(%rbp)
jmp 0x11554
movl $0x0, -0x38(%rbp)
movsbl -0x31(%rbp), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x118(%rbp)
subl $0x32, %eax
ja 0x113e9
movq -0x118(%rbp), %rax
leaq 0x6ed43(%rip), %rcx     # 0x80004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, -0x38(%rbp)
jmp 0x11535
movl $0x2, -0x38(%rbp)
jmp 0x11535
movl $0x4, -0x38(%rbp)
jmp 0x11535
leaq -0x59(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x6a20
movq -0x120(%rbp), %rdx
leaq 0x6eebc(%rip), %rsi     # 0x801c8
leaq -0x58(%rbp), %rdi
callq 0x11570
jmp 0x11317
leaq -0x91(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x6a20
movq -0x128(%rbp), %rdx
leaq 0x6eea5(%rip), %rsi     # 0x801dd
leaq -0x90(%rbp), %rdi
callq 0x11570
jmp 0x11346
movq -0x110(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x2c480
jmp 0x1135f
leaq -0x90(%rbp), %rdi
callq 0x6ba8
leaq -0x91(%rbp), %rdi
callq 0x6600
leaq -0x58(%rbp), %rdi
callq 0x6ba8
leaq -0x59(%rbp), %rdi
callq 0x6600
movb $0x0, -0x1(%rbp)
jmp 0x11554
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x113db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x113c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x6ba8
leaq -0x91(%rbp), %rdi
callq 0x6600
leaq -0x58(%rbp), %rdi
callq 0x6ba8
leaq -0x59(%rbp), %rdi
callq 0x6600
jmp 0x11562
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x6a20
movq -0x130(%rbp), %rdx
leaq 0x6ee14(%rip), %rsi     # 0x8021e
leaq -0xd8(%rbp), %rdi
callq 0x11570
jmp 0x11418
movsbl -0x31(%rbp), %edx
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x13830
jmp 0x11431
leaq -0xd8(%rbp), %rdi
callq 0x6ba8
leaq -0xd9(%rbp), %rdi
callq 0x6600
leaq -0x101(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x6a20
movq -0x138(%rbp), %rdx
leaq 0x6ed5e(%rip), %rsi     # 0x801c8
leaq -0x100(%rbp), %rdi
callq 0x11570
jmp 0x11478
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x2c480
jmp 0x11494
leaq -0x100(%rbp), %rdi
callq 0x6ba8
leaq -0x101(%rbp), %rdi
callq 0x6600
movb $0x0, -0x1(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x6ba8
jmp 0x11554
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x114e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x6ba8
leaq -0xd9(%rbp), %rdi
callq 0x6600
jmp 0x11562
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1151b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x6ba8
leaq -0x101(%rbp), %rdi
callq 0x6600
leaq -0xb8(%rbp), %rdi
callq 0x6ba8
jmp 0x11562
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x38(%rbp), %rdx
callq 0x6450
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x6a10
nopl (%rax,%rax)