// File: /workspace/github_c_makefile_star2_O3/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 0x389a4
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x31aec
cmpl $0x0, 0x54(%r12)
movq 0x38(%r12), %rbp
je 0x3198e
movq (%r14), %rsi
movq %rbp, %rdi
callq 0x8ca7b
testl %eax, %eax
js 0x31aec
movq 0x38(%r12), %rdi
movq 0x68(%r12), %rax
testq %rax, %rax
je 0x3197a
cmpq $0x0, 0x48(%rdi)
jne 0x3197a
movq 0x18(%rdi), %rcx
shlq $0x10, %rcx
movzwl 0x10(%rdi), %esi
orq %rcx, %rsi
movq %rax, %rdi
callq 0xc4fa
movq 0x38(%r12), %rdi
movq 0x10(%r12), %rdx
movq 0x20(%r12), %rsi
callq 0x8caa5
jmp 0x31a42
movq %r15, 0x10(%rsp)
movq 0x10(%r12), %rdx
movq 0x20(%r12), %rcx
testb $0x2, 0x30(%rbp)
movq 0x18(%rbp), %r15
movq %rcx, 0x8(%rsp)
jne 0x319dd
movq %r15, %rax
subq 0x8(%rbp), %rax
cmpq %rdx, %rax
jae 0x319dd
addq %rdx, %r15
subq (%rbp), %r15
movq %rbp, %rdi
movq %r15, %rsi
movq %rdx, %r15
callq 0x98194
movq 0x8(%rsp), %rcx
movq %r15, %rdx
movq 0x18(%rbp), %r15
movq %r15, 0x10(%rbp)
movq 0x8(%rbp), %rdi
subq %rdi, %r15
cmpq %rdx, %r15
ja 0x319ef
cmpq (%rbp), %rdi
je 0x31a2b
cmpq %rdx, %r15
movq %r14, 0x20(%rsp)
movq %rdx, %r14
cmovbq %r15, %r14
movq %rcx, %rsi
movq %rdx, 0x18(%rsp)
movq %r14, %rdx
callq 0x43c0
movq 0x18(%rsp), %rdx
movq %r14, %rax
movq 0x20(%rsp), %r14
addq %rax, 0x8(%rbp)
cmpq %rdx, %r15
movq 0x10(%rsp), %r15
jb 0x31a32
jmp 0x31a42
xorl %eax, %eax
movq 0x10(%rsp), %r15
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movq %rax, %rcx
callq 0x98670
movq 0x68(%r12), %rdi
testq %rdi, %rdi
je 0x31ae2
cmpl $0x2, 0x54(%r12)
jne 0x31ae2
movq %r14, %rbp
movq %rax, %r14
movslq 0x10(%r15), %rsi
testq %rsi, %rsi
sets %al
testq %r13, %r13
sete %cl
orb %al, %cl
jne 0x31a8d
cmpl %esi, 0x4(%r13)
jle 0x31a8d
movq 0x18(%r13), %rax
movq %rsi, %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rax
jmp 0x31a8f
xorl %eax, %eax
testq %rax, %rax
leaq 0x7ae76(%rip), %rdx     # 0xac90f
cmovneq %rax, %rdx
callq 0xc46c
testl %eax, %eax
js 0x31aec
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 0x89ea8
testl %eax, %eax
movq %r14, %rax
movq %rbp, %r14
js 0x31aec
xorl %ebx, %ebx
cmpq (%r14), %rax
setne %bl
negl %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq