// File: /workspace/github_c_makefile_star2_O0/zhou-lab[P]tbmate/htslib/bgzf.c
// Function: bgzf_flush
int bgzf_flush(BGZF *fp)
{
    if (!fp->is_write) return 0;
#ifdef BGZF_MT
    if (fp->mt) {
        if (fp->block_offset) mt_queue(fp); // guaranteed that assertion does not fail
        return mt_flush_queue(fp);
    }
#endif
    while (fp->block_offset > 0) {
        int block_length;
        if ( fp->idx_build_otf )
        {
            bgzf_index_add_block(fp);
            fp->idx->ublock_addr += fp->block_offset;
        }
        block_length = deflate_block(fp, fp->block_offset);
        if (block_length < 0) {
            if (hts_verbose >= 3) fprintf(stderr, "[E::%s] deflate_block error %d\n", __func__, block_length);
            return -1;
        }
        if (hwrite(fp->fp, fp->compressed_block, block_length) != block_length) {
            if (hts_verbose >= 1) fprintf(stderr, "[E::%s] hwrite error (wrong size)\n", __func__);
            fp->errcode |= BGZF_ERR_IO; // possibly truncated file
            return -1;
        }
        fp->block_address += block_length;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x3b899
movl $0x0, -0x4(%rbp)
jmp 0x3b9e9
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x3b8c8
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x3b8b7
movq -0x10(%rbp), %rdi
callq 0x3ba00
movq -0x10(%rbp), %rdi
callq 0x3bab0
movl %eax, -0x4(%rbp)
jmp 0x3b9e9
jmp 0x3b8ca
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jle 0x3b9e2
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x3b903
movq -0x10(%rbp), %rdi
callq 0x3b080
movq -0x10(%rbp), %rax
movslq 0xc(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x3bc70
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x3b956
leaq 0x49b6d(%rip), %rax     # 0x85490
cmpl $0x3, (%rax)
jl 0x3b94a
movq 0x496b9(%rip), %rax     # 0x84fe8
movq (%rax), %rdi
movl -0x14(%rbp), %ecx
leaq 0x3c9a1(%rip), %rsi     # 0x782dd
leaq 0x3c9ba(%rip), %rdx     # 0x782fd
movb $0x0, %al
callq 0x37f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3b9e9
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movslq -0x14(%rbp), %rdx
callq 0x3bd80
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
je 0x3b9cd
leaq 0x49b11(%rip), %rax     # 0x85490
cmpl $0x1, (%rax)
jl 0x3b9a3
movq 0x4965d(%rip), %rax     # 0x84fe8
movq (%rax), %rdi
leaq 0x3c973(%rip), %rsi     # 0x78308
leaq 0x3c961(%rip), %rdx     # 0x782fd
movb $0x0, %al
callq 0x37f0
movq -0x10(%rbp), %rax
movl (%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
orl $0x4, %edx
movl (%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3b9e9
movslq -0x14(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
jmp 0x3b8ca
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)