// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
testl %esi, %esi
sete %cl
leaq 0x58(%rdi), %r14
movl $0xff00, %r15d          # imm = 0xFF00
testb $0x1, %cl
je 0x443f1
movq 0x58(%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x443f1
movq 0x28(%rbx), %rdi
movq 0x38(%rbx), %r13
movq 0x8(%r13), %rsi
movq 0x10(%r13), %r12
subq %rsi, %r12
cmpq %r15, %r12
movl $0xff00, %r15d          # imm = 0xFF00
cmovbq %r12, %r15
movq %rdi, (%rsp)
movq %r15, %rdx
callq 0x4420
addq %r15, 0x8(%r13)
cmpq $0xfeff, %r12           # imm = 0xFEFF
ja 0x443d3
movl $0xff00, %edx           # imm = 0xFF00
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rcx
callq 0x48187
movq %rax, %r15
movq 0x58(%rbx), %rax
movl %r15d, 0x8(%rax)
testl %r15d, %r15d
je 0x4448b
movq 0x28(%rbx), %rcx
movq %rcx, (%rax)
movl $0xff00, %r15d          # imm = 0xFF00
movslq 0xc(%rbx), %rax
movl $0x10000, %ecx          # imm = 0x10000
subl %eax, %ecx
addq 0x20(%rbx), %rax
movq 0x58(%rbx), %rdi
movq %rax, 0x18(%rdi)
movl %ecx, 0x20(%rdi)
movq $0x0, 0x30(%rdi)
xorl %esi, %esi
callq 0x4410
cmpl $-0x5, %eax
je 0x4443c
testl %eax, %eax
js 0x4445a
movq (%r14), %rcx
movl 0x20(%rcx), %ecx
leal -0x10000(%rcx), %edx
negl %edx
cmpl $0x10000, %ecx          # imm = 0x10000
cmovnel %edx, %ebp
jne 0x4446e
movq (%r14), %rcx
movl 0x20(%rcx), %edx
testl %edx, %edx
je 0x443f1
movb $0x1, %cl
cmpl $0x1, %eax
jne 0x44374
movl $0x10000, %ebp          # imm = 0x10000
subl %edx, %ebp
jmp 0x4446e
leaq 0x200ef(%rip), %rcx     # 0x64550
cmpl $0x0, (%rcx)
jg 0x4447f
orb $0x1, (%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
movq %r14, %rsi
callq 0x5bb3
jmp 0x44466
xorl %ebp, %ebp
jmp 0x4446e