// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_update_format
int bcf_update_format(const bcf_hdr_t *hdr, bcf1_t *line, const char *key, const void *values, int n, int type)
{
    // Is the field already present?
    int i, fmt_id = bcf_hdr_id2int(hdr,BCF_DT_ID,key);
    int is_len = 0;
    if ( !bcf_hdr_idinfo_exists(hdr,BCF_HL_FMT,fmt_id) )
    {
        if ( !n ) return 0;
        return -1;  // the key not present in the header
    }

    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==fmt_id ) break;
    bcf_fmt_t *fmt = i==line->n_fmt ? NULL : &line->d.fmt[i];

    is_len = strcmp(key, "LEN") == 0;
    if ( !n )
    {
        if ( fmt )
        {
            // Mark the tag for removal, free existing memory if necessary
            if ( fmt->p_free )
            {
                free(fmt->p - fmt->p_off);
                fmt->p_free = 0;
            }
            line->d.indiv_dirty = 1;
            fmt->p = NULL;
        }
        if (is_len) {
            line->rlen = get_rlen(hdr, line);
        }
        return 0;
    }

    line->n_sample = bcf_hdr_nsamples(hdr);
    int nps = n / line->n_sample;  // number of values per sample
    assert( nps && nps*line->n_sample==n );     // must be divisible by n_sample

    // Encode the values and determine the size required to accommodate the values
    kstring_t str = {0,0,0};
    bcf_enc_int1(&str, fmt_id);
    assert(values != NULL);
    if ( type==BCF_HT_INT )
        bcf_enc_vint(&str, n, (int32_t*)values, nps);
    else if ( type==BCF_HT_REAL )
    {
        bcf_enc_size(&str, nps, BCF_BT_FLOAT);
        serialize_float_array(&str, nps*line->n_sample, (float *) values);
    }
    else if ( type==BCF_HT_STR )
    {
        bcf_enc_size(&str, nps, BCF_BT_CHAR);
        kputsn((char*)values, nps*line->n_sample, &str);
    }
    else
    {
        hts_log_error("The type %d not implemented yet at %s:%"PRIhts_pos, type, bcf_seqname_safe(hdr,line), line->pos+1);
        abort();
    }

    if ( !fmt )
    {
        // Not present, new format field
        line->n_fmt++;
        hts_expand0(bcf_fmt_t, line->n_fmt, line->d.m_fmt, line->d.fmt);

        // Special case: VCF specification requires that GT is always first
        if ( line->n_fmt > 1 && key[0]=='G' && key[1]=='T' && !key[2] )
        {
            for (i=line->n_fmt-1; i>0; i--)
                line->d.fmt[i] = line->d.fmt[i-1];
            fmt = &line->d.fmt[0];
        }
        else
            fmt = &line->d.fmt[line->n_fmt-1];
        bcf_unpack_fmt_core1((uint8_t*)str.s, line->n_sample, fmt);
        line->d.indiv_dirty = 1;
        fmt->p_free = 1;
    }
    else
    {
        // The tag is already present, check if it is big enough to accommodate the new block
        if ( fmt->p && str.l <= fmt->p_len + fmt->p_off )
        {
            // good, the block is big enough
            if ( str.l != fmt->p_len + fmt->p_off ) line->d.indiv_dirty = 1;
            uint8_t *ptr = fmt->p - fmt->p_off;
            memcpy(ptr, str.s, str.l);
            free(str.s);
            int p_free = fmt->p_free;
            bcf_unpack_fmt_core1(ptr, line->n_sample, fmt);
            fmt->p_free = p_free;
        }
        else
        {
            if ( fmt->p_free )
                free(fmt->p - fmt->p_off);
            bcf_unpack_fmt_core1((uint8_t*)str.s, line->n_sample, fmt);
            fmt->p_free = 1;
            line->d.indiv_dirty = 1;
        }
    }
    line->unpacked |= BCF_UN_FMT;

    if (is_len) {
        line->rlen = get_rlen(hdr, line);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
xorl %esi, %esi
callq 0x3e820
movl %eax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x0, -0x38(%rbp)
jl 0x4e8fb
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x4e8fb
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x4e8fb
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
andq $0xf, %rax
cmpl $0xf, %eax
jne 0x4e919
cmpl $0x0, -0x2c(%rbp)
jne 0x4e90d
movl $0x0, -0x4(%rbp)
jmp 0x4eff5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4eff5
movq -0x18(%rbp), %rax
movl 0xbc(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x4e939
movq -0x18(%rbp), %rdi
movl $0x8, %esi
callq 0x48110
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
andq $0xff, %rcx
cmpl %ecx, %eax
jge 0x4e986
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x38(%rbp), %eax
jne 0x4e979
jmp 0x4e986
jmp 0x4e97b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4e940
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
andq $0xff, %rcx
cmpl %ecx, %eax
jne 0x4e9a8
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x4e9c2
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
leaq 0xb98a6(%rip), %rsi     # 0x10827b
callq 0x46b0
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x4ea83
cmpq $0x0, -0x48(%rbp)
je 0x4ea59
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x4ea3f
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movslq %eax, %rcx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rdi
callq 0x45a0
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x1c(%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0xb4(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x10(%rax)
cmpl $0x0, -0x3c(%rbp)
je 0x4ea77
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x46e40
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4eff5
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0xffffff, %rdx         # imm = 0xFFFFFF
shlq $0x28, %rdx
movabsq $0xffffffffff, %rsi     # imm = 0xFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x28, %rcx
cltd
idivl %ecx
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x4eae9
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x28, %rcx
imull %ecx, %eax
cmpl -0x2c(%rbp), %eax
jne 0x4eae9
jmp 0x4eb08
leaq 0xb9851(%rip), %rdi     # 0x108341
leaq 0xb8b6c(%rip), %rsi     # 0x107663
movl $0x157a, %edx           # imm = 0x157A
leaq 0xb985b(%rip), %rcx     # 0x10835e
callq 0x42d0
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4240
movl -0x38(%rbp), %esi
leaq -0x68(%rbp), %rdi
callq 0x44a50
cmpq $0x0, -0x28(%rbp)
je 0x4eb2d
jmp 0x4eb4c
leaq 0xb9883(%rip), %rdi     # 0x1083b7
leaq 0xb8b28(%rip), %rsi     # 0x107663
movl $0x157f, %edx           # imm = 0x157F
leaq 0xb9817(%rip), %rcx     # 0x10835e
callq 0x42d0
cmpl $0x1, -0x30(%rbp)
jne 0x4eb6a
movl -0x2c(%rbp), %esi
movq -0x28(%rbp), %rdx
movl -0x4c(%rbp), %ecx
leaq -0x68(%rbp), %rdi
callq 0x442f0
jmp 0x4ec30
cmpl $0x2, -0x30(%rbp)
jne 0x4eba8
movl -0x4c(%rbp), %esi
leaq -0x68(%rbp), %rdi
movl $0x5, %edx
callq 0x448b0
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x28, %rcx
imull %ecx, %eax
movslq %eax, %rsi
movq -0x28(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x44ce0
jmp 0x4ec2e
cmpl $0x3, -0x30(%rbp)
jne 0x4ebe3
movl -0x4c(%rbp), %esi
leaq -0x68(%rbp), %rdi
movl $0x7, %edx
callq 0x448b0
movq -0x28(%rbp), %rdi
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x28, %rcx
imull %ecx, %eax
movslq %eax, %rsi
leaq -0x68(%rbp), %rdx
callq 0x43970
jmp 0x4ec2c
movl -0x30(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x43520
movl -0x84(%rbp), %ecx
movq %rax, %r8
movq -0x18(%rbp), %rax
movq (%rax), %r9
addq $0x1, %r9
movl $0x1, %edi
leaq 0xb97ad(%rip), %rsi     # 0x1083c6
leaq 0xb96cc(%rip), %rdx     # 0x1082ec
movb $0x0, %al
callq 0x9d90
callq 0x4250
jmp 0x4ec2e
jmp 0x4ec30
cmpq $0x0, -0x48(%rbp)
jne 0x4ee63
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
shrq $0x20, %rcx
andq $0xff, %rcx
addl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0xff, %rdx
shlq $0x20, %rdx
movabsq $-0xff00000001, %rsi    # imm = 0xFFFFFF00FFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
movq -0x18(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jle 0x4ed1b
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
cmpl $0x1, %eax
jl 0x4ecc8
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
movl %eax, -0x88(%rbp)
jmp 0x4ecd5
movl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x4ecd5
movl -0x88(%rbp), %eax
movslq %eax, %rdi
movq -0x18(%rbp), %rax
movslq 0x50(%rax), %rsi
movq -0x18(%rbp), %r9
addq $0x50, %r9
addq $0x48, %r9
movl $0x4, %edx
movl $0x20, %ecx
movl $0x1, %r8d
leaq 0xb96bd(%rip), %rax     # 0x1083c6
movq %rax, (%rsp)
callq 0x15780
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x50(%rax)
jmp 0x4ed1d
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
cmpl $0x1, %eax
jle 0x4edf0
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x47, %eax
jne 0x4edf0
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x54, %eax
jne 0x4edf0
movq -0x20(%rbp), %rax
cmpb $0x0, 0x2(%rax)
jne 0x4edf0
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x4eddf
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movq 0x98(%rcx), %rcx
movl -0x34(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4ed7f
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x4ee1f
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
andq $0xff, %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x28, %rax
movl %eax, %esi
movq -0x48(%rbp), %rdx
callq 0x414a0
movq -0x18(%rbp), %rax
movl $0x1, 0xb4(%rax)
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x1c(%rax)
jmp 0x4efbd
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x4ef49
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %rcx
movl 0x18(%rcx), %ecx
movq -0x48(%rbp), %rdx
movl 0x1c(%rdx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
addl %edx, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
ja 0x4ef49
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %rcx
movl 0x18(%rcx), %ecx
movq -0x48(%rbp), %rdx
movl 0x1c(%rdx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
addl %edx, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x4eec6
movq -0x18(%rbp), %rax
movl $0x1, 0xb4(%rax)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
movl 0x1c(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0x43b0
movq -0x58(%rbp), %rdi
callq 0x45a0
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x1f, %eax
movl %eax, -0x74(%rbp)
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x28, %rax
movl %eax, %esi
movq -0x48(%rbp), %rdx
callq 0x414a0
movl -0x74(%rbp), %edx
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
jmp 0x4efbb
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x4ef7c
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movslq %eax, %rcx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rdi
callq 0x45a0
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x28, %rax
movl %eax, %esi
movq -0x48(%rbp), %rdx
callq 0x414a0
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x1c(%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0xb4(%rax)
jmp 0x4efbd
movq -0x18(%rbp), %rax
movl 0xbc(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0xbc(%rax)
cmpl $0x0, -0x3c(%rbp)
je 0x4efee
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x46e40
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)