// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl 0xbc(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x4f54a
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x48110
movq $0x0, -0x30(%rbp)
movq $0x0, -0x138(%rbp)
movq -0x18(%rbp), %rax
movslq 0x5c(%rax), %rax
cmpq $0x100, %rax            # imm = 0x100
jae 0x4f57e
movq -0x18(%rbp), %rax
movslq 0x5c(%rax), %rax
movq %rax, -0x178(%rbp)
jmp 0x4f58c
movl $0x100, %eax            # imm = 0x100
movq %rax, -0x178(%rbp)
jmp 0x4f58c
movq -0x178(%rbp), %rax
movq %rax, -0x148(%rbp)
movl $0x0, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4f63d
movq -0x20(%rbp), %rax
movslq -0x13c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x41a0
addq $0x1, %rax
movq %rax, -0x150(%rbp)
movq -0x148(%rbp), %rax
subq -0x138(%rbp), %rax
cmpq -0x150(%rbp), %rax
jae 0x4f5eb
jmp 0x4f63d
leaq -0x130(%rbp), %rdi
addq -0x138(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x13c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x150(%rbp), %rdx
callq 0x43b0
movq -0x150(%rbp), %rax
addq -0x138(%rbp), %rax
movq %rax, -0x138(%rbp)
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x4f5a4
movl -0x13c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4f758
movq -0x138(%rbp), %rax
movq %rax, -0x160(%rbp)
movl -0x13c(%rbp), %eax
movl %eax, -0x154(%rbp)
movl -0x154(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4f6a8
movq -0x20(%rbp), %rax
movslq -0x154(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x41a0
addq $0x1, %rax
addq -0x160(%rbp), %rax
movq %rax, -0x160(%rbp)
movl -0x154(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x154(%rbp)
jmp 0x4f666
movq -0x160(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
cmpq %rcx, %rax
jae 0x4f6cb
movq -0x18(%rbp), %rax
movslq 0x5c(%rax), %rax
movq %rax, -0x160(%rbp)
cmpq $0x7fffffff, -0x160(%rbp) # imm = 0x7FFFFFFF
jbe 0x4f6fe
movl $0x1, %edi
leaq 0xb8d1a(%rip), %rsi     # 0x1083fe
leaq 0xb8d26(%rip), %rdx     # 0x108411
movb $0x0, %al
callq 0x9d90
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f857
movq -0x160(%rbp), %rdi
callq 0x4670
movq %rax, -0x168(%rbp)
cmpq $0x0, -0x168(%rbp)
jne 0x4f727
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f857
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x168(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x160(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x5c(%rax)
cmpq $0x0, -0x138(%rbp)
je 0x4f7b5
movq -0x138(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
cmpq %rcx, %rax
ja 0x4f778
jmp 0x4f797
leaq 0xb8cc0(%rip), %rdi     # 0x10843f
leaq 0xb7edd(%rip), %rsi     # 0x107663
movl $0x1646, %edx           # imm = 0x1646
leaq 0xb8cc3(%rip), %rcx     # 0x108455
callq 0x42d0
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rdi
leaq -0x130(%rbp), %rsi
movq -0x138(%rbp), %rdx
callq 0x43b0
jmp 0x4f7b7
movl -0x13c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4f834
movq -0x20(%rbp), %rax
movslq -0x13c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x41a0
addq $0x1, %rax
movq %rax, -0x170(%rbp)
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rdi
addq -0x138(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x13c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x170(%rbp), %rdx
callq 0x43b0
movq -0x170(%rbp), %rax
addq -0x138(%rbp), %rax
movq %rax, -0x138(%rbp)
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x4f7b7
cmpq $0x0, -0x30(%rbp)
je 0x4f844
movq -0x30(%rbp), %rdi
callq 0x45a0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x4f870
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)