// File: /workspace/github_c_makefile_star2_O3/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, %r12d
movq %r8, %rbp
movq %rcx, (%rsp)
movq %rsi, %r15
movq %rdi, %r13
xorl %esi, %esi
callq 0x2d3d9
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x405fa
movl %eax, %r14d
cmpl (%r13), %eax
jge 0x405fa
movq 0x10(%r13), %rax
movl %r14d, %ecx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
testq %rax, %rax
je 0x405fa
movq 0x8(%rax), %rax
movl %eax, %ecx
notl %ecx
testb $0xf, %cl
je 0x405fa
shrl $0x4, %eax
andl $0xf, %eax
movzbl %r12b, %ecx
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
cmpl %ecx, %eax
jne 0x405fa
testb $0x4, 0xbc(%r15)
jne 0x405ba
movq %r15, %rdi
movl $0x4, %esi
callq 0x38183
movq 0x18(%r15), %rcx
movl %ecx, %eax
andl $0xffff, %eax           # imm = 0xFFFF
je 0x405e6
movq 0x90(%r15), %rdx
movzwl %cx, %esi
xorl %ecx, %ecx
cmpl %r14d, (%rdx)
je 0x405e8
incq %rcx
addq $0x28, %rdx
cmpq %rcx, %rsi
jne 0x405d3
jmp 0x405ec
xorl %ecx, %ecx
cmpl %eax, %ecx
jne 0x4060b
xorl %eax, %eax
testl %r12d, %r12d
sete %al
leal (%rax,%rax,2), %ebx
addl $-0x3, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r12d, %r12d
je 0x40699
movq 0x90(%r15), %rax
movl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
movq 0x10(%rax,%rcx,8), %rsi
testq %rsi, %rsi
je 0x406a3
leaq (%rax,%rcx,8), %r14
movl $0x4, %eax
leal -0x1(%r12), %ecx
cmpl $0x2, %ecx
jb 0x406b2
cmpl $0x101, %r12d           # imm = 0x101
je 0x406ad
cmpl $0x3, %r12d
jne 0x40755
movl 0x20(%r14), %eax
movq (%rsp), %rbx
movq (%rbx), %rdi
cmpl %eax, (%rbp)
jg 0x4067d
movslq %eax, %rsi
incq %rsi
movl %esi, (%rbp)
callq 0x4860
movq %rax, %rdi
movq %rax, (%rbx)
movq 0x10(%r14), %rsi
movl 0x20(%r14), %eax
movslq %eax, %rdx
callq 0x43c0
movq (%rbx), %rax
movslq 0x20(%r14), %rcx
movb $0x0, (%rax,%rcx)
movl 0x20(%r14), %ebx
jmp 0x405fa
movl $0x1, %ebx
jmp 0x405fa
movl $0xfffffffd, %ebx       # imm = 0xFFFFFFFD
jmp 0x405fa
movl $0x8, %eax
movl 0x20(%r14), %ecx
cmpl %ecx, (%rbp)
jge 0x406d5
movl %ecx, (%rbp)
movq (%rsp), %rbp
movq (%rbp), %rdi
imull %ecx, %eax
movslq %eax, %rsi
callq 0x4860
movq %rax, (%rbp)
movl 0x4(%r14), %ecx
leal -0x1(%rcx), %eax
cmpl $0x4, %eax
ja 0x4089c
leaq 0x6a840(%rip), %rdx     # 0xaaf2c
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl 0x20(%r14), %eax
cmpl $0x101, %r12d           # imm = 0x101
jne 0x40926
testl %eax, %eax
movq (%rsp), %rdx
jle 0x409b4
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq (%rdx), %rdx
movq 0x10(%r14), %rsi
xorl %ebx, %ebx
movzbl (%rsi,%rbx), %edi
movq %rcx, %r8
cmpl $0x80, %edi
je 0x40744
cmpl $0x81, %edi
je 0x405fa
movsbq %dil, %r8
movq %r8, (%rdx,%rbx,8)
incq %rbx
cmpq %rbx, %rax
jne 0x40725
jmp 0x40895
movslq 0x10(%r15), %rax
testq %rax, %rax
js 0x40772
cmpl %eax, 0x4(%r13)
jle 0x40772
movq 0x18(%r13), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x40774
xorl %eax, %eax
testq %rax, %rax
leaq 0x6c191(%rip), %r8      # 0xac90f
cmovneq %rax, %r8
movq (%r15), %r9
incq %r9
leaq 0x6bc3e(%rip), %rsi     # 0xac3cd
leaq 0x6bc4b(%rip), %rdx     # 0xac3e1
movl $0x1, %edi
movl %r12d, %ecx
jmp 0x408e2
movl 0x20(%r14), %eax
cmpl $0x101, %r12d           # imm = 0x101
jne 0x408ee
testl %eax, %eax
movq (%rsp), %rdx
jle 0x409b4
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq (%rdx), %rdx
movq 0x10(%r14), %rsi
xorl %ebx, %ebx
movslq (%rsi,%rbx,4), %rdi
movq %rcx, %r8
cmpq $-0x80000000, %rdi      # imm = 0x80000000
je 0x407f2
cmpl $0x80000001, %edi       # imm = 0x80000001
je 0x405fa
movq %rdi, %r8
movq %r8, (%rdx,%rbx,8)
incq %rbx
cmpq %rbx, %rax
jne 0x407d3
jmp 0x40895
movl 0x20(%r14), %eax
cmpl $0x101, %r12d           # imm = 0x101
jne 0x4096f
testl %eax, %eax
movq (%rsp), %rdx
jle 0x409b4
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq (%rdx), %rdx
movq 0x10(%r14), %rsi
xorl %ebx, %ebx
movzwl (%rsi,%rbx,2), %edi
movq %rcx, %r8
cmpl $0x8000, %edi           # imm = 0x8000
je 0x40852
cmpl $0x8001, %edi           # imm = 0x8001
je 0x405fa
movswq %di, %r8
movq %r8, (%rdx,%rbx,8)
incq %rbx
cmpq %rbx, %rax
jne 0x40833
jmp 0x40895
movl 0x20(%r14), %eax
testl %eax, %eax
jle 0x409b4
movq (%rsp), %rcx
movq (%rcx), %rcx
movq 0x10(%r14), %rdx
movl 0x8cc97(%rip), %esi     # 0xcd514
xorl %ebx, %ebx
movl (%rdx,%rbx,4), %edi
cmpl %esi, %edi
je 0x405fa
movl %edi, (%rcx,%rbx,4)
incq %rbx
cmpq %rbx, %rax
jne 0x4087f
movl %eax, %ebx
jmp 0x405fa
movslq 0x10(%r15), %rax
testq %rax, %rax
js 0x408b9
cmpl %eax, 0x4(%r13)
jle 0x408b9
movq 0x18(%r13), %rdx
shlq $0x4, %rax
movq (%rdx,%rax), %rax
jmp 0x408bb
xorl %eax, %eax
testq %rax, %rax
leaq 0x6c04a(%rip), %r8      # 0xac90f
cmovneq %rax, %r8
movq (%r15), %r9
incq %r9
leaq 0x6baf7(%rip), %rsi     # 0xac3cd
leaq 0x6b531(%rip), %rdx     # 0xabe0e
movl $0x1, %edi
xorl %eax, %eax
callq 0x942d
jmp 0x405fa
testl %eax, %eax
movq (%rsp), %rax
jle 0x409b4
movq (%rax), %rax
movq 0x10(%r14), %rcx
xorl %ebx, %ebx
movl (%rcx,%rbx,4), %edx
cmpl $0x80000001, %edx       # imm = 0x80000001
je 0x405fa
movl %edx, (%rax,%rbx,4)
incq %rbx
movslq 0x20(%r14), %rdx
cmpq %rdx, %rbx
jl 0x40903
jmp 0x405fa
testl %eax, %eax
movq (%rsp), %rax
jle 0x409b4
movq (%rax), %rax
movq 0x10(%r14), %rcx
xorl %ebx, %ebx
movzbl (%rcx,%rbx), %edx
movl $0x80000000, %esi       # imm = 0x80000000
cmpl $0x80, %edx
je 0x4095b
cmpl $0x81, %edx
je 0x405fa
movsbl %dl, %esi
movl %esi, (%rax,%rbx,4)
incq %rbx
movslq 0x20(%r14), %rdx
cmpq %rdx, %rbx
jl 0x4093b
jmp 0x405fa
testl %eax, %eax
movq (%rsp), %rax
jle 0x409b4
movq (%rax), %rax
movq 0x10(%r14), %rcx
xorl %ebx, %ebx
movzwl (%rcx,%rbx,2), %edx
movl $0x80000000, %esi       # imm = 0x80000000
cmpl $0x8000, %edx           # imm = 0x8000
je 0x409a0
cmpl $0x8001, %edx           # imm = 0x8001
je 0x405fa
movswl %dx, %esi
movl %esi, (%rax,%rbx,4)
incq %rbx
movslq 0x20(%r14), %rdx
cmpq %rdx, %rbx
jl 0x40980
jmp 0x405fa
xorl %ebx, %ebx
jmp 0x405fa