// File: /workspace/github_c_makefile_star2_O3/zhou-lab[P]tbmate/htslib/bgzf.c
// Function: inflate_gzip_block
static int inflate_gzip_block(BGZF *fp, int cached)
{
    int ret = Z_OK;
    do
    {
        if ( !cached && fp->gz_stream->avail_out!=0 )
        {
            fp->gz_stream->avail_in = hread(fp->fp, fp->compressed_block, BGZF_BLOCK_SIZE);
            if ( fp->gz_stream->avail_in<=0 ) return fp->gz_stream->avail_in;
            if ( fp->gz_stream->avail_in==0 ) break;
            fp->gz_stream->next_in = fp->compressed_block;
        }
        else cached = 0;
        do
        {
            fp->gz_stream->next_out = (Bytef*)fp->uncompressed_block + fp->block_offset;
            fp->gz_stream->avail_out = BGZF_MAX_BLOCK_SIZE - fp->block_offset;
            fp->gz_stream->msg = NULL;
            ret = inflate(fp->gz_stream, Z_NO_FLUSH);
            if ( ret==Z_BUF_ERROR ) continue;   // non-critical error
            if ( ret<0 ) {
                if (hts_verbose >= 1) {
                    fprintf(stderr, "[E::%s] inflate failed: %s\n",
                            __func__,
                            bgzf_zerr(ret, ret == Z_DATA_ERROR ? fp->gz_stream : NULL));
                }
                fp->errcode |= BGZF_ERR_ZLIB;
                return -1;
            }
            unsigned int have = BGZF_MAX_BLOCK_SIZE - fp->gz_stream->avail_out;
            if ( have ) return have;
        }
        while ( fp->gz_stream->avail_out == 0 );
    }
    while (ret != Z_STREAM_END);
    return BGZF_MAX_BLOCK_SIZE - fp->gz_stream->avail_out;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x58(%rdi), %rdi
testl %esi, %esi
jne 0x27b8b
cmpl $0x0, 0x20(%rdi)
sete %dl
testb $0x1, %dl
jne 0x27b8b
movq 0x28(%rbx), %r15
movq 0x38(%rbx), %r12
movq 0x8(%r12), %rsi
movq 0x10(%r12), %r13
subq %rsi, %r13
movl $0xff00, %r14d          # imm = 0xFF00
cmpq %r14, %r13
cmovbq %r13, %r14
movq %r15, %rdi
movq %r14, %rdx
callq 0x3850
addq %r14, 0x8(%r12)
cmpq $0xfeff, %r13           # imm = 0xFEFF
ja 0x27b73
movl $0xff00, %edx           # imm = 0xFF00
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x2b8df
movq %rax, %r14
movq 0x58(%rbx), %rdi
movl %r14d, 0x8(%rdi)
testl %r14d, %r14d
je 0x27c06
movq 0x28(%rbx), %rax
movq %rax, (%rdi)
leaq 0x58(%rbx), %r14
movslq 0xc(%rbx), %rax
movq %rax, %rcx
addq 0x20(%rbx), %rcx
movl $0x10000, %edx          # imm = 0x10000
subl %eax, %edx
movq %rcx, 0x18(%rdi)
movl %edx, 0x20(%rdi)
movq $0x0, 0x30(%rdi)
xorl %esi, %esi
callq 0x3310
cmpl $-0x5, %eax
jne 0x27bcf
movq (%r14), %rdi
movl 0x20(%rdi), %edx
testl %edx, %edx
je 0x27b8f
movl $0x10000, %ecx          # imm = 0x10000
subl %edx, %ecx
jmp 0x27be3
testl %eax, %eax
js 0x27bf0
movq (%r14), %rdi
movl 0x20(%rdi), %edx
xorl %ecx, %ecx
cmpl $0x10000, %edx          # imm = 0x10000
jne 0x27c0a
xorl %edx, %edx
cmpl $0x1, %eax
jne 0x27b1d
jmp 0x27c11
leaq 0x37891(%rip), %rcx     # 0x5f488
cmpl $0x0, (%rcx)
jg 0x27c1d
orb $0x1, (%rbx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x27c11
xorl %ecx, %ecx
jmp 0x27c11
movl $0x10000, %ecx          # imm = 0x10000
subl %edx, %ecx
movl %ecx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl %eax, %edi
movq %r14, %rsi
callq 0x4716
jmp 0x27bfc