// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/vcf.c
// Function: bcf_update_alleles
int bcf_update_alleles(const bcf_hdr_t *hdr, bcf1_t *line, const char **alleles, int nals)
{
    if ( !(line->unpacked & BCF_UN_STR) ) bcf_unpack(line, BCF_UN_STR);
    char *free_old = NULL;
    char buffer[256];
    size_t used = 0;

    // The pointers in alleles may point into the existing line->d.als memory,
    // so care needs to be taken not to clobber them while updating.  Usually
    // they will be short so we can copy through an intermediate buffer.
    // If they're longer, or won't fit in the existing allocation we
    // can allocate a new buffer to write into.  Note that in either case
    // pointers to line->d.als memory in alleles may not be valid when we've
    // finished.
    int i;
    size_t avail = line->d.m_als < sizeof(buffer) ? line->d.m_als : sizeof(buffer);
    for (i=0; i<nals; i++) {
        size_t sz = strlen(alleles[i]) + 1;
        if (avail - used < sz)
            break;
        memcpy(buffer + used, alleles[i], sz);
        used += sz;
    }

    // Did we miss anything?
    if (i < nals) {
        int j;
        size_t needed = used;
        char *new_als;
        for (j = i; j < nals; j++)
            needed += strlen(alleles[j]) + 1;
        if (needed < line->d.m_als) // Don't shrink the buffer
            needed = line->d.m_als;
        if (needed > INT_MAX) {
            hts_log_error("REF + alleles too long to fit in a BCF record");
            return -1;
        }
        new_als = malloc(needed);
        if (!new_als)
            return -1;
        free_old = line->d.als;
        line->d.als = new_als;
        line->d.m_als = needed;
    }

    // Copy from the temp buffer to the destination
    if (used) {
        assert(used <= line->d.m_als);
        memcpy(line->d.als, buffer, used);
    }

    // Add in any remaining entries - if this happens we will always be
    // writing to a newly-allocated buffer.
    for (; i < nals; i++) {
        size_t sz = strlen(alleles[i]) + 1;
        memcpy(line->d.als + used, alleles[i], sz);
        used += sz;
    }

    if (free_old)
        free(free_old);
    return _bcf1_sync_alleles(hdr,line,nals);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movl %ecx, %ebp
movq %rdx, 0x20(%rsp)
movq %rsi, %rbx
movq %rdi, 0x38(%rsp)
testb $0x1, 0xbc(%rsi)
jne 0x40b83
movq %rbx, %rdi
movl $0x1, %esi
callq 0x38e9d
movl %ebp, %r14d
movq %rbx, 0x10(%rsp)
movslq 0x5c(%rbx), %rax
movl $0x100, %ecx            # imm = 0x100
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rcx, 0x18(%rsp)
movl %ebp, 0xc(%rsp)
testl %ebp, %ebp
setg %cl
movq %rax, 0x28(%rsp)
jle 0x40c0e
xorl %ebp, %ebp
xorl %r15d, %r15d
movb %cl, 0xb(%rsp)
movq %r14, %r12
movq 0x20(%rsp), %rax
movq (%rax,%rbp,8), %r13
movq %r13, %rdi
callq 0x41c0
movq %rax, %r14
incq %r14
movq 0x18(%rsp), %rbx
subq %r15, %rbx
cmpq %r14, %rbx
jb 0x40bf6
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x43c0
addq %r14, %r15
cmpq %r14, %rbx
movq %r12, %r14
jb 0x40c15
incq %rbp
cmpq %r14, %rbp
setb %cl
jne 0x40bb5
movl %r14d, %ebp
jmp 0x40c19
xorl %ebp, %ebp
xorl %r15d, %r15d
jmp 0x40c19
movb 0xb(%rsp), %cl
testb $0x1, %cl
movq %r14, 0x30(%rsp)
je 0x40c95
movq %r15, %rbx
movl 0xc(%rsp), %r13d
cmpl %r13d, %ebp
jge 0x40c5b
movl %ebp, %eax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,8), %r14
movl %ebp, %r12d
movq %r15, %rbx
movq (%r14), %rdi
callq 0x41c0
addq %rax, %rbx
incq %rbx
addq $0x8, %r14
incl %r12d
cmpl %r13d, %r12d
jl 0x40c41
movq 0x28(%rsp), %r14
cmpq %r14, %rbx
cmovaq %rbx, %r14
testq $-0x80000000, %r14      # imm = 0x80000000
je 0x40c9e
leaq 0x6e707(%rip), %rsi     # 0xaf37e
leaq 0x6e713(%rip), %rdx     # 0xaf391
xorl %ebx, %ebx
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
xorl %ecx, %ecx
movq 0x10(%rsp), %r12
jmp 0x40ccd
xorl %ecx, %ecx
movq 0x10(%rsp), %r12
jmp 0x40cda
movq %r14, %rdi
callq 0x46a0
testq %rax, %rax
movq 0x10(%rsp), %r12
je 0x40cc9
movq 0x80(%r12), %rcx
movq %rax, 0x80(%r12)
movl %r14d, 0x5c(%r12)
movb $0x1, %bl
jmp 0x40ccd
xorl %ebx, %ebx
xorl %ecx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %bl, %bl
je 0x40dfe
movq %rcx, 0x18(%rsp)
testq %r15, %r15
je 0x40d07
movslq 0x5c(%r12), %rax
cmpq %rax, %r15
ja 0x40e10
movq 0x80(%r12), %rdi
leaq 0x40(%rsp), %rsi
movq %r15, %rdx
callq 0x43c0
movl 0xc(%rsp), %r13d
cmpl %r13d, %ebp
jge 0x40d59
movq %r12, %r14
movl %ebp, %eax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,8), %rbx
movq (%rbx), %r12
movq %r12, %rdi
callq 0x41c0
movq %rax, %r13
leaq 0x1(%rax), %rdx
movq 0x80(%r14), %rdi
addq %r15, %rdi
movq %r12, %rsi
callq 0x43c0
addq %r13, %r15
incq %r15
movl 0xc(%rsp), %r13d
addq $0x8, %rbx
incl %ebp
cmpl %r13d, %ebp
jl 0x40d1f
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x40d68
callq 0x45c0
movq 0x10(%rsp), %rbx
orb $0x2, 0xb0(%rbx)
movl $0xffffffff, 0xac(%rbx) # imm = 0xFFFFFFFF
movw %r13w, 0x1a(%rbx)
movzwl %r13w, %edi
movslq 0x60(%rbx), %rsi
cmpl %esi, %edi
movq 0x30(%rsp), %r14
jle 0x40dc1
cmpl $0x1, %edi
adcl $0x0, %edi
leaq 0x88(%rbx), %r9
leaq 0x6f2a6(%rip), %rax     # 0xb004e
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x8, %ecx
xorl %r8d, %r8d
callq 0x1183c
movl %eax, 0x60(%rbx)
testl %r13d, %r13d
jle 0x40deb
movq 0x80(%rbx), %rcx
xorl %eax, %eax
movq 0x88(%rbx), %rdx
movq %rcx, (%rdx,%rax,8)
cmpb $0x0, (%rcx)
leaq 0x1(%rcx), %rcx
jne 0x40dda
incq %rax
cmpq %r14, %rax
jne 0x40dcf
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
callq 0x37d95
movq %rax, 0x8(%rbx)
xorl %eax, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6e5a8(%rip), %rdi     # 0xaf3bf
leaq 0x6d805(%rip), %rsi     # 0xae623
leaq 0x6e5b0(%rip), %rcx     # 0xaf3d5
movl $0x1646, %edx           # imm = 0x1646
callq 0x42e0