// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x58(%rdi), %rdi
testl %esi, %esi
jne 0x433d7
cmpl $0x0, 0x20(%rdi)
sete %dl
testb $0x1, %dl
jne 0x433d7
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 0x4420
addq %r14, 0x8(%r12)
cmpq $0xfeff, %r13           # imm = 0xFEFF
ja 0x433bf
movl $0xff00, %edx           # imm = 0xFF00
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x4716b
movq %rax, %r14
movq 0x58(%rbx), %rdi
movl %r14d, 0x8(%rdi)
testl %r14d, %r14d
je 0x43452
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 0x4410
cmpl $-0x5, %eax
jne 0x4341b
movq (%r14), %rdi
movl 0x20(%rdi), %edx
testl %edx, %edx
je 0x433db
movl $0x10000, %ecx          # imm = 0x10000
subl %edx, %ecx
jmp 0x4342f
testl %eax, %eax
js 0x4343c
movq (%r14), %rdi
movl 0x20(%rdi), %edx
xorl %ecx, %ecx
cmpl $0x10000, %edx          # imm = 0x10000
jne 0x43456
xorl %edx, %edx
cmpl $0x1, %eax
jne 0x43369
jmp 0x4345d
leaq 0x1f10d(%rip), %rcx     # 0x62550
cmpl $0x0, (%rcx)
jg 0x43469
orb $0x1, (%rbx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x4345d
xorl %ecx, %ecx
jmp 0x4345d
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 0x5afc
jmp 0x43448