// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_get_format_values
int bcf_get_format_values(const bcf_hdr_t *hdr, bcf1_t *line, const char *tag, void **dst, int *ndst, int type)
{
    int i,j, tag_id = bcf_hdr_id2int(hdr, BCF_DT_ID, tag);
    if ( !bcf_hdr_idinfo_exists(hdr,BCF_HL_FMT,tag_id) ) return -1;    // no such FORMAT field in the header
    if ( tag[0]=='G' && tag[1]=='T' && tag[2]==0 )
    {
        // Ugly: GT field is considered to be a string by the VCF header but BCF represents it as INT.
        if ( bcf_hdr_id2type(hdr,BCF_HL_FMT,tag_id)!=BCF_HT_STR ) return -2;
    }
    else if ( bcf_hdr_id2type(hdr,BCF_HL_FMT,tag_id)!=type ) return -2;     // expected different type

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

    for (i=0; i<line->n_fmt; i++)
        if ( line->d.fmt[i].id==tag_id ) break;
    if ( i==line->n_fmt ) return -3;                               // the tag is not present in this record
    bcf_fmt_t *fmt = &line->d.fmt[i];
    if ( !fmt->p ) return -3;                                      // the tag was marked for removal

    if ( type==BCF_HT_STR )
    {
        int n = fmt->n*bcf_hdr_nsamples(hdr);
        if ( *ndst < n )
        {
            *dst  = realloc(*dst, n);
            if ( !*dst ) return -4;     // could not alloc
            *ndst = n;
        }
        memcpy(*dst,fmt->p,n);
        return n;
    }

    // Make sure the buffer is big enough
    int nsmpl = bcf_hdr_nsamples(hdr);
    int size1 = type==BCF_HT_INT ? sizeof(int32_t) : sizeof(float);
    if ( *ndst < fmt->n*nsmpl )
    {
        *ndst = fmt->n*nsmpl;
        *dst  = realloc(*dst, *ndst*size1);
        if ( !*dst ) return -4;     // could not alloc
    }

    #define BRANCH(type_t, convert, is_missing, is_vector_end, set_missing, set_vector_end, set_regular, out_type_t) { \
        out_type_t *tmp = (out_type_t *) *dst; \
        uint8_t *fmt_p = fmt->p; \
        for (i=0; i<nsmpl; i++) \
        { \
            for (j=0; j<fmt->n; j++) \
            { \
                type_t p = convert(fmt_p + j * sizeof(type_t)); \
                if ( is_missing ) set_missing; \
                else if ( is_vector_end ) { set_vector_end; break; } \
                else set_regular; \
                tmp++; \
            } \
            for (; j<fmt->n; j++) { set_vector_end; tmp++; } \
            fmt_p += fmt->size; \
        } \
    }
    switch (fmt->type) {
        case BCF_BT_INT8:  BRANCH(int8_t,  le_to_i8, p==bcf_int8_missing,  p==bcf_int8_vector_end,  *tmp=bcf_int32_missing, *tmp=bcf_int32_vector_end, *tmp=p, int32_t); break;
        case BCF_BT_INT16: BRANCH(int16_t, le_to_i16, p==bcf_int16_missing, p==bcf_int16_vector_end, *tmp=bcf_int32_missing, *tmp=bcf_int32_vector_end, *tmp=p, int32_t); break;
        case BCF_BT_INT32: BRANCH(int32_t, le_to_i32, p==bcf_int32_missing, p==bcf_int32_vector_end, *tmp=bcf_int32_missing, *tmp=bcf_int32_vector_end, *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_vector_end(*tmp), bcf_float_set(tmp, p), float); break;
        default: hts_log_error("Unexpected type %d at %s:%"PRIhts_pos, fmt->type, bcf_seqname_safe(hdr,line), line->pos+1); exit(1);
    }
    #undef BRANCH
    return nsmpl*fmt->n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
