// File: /workspace/github_c_makefile_star2_O1/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, 0x8(%rsp)
movl %r8d, %r13d
movq %rcx, 0x30(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
xorl %esi, %esi
callq 0x2e585
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x3fca2
movl %eax, %ebp
cmpl (%r14), %eax
jge 0x3fca2
movq 0x10(%r14), %rax
movl %ebp, %ecx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
testq %rax, %rax
je 0x3fca2
movl 0x8(%rax), %eax
notl %eax
testb $0xf, %al
je 0x3fca2
movq %r12, %r15
testb $0x4, 0xbc(%r12)
jne 0x3f711
movq %r15, %rdi
movl $0x4, %esi
callq 0x38e9d
leaq 0x6fadd(%rip), %rsi     # 0xaf1f5
movq %rbx, %rdi
callq 0x46e0
movl %eax, 0xc(%rsp)
leaq 0x6face(%rip), %rsi     # 0xaf1f9
movq %rbx, %rdi
callq 0x46e0
movl %eax, %r8d
movq 0x18(%r15), %rcx
movl %ecx, %eax
andl $0xffff, %eax           # imm = 0xFFFF
movq %r15, %rbx
je 0x3f770
movq 0x90(%rbx), %r9
movzwl %cx, %esi
xorl %edi, %edi
movl 0x8(%rsp), %ecx
movq 0x30(%rsp), %rdx
cmpl (%r9), %ebp
je 0x3f77b
incq %rdi
addq $0x28, %r9
cmpq %rdi, %rsi
jne 0x3f75b
movl %eax, %edi
jmp 0x3f77b
xorl %edi, %edi
movl 0x8(%rsp), %ecx
movq 0x30(%rsp), %rdx
cmpl %eax, %edi
jne 0x3f784
xorl %r15d, %r15d
jmp 0x3f795
movl %edi, %eax
leaq (%rax,%rax,4), %r15
shlq $0x3, %r15
addq 0x90(%rbx), %r15
testl %r13d, %r13d
je 0x3f837
cmpl $0x3, %ecx
setne %al
testq %rdx, %rdx
setne %sil
orb %al, %sil
je 0x3f837
cmpl $0x0, 0xc(%rsp)
je 0x3f8b5
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpq $0x4, 0x18(%rsp)
movq %r12, 0x38(%rsp)
ja 0x3f812
movq 0x20(%rsp), %rdi
movl $0x7, %esi
movl %r8d, %ebx
callq 0x4860
movq 0x30(%rsp), %rdx
movl %ebx, %r8d
movl 0x8(%rsp), %ecx
testq %rax, %rax
je 0x3f900
movq %rax, 0x20(%rsp)
movq $0x7, 0x18(%rsp)
movq 0x20(%rsp), %rax
movl %ebp, %esi
negl %esi
jo 0x3f8e0
cmpl $0x80000001, %ebp       # imm = 0x80000001
jne 0x3f8e7
movw $0x8111, (%rax)         # imm = 0x8111
jmp 0x3f8f7
testq %r15, %r15
je 0x3f87f
movl 0x1c(%r15), %eax
testl %eax, %eax
jns 0x3f860
movq 0x10(%r15), %rdi
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subq %rax, %rdi
movl %r8d, %ebp
callq 0x45c0
movl %ebp, %r8d
andb $0x7f, 0x1f(%r15)
orb $0x8, 0xb0(%rbx)
movq $0x0, 0x10(%r15)
movl $0x0, 0x18(%r15)
andl $0x80000000, 0x1c(%r15) # imm = 0x80000000
testl %r8d, %r8d
sete %al
cmpl $0x0, 0xc(%rsp)
sete %cl
xorl %r15d, %r15d
testl %r13d, %r13d
jne 0x3fca2
orb %al, %cl
je 0x3fca2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x37d95
movq %rax, 0x8(%rbx)
jmp 0x3fca2
cmpl $0x1, %r13d
jne 0x3f972
movl %ecx, %eax
andl $0xfffffeff, %eax       # imm = 0xFFFFFEFF
cmpl $0x1, %eax
je 0x3f7bf
testq %rbx, %rbx
je 0x3fc46
movl 0x10(%rbx), %eax
jmp 0x3fc4b
movw $0x8011, (%rax)         # imm = 0x8011
jmp 0x3f8f7
cmpl $0x7f, %ebp
ja 0x3f983
movb $0x11, (%rax)
movb %bpl, 0x1(%rax)
movq $0x2, 0x10(%rsp)
cmpl $0x1, %ecx
movl %r8d, 0x44(%rsp)
jne 0x3f926
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x3321b
movq 0x38(%rsp), %rbx
jmp 0x3f9b2
testl %ecx, %ecx
je 0x3f94c
cmpl $0x3, %ecx
je 0x3f94c
cmpl $0x2, %ecx
movq 0x38(%rsp), %rbx
jne 0x3fcb4
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
callq 0x33836
jmp 0x3f9b2
testq %rdx, %rdx
movq 0x38(%rsp), %rbx
je 0x3f9a4
movq %rdx, %rdi
movq %rdx, %rbp
callq 0x41c0
leaq 0x10(%rsp), %rdi
movl %eax, %esi
movq %rbp, %rdx
callq 0x338fe
jmp 0x3f9b2
testq %rbx, %rbx
je 0x3fb60
movl 0x10(%rbx), %eax
jmp 0x3fb65
cmpl $0x7fff, %ebp           # imm = 0x7FFF
ja 0x3fc32
movb $0x12, (%rax)
movw %bp, 0x1(%rax)
movq $0x3, 0x10(%rsp)
jmp 0x3f900
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33722
testq %r15, %r15
je 0x3fa11
movq 0x10(%r15), %rbp
testq %rbp, %rbp
je 0x3f9db
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl 0x1c(%r15), %eax
movq 0x10(%rsp), %rdx
addl 0x18(%r15), %eax
cmpq %rax, %rdx
jbe 0x3fa8d
movl 0x1c(%r15), %eax
testl %eax, %eax
jns 0x3f9f3
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subq %rax, %rbp
movq %rbp, %rdi
callq 0x45c0
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x3953d
orb $-0x80, 0x1f(%r15)
orb $0x8, 0xb0(%rbx)
jmp 0x3fae0
movl 0x18(%rbx), %eax
incl %eax
movzwl %ax, %edi
movw %di, 0x18(%rbx)
movslq 0x54(%rbx), %rsi
cmpl %edi, %esi
jge 0x3fa57
cmpq $0x1, %rdi
adcq $0x0, %rdi
leaq 0x90(%rbx), %r9
leaq 0x6f7c4(%rip), %rax     # 0xaf1ff
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x28, %ecx
movl $0x1, %r8d
callq 0x1183c
movl %eax, 0x54(%rbx)
movq 0x90(%rbx), %rax
movzwl 0x18(%rbx), %ecx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rbx
addq $-0x28, %rbx
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x3953d
orb $-0x80, 0x1f(%rbx)
movq %r12, %rbx
orb $0x8, 0xb0(%r12)
jmp 0x3fae0
je 0x3fa96
orb $0x8, 0xb0(%rbx)
movl 0x1c(%r15), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subq %rax, %rbp
movq 0x20(%rsp), %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x43c0
movq %rbx, %rdi
callq 0x45c0
movl $0x80000000, %ebx       # imm = 0x80000000
andl 0x1c(%r15), %ebx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3953d
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl 0x1c(%r15), %eax
orl %ebx, %eax
movq %r12, %rbx
movl %eax, 0x1c(%r15)
orb $0x4, 0xbc(%rbx)
xorl $0x1, %r13d
orl 0xc(%rsp), %r13d
movl 0x8(%rsp), %esi
movq 0x30(%rsp), %rax
jne 0x3fc07
cmpl $0x1, %esi
jne 0x3fb09
movslq (%rax), %rcx
jmp 0x3fb0c
movq (%rax), %rcx
cmpl $0x1, %esi
sete %al
cmpq $-0x80000000, %rcx      # imm = 0x80000000
setne %dl
testb %dl, %al
jne 0x3fb3d
cmpl $0x101, %esi            # imm = 0x101
sete %al
movq %rcx, %rdx
negq %rdx
setno %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x3fc07
movq (%rbx), %r9
cmpq %r9, %rcx
jg 0x3fc07
testb $0x1, 0x902b8(%rip)     # 0xcfe08
jne 0x3fc07
testq %rbx, %rbx
je 0x3fbb4
movl 0x10(%rbx), %eax
jmp 0x3fbb9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x3fb7f
cmpl %eax, 0x4(%r14)
jle 0x3fb7f
movq 0x18(%r14), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x3fb81
xorl %eax, %eax
testq %rax, %rax
leaq 0x6fdd4(%rip), %rcx     # 0xaf95f
cmovneq %rax, %rcx
movq (%rbx), %r8
incq %r8
leaq 0x6f663(%rip), %rsi     # 0xaf1ff
leaq 0x6f66c(%rip), %rdx     # 0xaf20f
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
jmp 0x3fc95
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x3fbd3
cmpl %eax, 0x4(%r14)
jle 0x3fbd3
movq 0x18(%r14), %rdx
movl %eax, %eax
shlq $0x4, %rax
movq (%rdx,%rax), %rax
jmp 0x3fbd5
xorl %eax, %eax
testq %rax, %rax
leaq 0x6fd80(%rip), %r8      # 0xaf95f
cmovneq %rax, %r8
incq %r9
leaq 0x6f612(%rip), %rsi     # 0xaf1ff
leaq 0x6f6a2(%rip), %rdx     # 0xaf296
movl $0x3, %edi
xorl %eax, %eax
callq 0x9774
movb $0x1, 0x90201(%rip)     # 0xcfe08
cmpl $0x0, 0x44(%rsp)
sete %al
cmpl $0x0, 0xc(%rsp)
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x3fc2d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x37d95
movq %rax, 0x8(%rbx)
xorl %r15d, %r15d
jmp 0x3fca2
movb $0x13, (%rax)
movl %ebp, 0x1(%rax)
movq $0x5, 0x10(%rsp)
jmp 0x3f900
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x3fc65
cmpl %eax, 0x4(%r14)
jle 0x3fc65
movq 0x18(%r14), %rdx
movl %eax, %eax
shlq $0x4, %rax
movq (%rdx,%rax), %rax
jmp 0x3fc67
xorl %eax, %eax
testq %rax, %rax
leaq 0x6fcee(%rip), %r8      # 0xaf95f
cmovneq %rax, %r8
movq (%rbx), %r9
incq %r9
leaq 0x6f57d(%rip), %rsi     # 0xaf1ff
leaq 0x6f5b8(%rip), %rdx     # 0xaf241
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
orb $0x40, 0xcc(%rbx)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %rbx, %rsi
callq 0x32a62
movq (%rbx), %r9
incq %r9
leaq 0x6f533(%rip), %rsi     # 0xaf1ff
leaq 0x6f599(%rip), %rdx     # 0xaf26c
movl $0x1, %edi
movl 0x8(%rsp), %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x9774
callq 0x4260