// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/vcf.c
// Function: bcf_get_info_values
int bcf_get_info_values(const bcf_hdr_t *hdr, bcf1_t *line, const char *tag, void **dst, int *ndst, int type)
{
    int i, ret = -4, tag_id = bcf_hdr_id2int(hdr, BCF_DT_ID, tag);
    if ( !bcf_hdr_idinfo_exists(hdr,BCF_HL_INFO,tag_id) ) return -1;    // no such INFO field in the header
    if ( bcf_hdr_id2type(hdr,BCF_HL_INFO,tag_id)!=(type & 0xff) ) return -2;     // expected different type

    if ( !(line->unpacked & BCF_UN_INFO) ) bcf_unpack(line, BCF_UN_INFO);

    for (i=0; i<line->n_info; i++)
        if ( line->d.info[i].key==tag_id ) break;
    if ( i==line->n_info ) return ( type==BCF_HT_FLAG ) ? 0 : -3;       // the tag is not present in this record
    if ( type==BCF_HT_FLAG ) return 1;

    bcf_info_t *info = &line->d.info[i];
    if ( !info->vptr ) return -3;           // the tag was marked for removal
    if ( type==BCF_HT_STR )
    {
        if ( *ndst < info->len+1 )
        {
            *ndst = info->len + 1;
            *dst  = realloc(*dst, *ndst);
        }
        memcpy(*dst,info->vptr,info->len);
        ((uint8_t*)*dst)[info->len] = 0;
        return info->len;
    }

    // Make sure the buffer is big enough
    int size1;
    switch (type) {
        case BCF_HT_INT:  size1 = sizeof(int32_t); break;
        case BCF_HT_LONG: size1 = sizeof(int64_t); break;
        case BCF_HT_REAL: size1 = sizeof(float); break;
        default:
            hts_log_error("Unexpected output type %d at %s:%"PRIhts_pos, type, bcf_seqname_safe(hdr,line), line->pos+1);
            return -2;
    }
    if ( *ndst < info->len )
    {
        *ndst = info->len;
        *dst  = realloc(*dst, *ndst * size1);
    }

    #define BRANCH(type_t, convert, is_missing, is_vector_end, set_missing, set_regular, out_type_t) do { \
        out_type_t *tmp = (out_type_t *) *dst; \
        int j; \
        for (j=0; j<info->len; j++) \
        { \
            type_t p = convert(info->vptr + j * sizeof(type_t)); \
            if ( is_vector_end ) break; \
            if ( is_missing ) set_missing; \
            else set_regular; \
            tmp++; \
        } \
        ret = j; \
    } while (0)
    switch (info->type) {
        case BCF_BT_INT8:
            if (type == BCF_HT_LONG) {
                BRANCH(int8_t,  le_to_i8,  p==bcf_int8_missing,  p==bcf_int8_vector_end,  *tmp=bcf_int64_missing, *tmp=p, int64_t);
            } else {
                BRANCH(int8_t,  le_to_i8,  p==bcf_int8_missing,  p==bcf_int8_vector_end,  *tmp=bcf_int32_missing, *tmp=p, int32_t);
            }
            break;
        case BCF_BT_INT16:
            if (type == BCF_HT_LONG) {
                BRANCH(int16_t, le_to_i16, p==bcf_int16_missing, p==bcf_int16_vector_end, *tmp=bcf_int64_missing, *tmp=p, int64_t);
            } else {
                BRANCH(int16_t, le_to_i16, p==bcf_int16_missing, p==bcf_int16_vector_end, *tmp=bcf_int32_missing, *tmp=p, int32_t);
            }
            break;
        case BCF_BT_INT32:
            if (type == BCF_HT_LONG) {
                BRANCH(int32_t, le_to_i32, p==bcf_int32_missing, p==bcf_int32_vector_end, *tmp=bcf_int64_missing, *tmp=p, int64_t); break;
            } else {
                BRANCH(int32_t, le_to_i32, p==bcf_int32_missing, p==bcf_int32_vector_end, *tmp=bcf_int32_missing, *tmp=p, int32_t); break;
            }
        case BCF_BT_FLOAT: BRANCH(uint32_t, le_to_u32, p==bcf_float_missing, p==bcf_float_vector_end, bcf_float_set_missing(*tmp), bcf_float_set(tmp, p), float); break;
        default: hts_log_error("Unexpected type %d at %s:%"PRIhts_pos, info->type, bcf_seqname_safe(hdr,line), line->pos+1); return -2;
    }
    #undef BRANCH
    return ret;  // set by BRANCH
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %r15d
movq %r8, %rbp
movq %rcx, %rbx
movq %rsi, %r12
movq %rdi, %r13
xorl %esi, %esi
callq 0x2489c
pushq $-0x1
popq %r8
testl %eax, %eax
js 0x2fef0
movl %eax, %r14d
cmpl (%r13), %eax
jge 0x2fef0
movq 0x10(%r13), %rax
movl %r14d, %ecx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
testq %rax, %rax
je 0x2fef0
movq 0x8(%rax), %rax
movl %eax, %ecx
notl %ecx
testb $0xf, %cl
je 0x2fef0
shrl $0x4, %eax
andl $0xf, %eax
movzbl %r15b, %ecx
pushq $-0x2
popq %r8
cmpl %ecx, %eax
jne 0x2fef0
movq %rbx, (%rsp)
testb $0x4, 0xbc(%r12)
jne 0x2feb4
pushq $0x4
popq %rsi
movq %r12, %rdi
movq %r8, %rbx
callq 0x2b198
movq %rbx, %r8
movzwl 0x18(%r12), %eax
imulq $0x28, %rax, %rcx
xorl %ebx, %ebx
cmpq %rbx, %rcx
je 0x2fee0
movq 0x90(%r12), %rdx
cmpl %r14d, (%rdx,%rbx)
je 0x2fed9
addq $0x28, %rbx
jmp 0x2fec0
imull $0x28, %eax, %eax
cmpl %ebx, %eax
jne 0x2ff02
xorl %eax, %eax
testl %r15d, %r15d
sete %al
leal (%rax,%rax,2), %r8d
addl $-0x3, %r8d
movl %r8d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r15d, %r15d
je 0x2ff82
movq 0x90(%r12), %r14
movq 0x10(%r14,%rbx), %rsi
testq %rsi, %rsi
je 0x2ff86
leal -0x1(%r15), %eax
cmpl $0x2, %eax
jb 0x2ff8f
cmpl $0x101, %r15d           # imm = 0x101
je 0x2ff93
cmpl $0x3, %r15d
jne 0x30041
movl 0x20(%r14,%rbx), %eax
movq (%rsp), %r15
movq (%r15), %rdi
cmpl %eax, (%rbp)
jg 0x2ff64
movslq %eax, %rsi
incq %rsi
movl %esi, (%rbp)
callq 0x4860
movq %rax, %rdi
movq %rax, (%r15)
movq 0x10(%r14,%rbx), %rsi
movl 0x20(%r14,%rbx), %eax
movslq %eax, %rdx
callq 0x43c0
movq (%r15), %rax
movslq 0x20(%r14,%rbx), %rcx
movb $0x0, (%rax,%rcx)
movl 0x20(%r14,%rbx), %r8d
jmp 0x2fef0
pushq $0x1
jmp 0x2ff88
pushq $-0x3
popq %r8
jmp 0x2fef0
pushq $0x4
jmp 0x2ff95
pushq $0x8
popq %rax
movl 0x20(%r14,%rbx), %ecx
cmpl %ecx, (%rbp)
jge 0x2ffbe
movl %ecx, (%rbp)
movq (%rsp), %rbp
movq (%rbp), %rdi
imull %ecx, %eax
movslq %eax, %rsi
callq 0x4860
pushq $-0x2
popq %r8
movq %rax, (%rbp)
movl 0x4(%r14,%rbx), %ebp
leal -0x1(%rbp), %eax
cmpl $0x4, %eax
ja 0x30167
leaq 0x55c9e(%rip), %rcx     # 0x85c74
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rsp), %rax
movq (%rax), %rax
cmpl $0x101, %r15d           # imm = 0x101
jne 0x301d8
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movl 0x20(%r14,%rbx), %r8d
xorl %ecx, %ecx
testl %r8d, %r8d
cmovlel %ecx, %r8d
cmpq %rcx, %r8
je 0x2fef0
movq 0x10(%r14,%rbx), %rsi
movzbl (%rsi,%rcx), %esi
movq %rdx, %rdi
cmpl $0x80, %esi
je 0x30038
cmpl $0x81, %esi
je 0x301a1
movsbq %sil, %rdi
movq %rdi, (%rax,%rcx,8)
incq %rcx
jmp 0x3000b
movq %r13, %rdi
movq %r12, %rsi
movq %r8, %rbx
callq 0x27650
movq (%r12), %r9
incq %r9
leaq 0x570cc(%rip), %rsi     # 0x87129
leaq 0x570d9(%rip), %rdx     # 0x8713d
pushq $0x1
popq %rdi
movl %r15d, %ecx
jmp 0x3018f
movq (%rsp), %rax
movq (%rax), %rax
cmpl $0x101, %r15d           # imm = 0x101
jne 0x301a9
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movl 0x20(%r14,%rbx), %r8d
xorl %ecx, %ecx
testl %r8d, %r8d
cmovlel %ecx, %r8d
cmpq %rcx, %r8
je 0x2fef0
movq 0x10(%r14,%rbx), %rsi
movslq (%rsi,%rcx,4), %rsi
movq %rdx, %rdi
cmpq $-0x80000000, %rsi      # imm = 0x80000000
je 0x300c8
cmpl $0x80000001, %esi       # imm = 0x80000001
je 0x301a1
movq %rsi, %rdi
movq %rdi, (%rax,%rcx,8)
incq %rcx
jmp 0x3009b
movq (%rsp), %rax
movq (%rax), %rax
cmpl $0x101, %r15d           # imm = 0x101
jne 0x30218
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movl 0x20(%r14,%rbx), %r8d
xorl %ecx, %ecx
testl %r8d, %r8d
cmovlel %ecx, %r8d
cmpq %rcx, %r8
je 0x2fef0
movq 0x10(%r14,%rbx), %rsi
movzwl (%rsi,%rcx,2), %esi
movq %rdx, %rdi
cmpl $0x8000, %esi           # imm = 0x8000
je 0x30126
cmpl $0x8001, %esi           # imm = 0x8001
je 0x301a1
movswq %si, %rdi
movq %rdi, (%rax,%rcx,8)
incq %rcx
jmp 0x300fd
movq (%rsp), %rax
movq (%rax), %rax
movl 0x20(%r14,%rbx), %r8d
movl 0x7f3d3(%rip), %edx     # 0xaf514
xorl %ecx, %ecx
testl %r8d, %r8d
cmovlel %ecx, %r8d
cmpq %rcx, %r8
je 0x2fef0
movq 0x10(%r14,%rbx), %rsi
movl (%rsi,%rcx,4), %esi
cmpl %edx, %esi
je 0x301a1
movl %esi, (%rax,%rcx,4)
incq %rcx
jmp 0x3014a
movq %r13, %rdi
movq %r12, %rsi
movq %r8, %rbx
callq 0x27650
movq (%r12), %r9
incq %r9
leaq 0x56fa6(%rip), %rsi     # 0x87129
leaq 0x569dd(%rip), %rdx     # 0x86b67
pushq $0x1
popq %rdi
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x8132
movq %rbx, %r8
jmp 0x2fef0
movl %ecx, %r8d
jmp 0x2fef0
xorl %r8d, %r8d
movslq 0x20(%r14,%rbx), %rcx
cmpq %rcx, %r8
jge 0x2fef0
movq 0x10(%r14,%rbx), %rcx
movl (%rcx,%r8,4), %ecx
cmpl $0x80000001, %ecx       # imm = 0x80000001
je 0x2fef0
movl %ecx, (%rax,%r8,4)
incq %r8
jmp 0x301ac
xorl %r8d, %r8d
movslq 0x20(%r14,%rbx), %rcx
cmpq %rcx, %r8
jge 0x2fef0
movq 0x10(%r14,%rbx), %rcx
movzbl (%rcx,%r8), %ecx
movl $0x80000000, %edx       # imm = 0x80000000
cmpl $0x80, %ecx
je 0x3020f
cmpl $0x81, %ecx
je 0x2fef0
movsbl %cl, %edx
movl %edx, (%rax,%r8,4)
incq %r8
jmp 0x301db
xorl %r8d, %r8d
movslq 0x20(%r14,%rbx), %rcx
cmpq %rcx, %r8
jge 0x2fef0
movq 0x10(%r14,%rbx), %rcx
movzwl (%rcx,%r8,2), %ecx
movl $0x80000000, %edx       # imm = 0x80000000
cmpl $0x8000, %ecx           # imm = 0x8000
je 0x3024f
cmpl $0x8001, %ecx           # imm = 0x8001
je 0x2fef0
movswl %cx, %edx
movl %edx, (%rax,%r8,4)
incq %r8
jmp 0x3021b