xorl %esi, %esi
callq 0x3e820
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jl 0x50bb4
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x50bb4
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x50bb4
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
andq $0xf, %rax
cmpl $0xf, %eax
jne 0x50bc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x51319
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x47, %eax
jne 0x50c1c
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x54, %eax
jne 0x50c1c
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x50c1c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
shrq $0x4, %rax
andq $0xf, %rax
cmpl $0x3, %eax
je 0x50c1a
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x51319
jmp 0x50c52
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
shrq $0x4, %rax
andq $0xf, %rax
cmpl -0x34(%rbp), %eax
je 0x50c50
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x51319
jmp 0x50c52
movq -0x18(%rbp), %rax
movl 0xbc(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x50c72
movq -0x18(%rbp), %rdi
movl $0x8, %esi
callq 0x48110
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
andq $0xff, %rcx
cmpl %ecx, %eax
jge 0x50cbf
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x40(%rbp), %eax
jne 0x50cb2
jmp 0x50cbf
jmp 0x50cb4
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x50c79
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
andq $0xff, %rcx
cmpl %ecx, %eax
jne 0x50ce5
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x51319
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x50d16
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x51319
cmpl $0x3, -0x34(%rbp)
jne 0x50d95
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x8(%rcx), %eax
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpl -0x4c(%rbp), %eax
jge 0x50d72
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movslq -0x4c(%rbp), %rsi
callq 0x4840
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x50d69
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x51319
movl -0x4c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x4c(%rbp), %rdx
callq 0x43b0
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x51319
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x34(%rbp), %ecx
movl $0x4, %eax
cmpl $0x1, %ecx
cmoveq %rax, %rax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
movq -0x48(%rbp), %rcx
movl 0x4(%rcx), %ecx
imull -0x50(%rbp), %ecx
cmpl %ecx, %eax
jge 0x50e12
movq -0x48(%rbp), %rax
movl 0x4(%rax), %ecx
imull -0x50(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movl (%rax), %eax
imull -0x54(%rbp), %eax
movslq %eax, %rsi
callq 0x4840
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x50e10
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x51319
jmp 0x50e12
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0xc0(%rbp)
subl $0x4, %eax
ja 0x512b9
movq -0xc0(%rbp), %rax
leaq 0xb61c5(%rip), %rcx     # 0x107000
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x50f37
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x50ee5
movq -0x68(%rbp), %rdi
movslq -0x3c(%rbp), %rax
shlq $0x0, %rax
addq %rax, %rdi
callq 0x45340
movb %al, -0x69(%rbp)
movsbl -0x69(%rbp), %eax
cmpl $-0x80, %eax
jne 0x50ead
movq -0x60(%rbp), %rax
movl $0x80000000, (%rax)     # imm = 0x80000000
jmp 0x50ece
movsbl -0x69(%rbp), %eax
cmpl $-0x7f, %eax
jne 0x50ec2
movq -0x60(%rbp), %rax
movl $0x80000001, (%rax)     # imm = 0x80000001
jmp 0x50ee5
movsbl -0x69(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, (%rax)
jmp 0x50ece
movq -0x60(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x60(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x50e75
jmp 0x50ee7
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x50f14
movq -0x60(%rbp), %rax
movl $0x80000001, (%rax)     # imm = 0x80000001
movq -0x60(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x60(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x50ee7
movq -0x48(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x68(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x50e62
jmp 0x5130b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x5103f
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x50fed
movq -0x80(%rbp), %rdi
movslq -0x3c(%rbp), %rax
shlq %rax
addq %rax, %rdi
callq 0x45390
movw %ax, -0x82(%rbp)
movswl -0x82(%rbp), %eax
cmpl $0xffff8000, %eax       # imm = 0xFFFF8000
jne 0x50fad
movq -0x78(%rbp), %rax
movl $0x80000000, (%rax)     # imm = 0x80000000
jmp 0x50fd6
movswl -0x82(%rbp), %eax
cmpl $0xffff8001, %eax       # imm = 0xFFFF8001
jne 0x50fc7
movq -0x78(%rbp), %rax
movl $0x80000001, (%rax)     # imm = 0x80000001
jmp 0x50fed
movswl -0x82(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, (%rax)
jmp 0x50fd6
movq -0x78(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x78(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x50f6d
jmp 0x50fef
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x5101c
movq -0x78(%rbp), %rax
movl $0x80000001, (%rax)     # imm = 0x80000001
movq -0x78(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x78(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x50fef
movq -0x48(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x80(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x50f5a
jmp 0x5130b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x51170
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x5110f
movq -0x98(%rbp), %rdi
movslq -0x3c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
callq 0x453e0
movl %eax, -0x9c(%rbp)
cmpl $0x80000000, -0x9c(%rbp) # imm = 0x80000000
jne 0x510c3
movq -0x90(%rbp), %rax
movl $0x80000000, (%rax)     # imm = 0x80000000
jmp 0x510ef
cmpl $0x80000001, -0x9c(%rbp) # imm = 0x80000001
jne 0x510de
movq -0x90(%rbp), %rax
movl $0x80000001, (%rax)     # imm = 0x80000001
jmp 0x5110f
movl -0x9c(%rbp), %ecx
movq -0x90(%rbp), %rax
movl %ecx, (%rax)
jmp 0x510ef
movq -0x90(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x90(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5107b
jmp 0x51111
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x51147
movq -0x90(%rbp), %rax
movl $0x80000001, (%rax)     # imm = 0x80000001
movq -0x90(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x90(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x51111
movq -0x48(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x98(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x51068
jmp 0x5130b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb0(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x512b7
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x51251
movq -0xb0(%rbp), %rdi
movslq -0x3c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
callq 0x45430
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl 0xd445b(%rip), %eax     # 0x125640
jne 0x511fb
movq -0xa8(%rbp), %rdi
movl 0xd444c(%rip), %esi     # 0x125640
callq 0x40e90
jmp 0x51231
movl -0xb4(%rbp), %eax
cmpl 0xd443d(%rip), %eax     # 0x125644
jne 0x5121d
movq -0xa8(%rbp), %rdi
movl 0xd442e(%rip), %esi     # 0x125644
callq 0x40e90
jmp 0x51251
movq -0xa8(%rbp), %rdi
movl -0xb4(%rbp), %esi
callq 0x40e90
jmp 0x51231
movq -0xa8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xa8(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x511ac
jmp 0x51253
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x5128e
movq -0xa8(%rbp), %rdi
movl 0xd43d8(%rip), %esi     # 0x125644
callq 0x40e90
movq -0xa8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xa8(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x51253
movq -0x48(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0xb0(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x51199
jmp 0x5130b
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0xc4(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x43520
movl -0xc4(%rbp), %ecx
movq %rax, %r8
movq -0x18(%rbp), %rax
movq (%rax), %r9
addq $0x1, %r9
movl $0x1, %edi
leaq 0xb71e2(%rip), %rsi     # 0x1084d5
leaq 0xb6be1(%rip), %rdx     # 0x107edb
movb $0x0, %al
callq 0x9d90
movl $0x1, %edi
callq 0x45d0
movl -0x50(%rbp), %eax
movq -0x48(%rbp), %rcx
imull 0x4(%rcx), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)