// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/bgzf.c
// Function: bgzf_read
ssize_t bgzf_read(BGZF *fp, void *data, size_t length)
{
    ssize_t bytes_read = 0;
    uint8_t *output = (uint8_t*)data;
    if (length <= 0) return 0;
    assert(fp->is_write == 0);
    while (bytes_read < length) {
        int copy_length, available = fp->block_length - fp->block_offset;
        uint8_t *buffer;
        if (available <= 0) {
            if (bgzf_read_block(fp) != 0) return -1;
            available = fp->block_length - fp->block_offset;
            if (available <= 0) break;
        }
        copy_length = length - bytes_read < available? length - bytes_read : available;
        buffer = (uint8_t*)fp->uncompressed_block;
        memcpy(output, buffer + fp->block_offset, copy_length);
        fp->block_offset += copy_length;
        output += copy_length;
        bytes_read += copy_length;
    }
    if (fp->block_offset == fp->block_length) {
        fp->block_address = htell(fp->fp);
        fp->block_offset = fp->block_length = 0;
    }
    fp->uncompressed_address += bytes_read;
    return bytes_read;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
ja 0x9c7e8
movq $0x0, -0x8(%rbp)
jmp 0x9c955
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x9c7fb
jmp 0x9c81a
leaq 0x47392(%rip), %rdi     # 0xe3b94
leaq 0x4730c(%rip), %rsi     # 0xe3b15
movl $0x229, %edx            # imm = 0x229
leaq 0x47391(%rip), %rcx     # 0xe3ba6
callq 0x6450
jmp 0x9c81c
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x9c8ff
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jg 0x9c87a
movq -0x10(%rbp), %rdi
callq 0x9b9a0
cmpl $0x0, %eax
je 0x9c85c
movq $-0x1, -0x8(%rbp)
jmp 0x9c955
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jg 0x9c878
jmp 0x9c8ff
jmp 0x9c87a
movq -0x20(%rbp), %rax
subq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
cmpq %rcx, %rax
jae 0x9c899
movq -0x20(%rbp), %rax
subq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x9c8a1
movslq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq 0xc(%rax), %rax
addq %rax, %rsi
movslq -0x34(%rbp), %rdx
callq 0x6570
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movl -0x34(%rbp), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movslq -0x34(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x9c81c
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x9c93d
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x9bfd0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop