// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/bgzf.c
// Function: bgzf_close
int bgzf_close(BGZF* fp)
{
    int ret, block_length;
    if (fp == 0) return -1;
    if (fp->is_write && fp->is_compressed) {
        if (bgzf_flush(fp) != 0) return -1;
        fp->compress_level = -1;
        block_length = deflate_block(fp, 0); // write an empty block
        if (hwrite(fp->fp, fp->compressed_block, block_length) < 0
            || hflush(fp->fp) != 0) {
            fp->errcode |= BGZF_ERR_IO;
            return -1;
        }
#ifdef BGZF_MT
        if (fp->mt) mt_destroy(fp->mt);
#endif
    }
    if ( fp->is_gzip )
    {
        if (!fp->is_write) (void)inflateEnd(fp->gz_stream);
        else (void)deflateEnd(fp->gz_stream);
        free(fp->gz_stream);
    }
    ret = hclose(fp->fp);
    if (ret != 0) return -1;
    bgzf_index_destroy(fp);
    free(fp->uncompressed_block);
    free(fp->compressed_block);
    free_cache(fp);
    free(fp);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x9d39f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9d520
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x9d47d
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x1d, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x9d47d
movq -0x10(%rbp), %rdi
callq 0x9cc20
cmpl $0x0, %eax
je 0x9d3e3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9d520
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xe00fffff, %ecx       # imm = 0xE00FFFFF
orl $0x1ff00000, %ecx       # imm = 0x1FF00000
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x9cfb0
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movslq -0x18(%rbp), %rdx
callq 0x9d090
cmpq $0x0, %rax
jl 0x9d436
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0xa1f60
cmpl $0x0, %eax
je 0x9d463
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 0x9d520
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x9d47b
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x9d530
jmp 0x9d47d
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x9d4c5
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x9d4ab
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x6720
jmp 0x9d4b8
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x6410
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x6880
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0xa23e0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x9d4e4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9d520
movq -0x10(%rbp), %rdi
callq 0x9d680
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x6880
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x6880
movq -0x10(%rbp), %rdi
callq 0x9d6e0
movq -0x10(%rbp), %rdi
callq 0x6880
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)