// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq %rsi, %r15
movq %rdi, %r13
xorl %esi, %esi
callq 0x2e585
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x41880
movl %eax, %r14d
cmpl (%r13), %eax
jge 0x41880
movq 0x10(%r13), %rax
movl %r14d, %ecx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
testq %rax, %rax
je 0x41880
movq 0x8(%rax), %rax
movl %eax, %ecx
notl %ecx
testb $0xf, %cl
je 0x41880
shrl $0x4, %eax
andl $0xf, %eax
movzbl %r12b, %ecx
movl $0xfffffffe, %r9d       # imm = 0xFFFFFFFE
cmpl %ecx, %eax
jne 0x41880
testb $0x4, 0xbc(%r15)
jne 0x4142c
movq %r15, %rdi
movl $0x4, %esi
callq 0x38e9d
movq 0x18(%r15), %rcx
movl %ecx, %eax
andl $0xffff, %eax           # imm = 0xFFFF
je 0x4145a
movq 0x90(%r15), %rdx
movzwl %cx, %esi
xorl %ecx, %ecx
cmpl %r14d, (%rdx)
je 0x4145c
incq %rcx
addq $0x28, %rdx
cmpq %rcx, %rsi
jne 0x41445
movl %eax, %ecx
jmp 0x4145c
xorl %ecx, %ecx
cmpl %eax, %ecx
jne 0x41475
xorl %eax, %eax
testl %r12d, %r12d
sete %al
leal (%rax,%rax,2), %r9d
addl $-0x3, %r9d
jmp 0x41880
testl %r12d, %r12d
je 0x414f3
movq 0x90(%r15), %rax
movl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x414fe
leaq (%rax,%rcx,8), %r14
movl $0x4, %eax
leal -0x1(%r12), %ecx
cmpl $0x2, %ecx
jb 0x4150e
cmpl $0x101, %r12d           # imm = 0x101
je 0x41509
cmpl $0x3, %r12d
jne 0x415b8
movslq 0x20(%r14), %rsi
cmpl %esi, (%rbp)
jg 0x414cf
incq %rsi
movl %esi, (%rbp)
movq (%rbx), %rdi
callq 0x4860
movq %rax, (%rbx)
movq (%rbx), %rdi
movq 0x10(%r14), %rsi
movslq 0x20(%r14), %rdx
callq 0x43c0
movq (%rbx), %rax
movslq 0x20(%r14), %rcx
movb $0x0, (%rax,%rcx)
movl 0x20(%r14), %r9d
jmp 0x41880
movl $0x1, %r9d
jmp 0x41880
movl $0xfffffffd, %r9d       # imm = 0xFFFFFFFD
jmp 0x41880
movl $0x8, %eax
movl 0x20(%r14), %ecx
cmpl %ecx, (%rbp)
jge 0x4152b
movl %ecx, (%rbp)
movq (%rbx), %rdi
imull %ecx, %eax
movslq %eax, %rsi
callq 0x4860
movq %rax, (%rbx)
movl 0x4(%r14), %ecx
leal -0x1(%rcx), %eax
cmpl $0x4, %eax
ja 0x416e2
leaq 0x6ca3e(%rip), %rdx     # 0xadf80
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl 0x20(%r14), %eax
cmpl $0x101, %r12d           # imm = 0x101
jne 0x41785
testl %eax, %eax
jle 0x41826
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq (%rbx), %rdx
movq 0x10(%r14), %rsi
xorl %r9d, %r9d
movzbl (%rsi,%r9), %edi
movq %rcx, %r8
cmpl $0x80, %edi
je 0x41598
cmpl $0x81, %edi
jne 0x41594
xorl %edi, %edi
jmp 0x415a2
movsbq %dil, %r8
movq %r8, (%rdx)
addq $0x8, %rdx
movb $0x1, %dil
testb %dil, %dil
je 0x41880
incq %r9
cmpq %r9, %rax
jne 0x41578
jmp 0x416da
testq %r15, %r15
je 0x416f4
movl 0x10(%r15), %eax
jmp 0x416f9
movl 0x20(%r14), %eax
cmpl $0x101, %r12d           # imm = 0x101
jne 0x41744
testl %eax, %eax
jle 0x41826
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq (%rbx), %rdx
movq 0x10(%r14), %rsi
xorl %r9d, %r9d
movslq (%rsi,%r9,4), %rdi
movq %rcx, %r8
cmpq $-0x80000000, %rdi      # imm = 0x80000000
je 0x41616
cmpl $0x80000001, %edi       # imm = 0x80000001
jne 0x41613
xorl %edi, %edi
jmp 0x41620
movq %rdi, %r8
movq %r8, (%rdx)
addq $0x8, %rdx
movb $0x1, %dil
testb %dil, %dil
je 0x41880
incq %r9
cmpq %r9, %rax
jne 0x415f7
jmp 0x416da
movl 0x20(%r14), %eax
cmpl $0x101, %r12d           # imm = 0x101
jne 0x417db
testl %eax, %eax
jle 0x41826
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq (%rbx), %rdx
movq 0x10(%r14), %rsi
xorl %r9d, %r9d
movzwl (%rsi,%r9,2), %edi
movq %rcx, %r8
cmpl $0x8000, %edi           # imm = 0x8000
je 0x41683
cmpl $0x8001, %edi           # imm = 0x8001
jne 0x4167f
xorl %edi, %edi
jmp 0x4168d
movswq %di, %r8
movq %r8, (%rdx)
addq $0x8, %rdx
movb $0x1, %dil
testb %dil, %dil
je 0x41880
incq %r9
cmpq %r9, %rax
jne 0x41663
jmp 0x416da
movl 0x20(%r14), %eax
testl %eax, %eax
jle 0x41826
movq (%rbx), %rcx
movq 0x10(%r14), %rdx
movl 0x8de5b(%rip), %esi     # 0xcf514
xorl %r9d, %r9d
movl (%rdx,%r9,4), %edi
cmpl %esi, %edi
je 0x416ca
movl %edi, (%rcx)
addq $0x4, %rcx
cmpl %esi, %edi
je 0x41880
incq %r9
cmpq %r9, %rax
jne 0x416bc
movl %eax, %r9d
jmp 0x41880
testq %r15, %r15
je 0x4182b
movl 0x10(%r15), %eax
jmp 0x41830
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x41713
cmpl %eax, 0x4(%r13)
jle 0x41713
movq 0x18(%r13), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x41715
xorl %eax, %eax
testq %rax, %rax
leaq 0x6e240(%rip), %r8      # 0xaf95f
cmovneq %rax, %r8
movq (%r15), %r9
incq %r9
leaq 0x6dced(%rip), %rsi     # 0xaf41d
leaq 0x6dcfa(%rip), %rdx     # 0xaf431
movl $0x1, %edi
movl %r12d, %ecx
jmp 0x41873
testl %eax, %eax
jle 0x41826
movq (%rbx), %rax
movq 0x10(%r14), %rcx
xorl %r9d, %r9d
movl (%rcx,%r9,4), %edx
cmpl $0x80000001, %edx       # imm = 0x80000001
je 0x41768
movl %edx, (%rax)
addq $0x4, %rax
cmpl $0x80000001, %edx       # imm = 0x80000001
je 0x41880
incq %r9
movslq 0x20(%r14), %rdx
cmpq %rdx, %r9
jl 0x41756
jmp 0x41880
testl %eax, %eax
jle 0x41826
movq (%rbx), %rax
movq 0x10(%r14), %rcx
xorl %r9d, %r9d
movzbl (%rcx,%r9), %edx
cmpl $0x80, %edx
je 0x417b0
cmpl $0x81, %edx
jne 0x417b7
xorl %edx, %edx
jmp 0x417c2
movl $0x80000000, %edx       # imm = 0x80000000
jmp 0x417ba
movsbl %dl, %edx
movl %edx, (%rax)
addq $0x4, %rax
movb $0x1, %dl
testb %dl, %dl
je 0x41880
incq %r9
movslq 0x20(%r14), %rdx
cmpq %rdx, %r9
jl 0x41797
jmp 0x41880
testl %eax, %eax
jle 0x41826
movq (%rbx), %rax
movq 0x10(%r14), %rcx
xorl %r9d, %r9d
movzwl (%rcx,%r9,2), %edx
cmpl $0x8000, %edx           # imm = 0x8000
je 0x41802
cmpl $0x8001, %edx           # imm = 0x8001
jne 0x41809
xorl %edx, %edx
jmp 0x41814
movl $0x80000000, %edx       # imm = 0x80000000
jmp 0x4180c
movswl %dx, %edx
movl %edx, (%rax)
addq $0x4, %rax
movb $0x1, %dl
testb %dl, %dl
je 0x41880
incq %r9
movslq 0x20(%r14), %rdx
cmpq %rdx, %r9
jl 0x417e9
jmp 0x41880
xorl %r9d, %r9d
jmp 0x41880
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x4184a
cmpl %eax, 0x4(%r13)
jle 0x4184a
movq 0x18(%r13), %rdx
movl %eax, %eax
shlq $0x4, %rax
movq (%rdx,%rax), %rax
jmp 0x4184c
xorl %eax, %eax
testq %rax, %rax
leaq 0x6e109(%rip), %r8      # 0xaf95f
cmovneq %rax, %r8
movq (%r15), %r9
incq %r9
leaq 0x6dbb6(%rip), %rsi     # 0xaf41d
leaq 0x6d5f0(%rip), %rdx     # 0xaee5e
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
movl $0xfffffffe, %r9d       # imm = 0xFFFFFFFE
movl %r9d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq