// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/vcf.c
// Function: bcf_update_info
int bcf_update_info(const bcf_hdr_t *hdr, bcf1_t *line, const char *key, const void *values, int n, int type)
{
    static int negative_rlen_warned = 0;
    int is_end_tag, is_svlen_tag = 0;

    // Is the field already present?
    int i, inf_id = bcf_hdr_id2int(hdr,BCF_DT_ID,key);
    if ( !bcf_hdr_idinfo_exists(hdr,BCF_HL_INFO,inf_id) ) return -1;    // No such INFO field in the header
    if ( !(line->unpacked & BCF_UN_INFO) ) bcf_unpack(line, BCF_UN_INFO);

    is_end_tag = strcmp(key, "END") == 0;
    is_svlen_tag = strcmp(key, "SVLEN") == 0;

    for (i=0; i<line->n_info; i++)
        if ( inf_id==line->d.info[i].key ) break;
    bcf_info_t *inf = i==line->n_info ? NULL : &line->d.info[i];

    if ( !n || (type==BCF_HT_STR && !values) )
    {
        if ( inf )
        {
            // Mark the tag for removal, free existing memory if necessary
            if ( inf->vptr_free )
            {
                free(inf->vptr - inf->vptr_off);
                inf->vptr_free = 0;
            }
            line->d.shared_dirty |= BCF1_DIRTY_INF;
            inf->vptr = NULL;
            inf->vptr_off = inf->vptr_len = 0;
        }
        if ( n==0 && (is_end_tag || is_svlen_tag) ) {
            line->rlen = get_rlen(hdr, line);
        }
        return 0;
    }

    if (is_end_tag)
    {
        if (n != 1)
        {
            hts_log_error("END info tag should only have one value at %s:%"PRIhts_pos, bcf_seqname_safe(hdr,line), line->pos+1);
            line->errcode |= BCF_ERR_TAG_INVALID;
            return -1;
        }
        if (type != BCF_HT_INT && type != BCF_HT_LONG)
        {
            hts_log_error("Wrong type (%d) for END info tag at %s:%"PRIhts_pos, type, bcf_seqname_safe(hdr,line), line->pos+1);
            line->errcode |= BCF_ERR_TAG_INVALID;
            return -1;
        }
    }

    // Encode the values and determine the size required to accommodate the values
    kstring_t str = {0,0,0};
    bcf_enc_int1(&str, inf_id);
    if ( type==BCF_HT_INT )
        bcf_enc_vint(&str, n, (int32_t*)values, -1);
    else if ( type==BCF_HT_REAL )
        bcf_enc_vfloat(&str, n, (float*)values);
    else if ( type==BCF_HT_FLAG || type==BCF_HT_STR )
    {
        if ( values==NULL )
            bcf_enc_size(&str, 0, BCF_BT_NULL);
        else
            bcf_enc_vchar(&str, strlen((char*)values), (char*)values);
    }
#ifdef VCF_ALLOW_INT64
    else if ( type==BCF_HT_LONG )
    {
        if (n != 1) {
            hts_log_error("Only storing a single BCF_HT_LONG value is supported at %s:%"PRIhts_pos, bcf_seqname_safe(hdr,line), line->pos+1);
            abort();
        }
        bcf_enc_long1(&str, *(int64_t *) values);
    }
#endif
    else
    {
        hts_log_error("The type %d not implemented yet at %s:%"PRIhts_pos, type, bcf_seqname_safe(hdr,line), line->pos+1);
        abort();
    }

    // Is the INFO tag already present
    if ( inf )
    {
        // Is it big enough to accommodate new block?
        if ( inf->vptr && str.l <= inf->vptr_len + inf->vptr_off )
        {
            if ( str.l != inf->vptr_len + inf->vptr_off ) line->d.shared_dirty |= BCF1_DIRTY_INF;
            uint8_t *ptr = inf->vptr - inf->vptr_off;
            memcpy(ptr, str.s, str.l);
            free(str.s);
            int vptr_free = inf->vptr_free;
            bcf_unpack_info_core1(ptr, inf);
            inf->vptr_free = vptr_free;
        }
        else
        {
            if ( inf->vptr_free )
                free(inf->vptr - inf->vptr_off);
            bcf_unpack_info_core1((uint8_t*)str.s, inf);
            inf->vptr_free = 1;
            line->d.shared_dirty |= BCF1_DIRTY_INF;
        }
    }
    else
    {
        // The tag is not present, create new one
        line->n_info++;
        hts_expand0(bcf_info_t, line->n_info, line->d.m_info , line->d.info);
        inf = &line->d.info[line->n_info-1];
        bcf_unpack_info_core1((uint8_t*)str.s, inf);
        inf->vptr_free = 1;
        line->d.shared_dirty |= BCF1_DIRTY_INF;
    }
    line->unpacked |= BCF_UN_INFO;

   if ( n==1 && is_end_tag) {
        hts_pos_t end = type == BCF_HT_INT ? *(int32_t *) values : *(int64_t *) values;
        if ( (type == BCF_HT_INT && end!=bcf_int32_missing) || (type == BCF_HT_LONG && end!=bcf_int64_missing) )
        {
            if ( end <= line->pos )
            {
                if ( !negative_rlen_warned )
                {
                    hts_log_warning("INFO/END=%"PRIhts_pos" is smaller than POS at %s:%"PRIhts_pos,end,bcf_seqname_safe(hdr,line),line->pos+1);
                    negative_rlen_warned = 1;
                }
            }
        }
    }
    if (is_svlen_tag || is_end_tag) {
        line->rlen = get_rlen(hdr, line);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %r12d
movl %r8d, %r15d
movq %rcx, 0x18(%rsp)
movq %rdx, %rbx
movq %rsi, 0x38(%rsp)
movq %rdi, %r14
xorl %esi, %esi
callq 0x2d3d9
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x3ee46
movl %eax, %ebp
cmpl (%r14), %eax
jge 0x3ee46
movq 0x10(%r14), %rax
movl %ebp, %ecx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
testq %rax, %rax
je 0x3ee46
movl 0x8(%rax), %eax
notl %eax
testb $0xf, %al
je 0x3ee46
movl %r15d, 0x10(%rsp)
movl %r12d, %r15d
movq 0x38(%rsp), %r12
testb $0x4, 0xbc(%r12)
jne 0x3e95e
movq %r12, %rdi
movl $0x4, %esi
callq 0x38183
leaq 0x6d840(%rip), %rsi     # 0xac1a5
movq %rbx, %rdi
callq 0x46e0
movl %eax, 0xc(%rsp)
leaq 0x6d831(%rip), %rsi     # 0xac1a9
movq %rbx, %rdi
callq 0x46e0
movq 0x18(%r12), %rcx
movl %ecx, %edi
andl $0xffff, %edi           # imm = 0xFFFF
movq %r12, %rbx
je 0x3e9bb
movq 0x90(%rbx), %rdx
movzwl %cx, %esi
xorl %r8d, %r8d
xorl %ecx, %ecx
movl %r15d, %r12d
movl 0x10(%rsp), %r15d
cmpl (%rdx), %ebp
je 0x3e9c5
incq %rcx
addq $0x28, %rdx
cmpq %rcx, %rsi
jne 0x3e9a9
jmp 0x3e9df
xorl %ecx, %ecx
movl %r15d, %r12d
movl 0x10(%rsp), %r15d
cmpl %edi, %ecx
jne 0x3e9ce
xorl %r8d, %r8d
jmp 0x3e9df
movl %ecx, %ecx
leaq (%rcx,%rcx,4), %r8
shlq $0x3, %r8
addq 0x90(%rbx), %r8
testl %r15d, %r15d
je 0x3ea5e
cmpl $0x3, %r12d
setne %dl
cmpq $0x0, 0x18(%rsp)
setne %cl
orb %dl, %cl
je 0x3ea5e
cmpl $0x0, 0xc(%rsp)
je 0x3eae6
movq %r8, 0x10(%rsp)
movl %eax, 0x44(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movl $0x7, %edi
callq 0x46a0
testq %rax, %rax
je 0x3eb6f
movq %rax, 0x30(%rsp)
movq $0x7, 0x28(%rsp)
movl %ebp, %ecx
negl %ecx
jo 0x3eb4e
cmpl $0x80000001, %ebp       # imm = 0x80000001
jne 0x3eb55
movw $0x8111, (%rax)         # imm = 0x8111
jmp 0x3eb65
testq %r8, %r8
movl 0xc(%rsp), %ecx
je 0x3eab4
movl 0x1c(%r8), %edx
testl %edx, %edx
jns 0x3ea95
movl %eax, %ebp
movq 0x10(%r8), %rdi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
subq %rdx, %rdi
movq %r8, %r12
callq 0x45c0
movq %r12, %r8
movl %ebp, %eax
movl 0xc(%rsp), %ecx
andb $0x7f, 0x1f(%r12)
orb $0x8, 0xb0(%rbx)
movq $0x0, 0x10(%r8)
movl $0x0, 0x18(%r8)
andl $0x80000000, 0x1c(%r8)  # imm = 0x80000000
testl %eax, %eax
sete %al
testl %ecx, %ecx
sete %cl
xorl %r13d, %r13d
testl %r15d, %r15d
jne 0x3ee46
orb %al, %cl
je 0x3ee46
movq %r14, %rdi
movq %rbx, %rsi
callq 0x370a7
movq %rax, 0x8(%rbx)
jmp 0x3ee46
cmpl $0x1, %r15d
jne 0x3eb26
movl %r12d, %ecx
andl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
cmpl $0x1, %ecx
je 0x3ea03
movslq 0x10(%rbx), %rax
testq %rax, %rax
js 0x3ee0c
cmpl %eax, 0x4(%r14)
jle 0x3ee0c
movq 0x18(%r14), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x3ee0e
movslq 0x10(%rbx), %rax
testq %rax, %rax
js 0x3ebde
cmpl %eax, 0x4(%r14)
jle 0x3ebde
movq 0x18(%r14), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x3ebe0
movw $0x8011, (%rax)         # imm = 0x8011
jmp 0x3eb65
cmpl $0x7f, %ebp
ja 0x3edf3
movb $0x11, (%rax)
movb %bpl, 0x1(%rax)
movl $0x2, %eax
movq %rax, 0x20(%rsp)
cmpl $0x1, %r12d
jne 0x3eb94
leaq 0x20(%rsp), %rdi
movl %r15d, %esi
movq 0x18(%rsp), %rbp
movq %rbp, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x32025
jmp 0x3ec21
testl %r12d, %r12d
movq 0x18(%rsp), %rbp
je 0x3ebc0
cmpl $0x3, %r12d
je 0x3ebc0
cmpl $0x2, %r12d
jne 0x3eea1
leaq 0x20(%rsp), %rdi
movl %r15d, %esi
movq %rbp, %rdx
callq 0x32942
jmp 0x3ec21
testq %rbp, %rbp
je 0x3ec13
movq %rbp, %rdi
callq 0x41c0
leaq 0x20(%rsp), %rdi
movl %eax, %esi
movq %rbp, %rdx
callq 0x32aea
jmp 0x3ec21
xorl %eax, %eax
testq %rax, %rax
leaq 0x6dd25(%rip), %rcx     # 0xac90f
cmovneq %rax, %rcx
movq (%rbx), %r8
incq %r8
leaq 0x6d5b4(%rip), %rsi     # 0xac1af
leaq 0x6d5bd(%rip), %rdx     # 0xac1bf
movl $0x1, %edi
xorl %eax, %eax
callq 0x942d
jmp 0x3ee3f
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x32835
movq 0x10(%rsp), %r8
testq %r8, %r8
je 0x3ecbc
movq 0x10(%r8), %r13
testq %r13, %r13
je 0x3ed31
movq 0x20(%rsp), %rdx
movl 0x1c(%r8), %eax
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl 0x18(%r8), %esi
addl %ecx, %esi
cmpq %rsi, %rdx
ja 0x3ed35
je 0x3ec6e
orb $0x8, 0xb0(%rbx)
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl 0x1c(%r8), %ecx
movl %ecx, %eax
subq %rax, %r13
movq 0x30(%rsp), %rsi
movq %r13, %rdi
movq %r8, %rbp
callq 0x43c0
movq 0x30(%rsp), %rdi
callq 0x45c0
movl $0x80000000, %ebx       # imm = 0x80000000
andl 0x1c(%rbp), %ebx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x38849
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl 0x1c(%rbp), %eax
orl %ebx, %eax
movq 0x38(%rsp), %rbx
movl %eax, 0x1c(%rbp)
movq 0x18(%rsp), %rbp
jmp 0x3ed6a
movl 0x18(%rbx), %eax
incl %eax
movzwl %ax, %edi
movw %di, 0x18(%rbx)
movslq 0x54(%rbx), %rsi
cmpl %edi, %esi
jge 0x3ed06
cmpq $0x1, %rdi
adcq $0x0, %rdi
leaq 0x90(%rbx), %r9
leaq 0x6d4c9(%rip), %rax     # 0xac1af
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x28, %ecx
movl $0x1, %r8d
callq 0x114b1
movl %eax, 0x54(%rbx)
movzwl 0x18(%rbx), %edi
movq 0x90(%rbx), %rax
leaq (%rdi,%rdi,4), %rcx
leaq (%rax,%rcx,8), %rbx
addq $-0x28, %rbx
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x38849
orb $-0x80, 0x1f(%rbx)
movq 0x38(%rsp), %rbx
jmp 0x3ed63
movl 0x1c(%r8), %eax
testl %eax, %eax
jns 0x3ed4e
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subq %rax, %r13
movq %r13, %rdi
callq 0x45c0
movq 0x10(%rsp), %r8
movq 0x30(%rsp), %rdi
movq %r8, %rsi
movq %r8, %r13
callq 0x38849
orb $-0x80, 0x1f(%r13)
orb $0x8, 0xb0(%rbx)
orb $0x4, 0xbc(%rbx)
xorl $0x1, %r15d
movl 0xc(%rsp), %ecx
orl %ecx, %r15d
movl 0x44(%rsp), %eax
jne 0x3edce
cmpl $0x1, %r12d
jne 0x3eddf
movslq (%rbp), %rcx
cmpq $-0x80000000, %rcx      # imm = 0x80000000
je 0x3eddf
movq (%rbx), %r9
cmpq %rcx, %r9
jl 0x3eddf
testb $0x1, 0x8f064(%rip)     # 0xcde08
jne 0x3eddf
movslq 0x10(%rbx), %rax
testq %rax, %rax
js 0x3ee68
cmpl %eax, 0x4(%r14)
jle 0x3ee68
movq 0x18(%r14), %rdx
shlq $0x4, %rax
movq (%rdx,%rax), %rax
jmp 0x3ee6a
testl %eax, %eax
sete %al
testl %ecx, %ecx
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x3edee
movq %r14, %rdi
movq %rbx, %rsi
callq 0x370a7
movq %rax, 0x8(%rbx)
xorl %r13d, %r13d
jmp 0x3ee46
cmpl $0x7fff, %ebp           # imm = 0x7FFF
ja 0x3ee58
movb $0x12, (%rax)
movw %bp, 0x1(%rax)
movl $0x3, %eax
jmp 0x3eb6a
xorl %eax, %eax
testq %rax, %rax
leaq 0x6daf7(%rip), %r8      # 0xac90f
cmovneq %rax, %r8
movq (%rbx), %r9
incq %r9
leaq 0x6d386(%rip), %rsi     # 0xac1af
leaq 0x6d3c1(%rip), %rdx     # 0xac1f1
movl $0x1, %edi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x942d
orb $0x40, 0xcc(%rbx)
movl %r13d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x13, (%rax)
movl %ebp, 0x1(%rax)
movl $0x5, %eax
jmp 0x3eb6a
xorl %eax, %eax
testq %rax, %rax
leaq 0x6da9b(%rip), %r8      # 0xac90f
cmovneq %rax, %r8
incq %r9
leaq 0x6d32d(%rip), %rsi     # 0xac1af
leaq 0x6d3bd(%rip), %rdx     # 0xac246
movl $0x3, %edi
xorl %eax, %eax
callq 0x942d
movb $0x1, 0x8ef6c(%rip)     # 0xcde08
jmp 0x3eddf
movq %r14, %rdi
movq %rbx, %rsi
callq 0x318ad
movq (%rbx), %r9
incq %r9
leaq 0x6d2f6(%rip), %rsi     # 0xac1af
leaq 0x6d35c(%rip), %rdx     # 0xac21c
movl $0x1, %edi
movl %r12d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x942d
callq 0x4260