// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/vcf.c
// Function: vcf_write
int vcf_write(htsFile *fp, const bcf_hdr_t *h, bcf1_t *v)
{
    ssize_t ret;
    fp->line.l = 0;
    if (vcf_format1(h, v, &fp->line) != 0)
        return -1;
    if ( fp->format.compression!=no_compression ) {
        if (bgzf_flush_try(fp->fp.bgzf, fp->line.l) < 0)
            return -1;
        if (fp->idx && !fp->fp.bgzf->mt)
            hts_idx_amend_last(fp->idx, bgzf_tell(fp->fp.bgzf));
        ret = bgzf_write(fp->fp.bgzf, fp->line.s, fp->line.l);
    } else {
        ret = hwrite(fp->fp.hfile, fp->line.s, fp->line.l);
    }

    if (fp->idx && fp->format.compression == bgzf) {
        int tid;
        if ((tid = hts_idx_tbi_name(fp->idx, v->rid, bcf_seqname_safe(h, v))) < 0)
            return -1;

        if (bgzf_idx_push(fp->fp.bgzf, fp->idx,
                          tid, v->pos, v->pos + v->rlen,
                          bgzf_tell(fp->fp.bgzf), 1) < 0)
            return -1;
    }

    return ret==fp->line.l ? 0 : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
leaq 0x10(%rdi), %r14
movq $0x0, 0x10(%rdi)
movq %rsi, %rdi
movq %rdx, %rsi
movq %r14, %rdx
callq 0x39689
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x32cc8
cmpl $0x0, 0x54(%r12)
movq 0x38(%r12), %rbp
je 0x32b4a
movq (%r14), %rsi
movq %rbp, %rdi
callq 0x8eb19
testl %eax, %eax
js 0x32cc8
movq 0x68(%r12), %rdi
testq %rdi, %rdi
je 0x32b2e
movq 0x38(%r12), %rax
cmpq $0x0, 0x48(%rax)
jne 0x32b2e
movq 0x18(%rax), %rcx
shlq $0x10, %rcx
movzwl 0x10(%rax), %esi
orq %rcx, %rsi
callq 0xc7df
movq 0x38(%r12), %rdi
movq 0x10(%r12), %rdx
movq 0x20(%r12), %rsi
callq 0x8eb43
movq %rax, %rbp
jmp 0x32c04
movq %r14, 0x8(%rsp)
movq 0x10(%r12), %rdx
movq 0x20(%r12), %rcx
testb $0x2, 0x30(%rbp)
movq %rdx, 0x18(%rsp)
jne 0x32b96
movq 0x18(%rbp), %rsi
movq %rsi, %rax
subq 0x8(%rbp), %rax
cmpq %rdx, %rax
jae 0x32b96
addq %rdx, %rsi
subq (%rbp), %rsi
movq %rbp, %rdi
movq %rcx, %r14
callq 0x9a811
movq %r14, %rcx
movq 0x18(%rsp), %rdx
movq 0x18(%rbp), %rax
movq %rax, 0x10(%rbp)
movq 0x8(%rbp), %rdi
movq 0x18(%rbp), %r14
subq %rdi, %r14
cmpq %rdx, %r14
ja 0x32bb0
cmpq (%rbp), %rdi
je 0x32c58
movq %r15, 0x10(%rsp)
cmpq %rdx, %r14
movq %rdx, %r15
cmovbq %r14, %r15
movq %rcx, %rsi
movq %r15, %rdx
movq %rcx, 0x20(%rsp)
callq 0x43c0
movq 0x18(%rsp), %rdx
addq %r15, 0x8(%rbp)
cmpq %rdx, %r14
jae 0x32bf7
movq %rbp, %rdi
movq 0x20(%rsp), %rsi
movq %r15, %rcx
callq 0x9acfa
movq %rax, %rbp
movq 0x8(%rsp), %r14
jmp 0x32bff
movq 0x8(%rsp), %r14
movq %r15, %rbp
movq 0x10(%rsp), %r15
movq 0x68(%r12), %rdi
testq %rdi, %rdi
je 0x32cbe
cmpl $0x2, 0x54(%r12)
jne 0x32cbe
movl 0x10(%r15), %esi
xorl %eax, %eax
cmpq $0x1, %r15
movl $0x0, %ecx
sbbl %ecx, %ecx
orl %esi, %ecx
testq %r13, %r13
sete %dl
testl %ecx, %ecx
sets %r8b
orb %dl, %r8b
jne 0x32c71
cmpl %ecx, 0x4(%r13)
jle 0x32c6f
movq 0x18(%r13), %rax
movl %ecx, %ecx
shlq $0x4, %rcx
movq (%rax,%rcx), %rax
jmp 0x32c71
movq %rbp, %rdi
movq %rcx, %rsi
xorl %ecx, %ecx
callq 0x9acfa
movq %rax, %rbp
movq 0x8(%rsp), %r14
jmp 0x32c04
xorl %eax, %eax
testq %rax, %rax
leaq 0x7cce4(%rip), %rdx     # 0xaf95f
cmovneq %rax, %rdx
callq 0xc751
testl %eax, %eax
js 0x32cc8
movq 0x38(%r12), %rdi
movq 0x68(%r12), %rsi
movq (%r15), %rcx
movq 0x8(%r15), %r8
addq %rcx, %r8
movq 0x18(%rdi), %rdx
shlq $0x10, %rdx
movzwl 0x10(%rdi), %r9d
orq %rdx, %r9
movl $0x1, (%rsp)
movl %eax, %edx
callq 0x8bddc
testl %eax, %eax
js 0x32cc8
xorl %ebx, %ebx
cmpq (%r14), %rbp
setne %bl
negl %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq