// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x6426a
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0x20(%rax)
je 0x6426a
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movl $0xff00, %edx           # imm = 0xFF00
callq 0x64100
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0x8(%rax)
ja 0x64242
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x643c2
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0x8(%rax)
jne 0x64255
jmp 0x643af
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rcx, (%rax)
jmp 0x64271
movl $0x0, -0x14(%rbp)
jmp 0x64273
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0xc(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x10000, %ecx          # imm = 0x10000
subl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
xorl %esi, %esi
callq 0x4450
movl %eax, -0x18(%rbp)
cmpl $-0x5, -0x18(%rbp)
jne 0x642d6
jmp 0x64391
cmpl $0x0, -0x18(%rbp)
jge 0x6436e
leaq 0x262f9(%rip), %rax     # 0x8a5e0
cmpl $0x1, (%rax)
jl 0x64344
movq 0x25cdd(%rip), %rax     # 0x89fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $-0x3, -0x18(%rbp)
jne 0x64314
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x6431c
xorl %eax, %eax
movq %rax, -0x30(%rbp)
jmp 0x6431c
movl -0x20(%rbp), %edi
movq -0x30(%rbp), %rsi
callq 0x63940
movq -0x28(%rbp), %rdi
movq %rax, %rcx
leaq 0x19f93(%rip), %rsi     # 0x7e2c9
leaq 0x19fa8(%rip), %rdx     # 0x7e2e5
movb $0x0, %al
callq 0x4830
movq -0x10(%rbp), %rax
movl (%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
orl $0x1, %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 0x643c2
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rcx
movl $0x10000, %eax          # imm = 0x10000
subl 0x20(%rcx), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x6438f
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x643c2
jmp 0x64391
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0x20(%rax)
je 0x64273
jmp 0x643a5
cmpl $0x1, -0x18(%rbp)
jne 0x641e6
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rcx
movl $0x10000, %eax          # imm = 0x10000
subl 0x20(%rcx), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)