// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/vcf.c
// Function: bcf1_sync
static int bcf1_sync(bcf1_t *line)
{
    char *shared_ori = line->shared.s;
    size_t prev_len;

    kstring_t tmp = {0,0,0};
    if ( !line->shared.l )
    {
        // New line created via API, BCF data blocks do not exist. Get it ready for BCF output
        tmp = line->shared;
        bcf1_sync_id(line, &tmp);
        line->unpack_size[0] = tmp.l; prev_len = tmp.l;

        bcf1_sync_alleles(line, &tmp);
        line->unpack_size[1] = tmp.l - prev_len; prev_len = tmp.l;

        bcf1_sync_filter(line, &tmp);
        line->unpack_size[2] = tmp.l - prev_len;

        bcf1_sync_info(line, &tmp);
        line->shared = tmp;
    }
    else if ( line->d.shared_dirty )
    {
        // The line was edited, update the BCF data block.

        if ( !(line->unpacked & BCF_UN_STR) ) bcf_unpack(line,BCF_UN_STR);

        // ptr_ori points to the original unchanged BCF data.
        uint8_t *ptr_ori = (uint8_t *) line->shared.s;

        // ID: single typed string
        if ( line->d.shared_dirty & BCF1_DIRTY_ID )
            bcf1_sync_id(line, &tmp);
        else
            kputsn_(ptr_ori, line->unpack_size[0], &tmp);
        ptr_ori += line->unpack_size[0];
        line->unpack_size[0] = tmp.l; prev_len = tmp.l;

        // REF+ALT: list of typed strings
        if ( line->d.shared_dirty & BCF1_DIRTY_ALS )
            bcf1_sync_alleles(line, &tmp);
        else
        {
            kputsn_(ptr_ori, line->unpack_size[1], &tmp);
            if ( !line->rlen && line->n_allele ) line->rlen = strlen(line->d.allele[0]);
        }
        ptr_ori += line->unpack_size[1];
        line->unpack_size[1] = tmp.l - prev_len; prev_len = tmp.l;

        if ( line->unpacked & BCF_UN_FLT )
        {
            // FILTER: typed vector of integers
            if ( line->d.shared_dirty & BCF1_DIRTY_FLT )
                bcf1_sync_filter(line, &tmp);
            else if ( line->d.n_flt )
                kputsn_(ptr_ori, line->unpack_size[2], &tmp);
            else
                bcf_enc_vint(&tmp, 0, 0, -1);
            ptr_ori += line->unpack_size[2];
            line->unpack_size[2] = tmp.l - prev_len;

            if ( line->unpacked & BCF_UN_INFO )
            {
                // INFO: pairs of typed vectors
                if ( line->d.shared_dirty & BCF1_DIRTY_INF )
                {
                    bcf1_sync_info(line, &tmp);
                    ptr_ori = (uint8_t*)line->shared.s + line->shared.l;
                }
            }
        }

        int size = line->shared.l - (size_t)ptr_ori + (size_t)line->shared.s;
        if ( size ) kputsn_(ptr_ori, size, &tmp);

        free(line->shared.s);
        line->shared = tmp;
    }
    if ( line->shared.s != shared_ori && line->unpacked & BCF_UN_INFO )
    {
        // Reallocated line->shared.s block invalidated line->d.info[].vptr pointers
        size_t off_new = line->unpack_size[0] + line->unpack_size[1] + line->unpack_size[2];
        int i;
        for (i=0; i<line->n_info; i++)
        {
            uint8_t *vptr_free = line->d.info[i].vptr_free ? line->d.info[i].vptr - line->d.info[i].vptr_off : NULL;
            line->d.info[i].vptr = (uint8_t*) line->shared.s + off_new + line->d.info[i].vptr_off;
            off_new += line->d.info[i].vptr_len + line->d.info[i].vptr_off;
            if ( vptr_free )
            {
                free(vptr_free);
                line->d.info[i].vptr_free = 0;
            }
        }
    }

    if ( line->n_sample && line->n_fmt && (!line->indiv.l || line->d.indiv_dirty) )
    {
        // The genotype fields changed or are not present
        tmp.l = tmp.m = 0; tmp.s = NULL;
        int i, irm = -1;
        for (i=0; i<line->n_fmt; i++)
        {
            bcf_fmt_t *fmt = &line->d.fmt[i];
            if ( !fmt->p )
            {
                // marked for removal
                if ( irm < 0 ) irm = i;
                continue;
            }
            kputsn_(fmt->p - fmt->p_off, fmt->p_len + fmt->p_off, &tmp);
            if ( irm >=0 )
            {
                bcf_fmt_t tfmt = line->d.fmt[irm]; line->d.fmt[irm] = line->d.fmt[i]; line->d.fmt[i] = tfmt;
                while ( irm<=i && line->d.fmt[irm].p ) irm++;
            }

        }
        if ( irm>=0 ) line->n_fmt = irm;
        free(line->indiv.s);
        line->indiv = tmp;

        // Reallocated line->indiv.s block invalidated line->d.fmt[].p pointers
        size_t off_new = 0;
        for (i=0; i<line->n_fmt; i++)
        {
            uint8_t *p_free = line->d.fmt[i].p_free ? line->d.fmt[i].p - line->d.fmt[i].p_off : NULL;
            line->d.fmt[i].p = (uint8_t*) line->indiv.s + off_new + line->d.fmt[i].p_off;
            off_new += line->d.fmt[i].p_len + line->d.fmt[i].p_off;
            if ( p_free )
            {
                free(p_free);
                line->d.fmt[i].p_free = 0;
            }
        }
    }
    if ( !line->n_sample ) line->n_fmt = 0;
    line->d.shared_dirty = line->d.indiv_dirty = 0;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x20(%rdi), %r12
movq 0x30(%rdi), %r15
andq $0x0, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
cmpq $0x0, 0x20(%rdi)
je 0x26f55
movl 0xb0(%rbx), %eax
testl %eax, %eax
je 0x270fe
testb $0x1, 0xbc(%rbx)
movq %r15, %r14
jne 0x26f3d
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x2b198
movq 0x30(%rbx), %r14
movl 0xb0(%rbx), %eax
testb $0x1, %al
jne 0x26fbe
movslq 0xc0(%rbx), %rsi
movq %rsp, %rdx
movq %r14, %rdi
callq 0x311c6
jmp 0x26fc9
movq 0x10(%r12), %rax
movq %rsp, %r14
movq %rax, 0x10(%r14)
movups (%r12), %xmm0
movaps %xmm0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30f69
movl (%r14), %ebp
movl %ebp, 0xc0(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30fb6
movl (%r14), %r13d
movl %r13d, %eax
subl %ebp, %eax
movl %eax, 0xc4(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x31029
movl (%r14), %eax
subl %r13d, %eax
movl %eax, 0xc8(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x31051
jmp 0x270eb
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x30f69
movslq 0xc0(%rbx), %rax
addq %rax, %r14
movq (%rsp), %rbp
movl %ebp, 0xc0(%rbx)
testb $0x2, 0xb0(%rbx)
jne 0x2701b
movslq 0xc4(%rbx), %rsi
movq %rsp, %rdx
movq %r14, %rdi
callq 0x311c6
cmpq $0x0, 0x8(%rbx)
jne 0x27026
cmpw $0x0, 0x1a(%rbx)
je 0x27026
movq 0x88(%rbx), %rax
movq (%rax), %rdi
callq 0x41c0
movq %rax, 0x8(%rbx)
jmp 0x27026
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x30fb6
movslq 0xc4(%rbx), %rax
addq %rax, %r14
movq (%rsp), %r13
movl %r13d, %eax
subl %ebp, %eax
movl %eax, 0xc4(%rbx)
testb $0x2, 0xbc(%rbx)
je 0x270c2
testb $0x4, 0xb0(%rbx)
jne 0x2706b
cmpl $0x0, 0x68(%rbx)
je 0x27078
movslq 0xc8(%rbx), %rsi
movq %rsp, %rdx
movq %r14, %rdi
callq 0x311c6
jmp 0x27087
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x31029
jmp 0x27087
movq %rsp, %rdi
pushq $-0x1
popq %rcx
xorl %esi, %esi
xorl %edx, %edx
callq 0x27d4a
movslq 0xc8(%rbx), %rax
addq %rax, %r14
movl (%rsp), %eax
subl %r13d, %eax
movl %eax, 0xc8(%rbx)
testb $0x4, 0xbc(%rbx)
je 0x270c2
testb $0x8, 0xb0(%rbx)
je 0x270c2
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x31051
movq 0x30(%rbx), %r14
addq 0x20(%rbx), %r14
movq 0x20(%rbx), %rax
movq 0x30(%rbx), %rdi
subq %r14, %rax
addq %rdi, %rax
testl %eax, %eax
je 0x270e6
movslq %eax, %rsi
movq %rsp, %rdx
movq %r14, %rdi
callq 0x311c6
movq 0x30(%rbx), %rdi
callq 0x45c0
movq 0x10(%rsp), %rax
movq %rax, 0x10(%r12)
movaps (%rsp), %xmm0
movups %xmm0, (%r12)
cmpq %r15, 0x30(%rbx)
je 0x27111
testb $0x4, 0xbc(%rbx)
jne 0x27354
movq 0x18(%rbx), %rax
movq %rax, %rcx
shrq $0x28, %rcx
sete %cl
movq %rax, %rdx
shrq $0x20, %rdx
testb %dl, %dl
sete %dl
orb %cl, %dl
je 0x2714d
movabsq $0x10000000000, %rcx    # imm = 0x10000000000
cmpq %rcx, %rax
jae 0x27281
movl %eax, %eax
movq %rax, 0x18(%rbx)
jmp 0x27281
cmpq $0x0, 0x38(%rbx)
je 0x27161
cmpl $0x0, 0xb4(%rbx)
je 0x27281
pushq $-0x1
popq %rbp
pushq $0x1
popq %r12
leaq 0x38(%rbx), %rcx
movq %rcx, 0x18(%rsp)
movq %rsp, %rcx
andq $0x0, 0x10(%rcx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rcx)
xorl %r14d, %r14d
movabsq $0x100000000, %r15      # imm = 0x100000000
movq %rax, %rcx
shrq $0x20, %rcx
movzbl %cl, %ecx
cmpq %rcx, %r14
jae 0x27298
movq 0x98(%rbx), %rax
movq %r14, %r13
shlq $0x5, %r13
movq 0x10(%rax,%r13), %rdi
testq %rdi, %rdi
je 0x27268
addq %r13, %rax
movl 0x1c(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
subq %rcx, %rdi
movl 0x18(%rax), %esi
addl %ecx, %esi
movq %rsp, %rdx
callq 0x311c6
testl %ebp, %ebp
js 0x27272
movq 0x98(%rbx), %rdx
movl %ebp, %eax
movq %rax, %rcx
shlq $0x5, %rcx
movups (%rdx,%rcx), %xmm0
movups 0x10(%rdx,%rcx), %xmm1
movaps %xmm1, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movups (%rdx,%r13), %xmm0
movups 0x10(%rdx,%r13), %xmm1
movups %xmm0, (%rdx,%rcx)
movups %xmm1, 0x10(%rdx,%rcx)
movq 0x98(%rbx), %rdx
movaps 0x20(%rsp), %xmm0
movaps 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rdx,%r13)
movups %xmm0, (%rdx,%r13)
cmpl %r12d, %ebp
movl %r12d, %edx
cmovgl %ebp, %edx
shlq $0x20, %rax
orq $0x10, %rcx
movq %rax, %rsi
sarq $0x20, %rsi
cmpq %r14, %rsi
jg 0x27270
movq 0x98(%rbx), %rsi
cmpq $0x0, (%rsi,%rcx)
je 0x27272
incl %ebp
addq %r15, %rax
addq $0x20, %rcx
jmp 0x27243
testl %ebp, %ebp
cmovsl %r14d, %ebp
jmp 0x27272
movl %edx, %ebp
incq %r14
incl %r12d
movq 0x18(%rbx), %rax
jmp 0x2718c
andq $0x0, 0xb0(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebp, %ebp
js 0x272b8
movzbl %bpl, %ecx
shlq $0x20, %rcx
movabsq $-0xff00000001, %rdx    # imm = 0xFFFFFF00FFFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, 0x18(%rbx)
movq 0x48(%rbx), %rdi
callq 0x45c0
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rax, 0x10(%rcx)
movaps (%rsp), %xmm0
movups %xmm0, (%rcx)
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x18(%rbx), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movzbl %cl, %ecx
cmpq %rcx, %r15
jae 0x2712f
movq 0x98(%rbx), %rax
movl 0x1c(%rax,%r14), %r13d
testl %r13d, %r13d
js 0x2730b
xorl %edi, %edi
jmp 0x2731a
movq 0x10(%rax,%r14), %rdi
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
subq %r13, %rdi
movq 0x48(%rbx), %rcx
addq %r12, %rcx
addq %r13, %rcx
movq %rcx, 0x10(%rax,%r14)
addl 0x18(%rax,%r14), %r13d
testq %rdi, %rdi
je 0x27348
callq 0x45c0
movq 0x98(%rbx), %rax
andl $0x7fffffff, 0x1c(%rax,%r14) # imm = 0x7FFFFFFF
addq %r13, %r12
incq %r15
addq $0x20, %r14
jmp 0x272df
movslq 0xc0(%rbx), %rax
movslq 0xc4(%rbx), %rcx
addq %rax, %rcx
movslq 0xc8(%rbx), %r14
addq %rcx, %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movzwl 0x18(%rbx), %eax
cmpq %rax, %r12
jae 0x27111
movq 0x90(%rbx), %rax
movl 0x1c(%rax,%r15), %r13d
testl %r13d, %r13d
js 0x27397
xorl %edi, %edi
jmp 0x273a6
movq 0x10(%rax,%r15), %rdi
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
subq %r13, %rdi
movq 0x30(%rbx), %rcx
addq %r14, %rcx
addq %r13, %rcx
movq %rcx, 0x10(%rax,%r15)
addl 0x18(%rax,%r15), %r13d
testq %rdi, %rdi
je 0x273d4
callq 0x45c0
movq 0x90(%rbx), %rax
andl $0x7fffffff, 0x1c(%rax,%r15) # imm = 0x7FFFFFFF
addq %r13, %r14
incq %r12
addq $0x28, %r15
jmp 0x27375