// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/razf.c
// Function: razf_read
static int _razf_read(RAZF* rz, void *data, int size){
	int ret, tin;
	if(rz->z_eof || rz->z_err) return 0;
	if (rz->file_type == FILE_TYPE_PLAIN) {
#ifdef _USE_KNETFILE
		ret = knet_read(rz->x.fpr, data, size);
#else
		ret = read(rz->filedes, data, size);
#endif        
		if (ret == 0) rz->z_eof = 1;
		return ret;
	}
	rz->stream->avail_out = size;
	rz->stream->next_out  = data;
	while(rz->stream->avail_out){
		if(rz->stream->avail_in == 0){
			if(rz->in >= rz->end){ rz->z_eof = 1; break; }
			if(rz->end - rz->in < RZ_BUFFER_SIZE){
#ifdef _USE_KNETFILE
				rz->stream->avail_in = knet_read(rz->x.fpr, rz->inbuf, rz->end -rz->in);
#else
				rz->stream->avail_in = read(rz->filedes, rz->inbuf, rz->end -rz->in);
#endif        
			} else {
#ifdef _USE_KNETFILE
				rz->stream->avail_in = knet_read(rz->x.fpr, rz->inbuf, RZ_BUFFER_SIZE);
#else
				rz->stream->avail_in = read(rz->filedes, rz->inbuf, RZ_BUFFER_SIZE);
#endif        
			}
			if(rz->stream->avail_in == 0){
				rz->z_eof = 1;
				break;
			}
			rz->stream->next_in = rz->inbuf;
		}
		tin = rz->stream->avail_in;
		ret = inflate(rz->stream, Z_BLOCK);
		rz->in += tin - rz->stream->avail_in;
		if(ret == Z_NEED_DICT || ret == Z_MEM_ERROR || ret == Z_DATA_ERROR){
			fprintf(stderr, "[_razf_read] inflate error: %d %s (at %s:%d)\n", ret, rz->stream->msg ? rz->stream->msg : "", __FILE__, __LINE__);
			rz->z_err = 1;
			break;
		}
		if(ret == Z_STREAM_END){
			rz->z_eof = 1;
			break;
		}
		if ((rz->stream->data_type&128) && !(rz->stream->data_type&64)){
			rz->buf_flush = 1;
			rz->next_block_pos = rz->in;
			break;
		}
	}
	return size - rz->stream->avail_out;
}

// Assembly:
xorl %eax, %eax
cmpl $0x0, 0x8c(%rdi)
je 0x22a4d
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x88(%rdi)
jne 0x22b54
cmpl $0x2, 0x4(%rbx)
jne 0x22a8f
movq 0x8(%rbx), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x1c4bd
testl %eax, %eax
jne 0x22b54
movl $0x1, 0x8c(%rbx)
jmp 0x22b54
movq 0x10(%rbx), %rax
movl $0x1000, 0x20(%rax)     # imm = 0x1000
movq %rsi, 0x18(%rax)
movl $0x1000, %r14d          # imm = 0x1000
movl $0xc0, %ebp
movq 0x10(%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x22b48
cmpl $0x0, 0x8(%rax)
jne 0x22aed
movq 0x30(%rbx), %rdx
subq 0x20(%rbx), %rdx
jle 0x22b3e
cmpq %r14, %rdx
cmovgeq %r14, %rdx
movq 0x8(%rbx), %rdi
movq 0x60(%rbx), %rsi
callq 0x1c4bd
movq 0x10(%rbx), %rcx
movl %eax, 0x8(%rcx)
testl %eax, %eax
je 0x22b3e
movq 0x60(%rbx), %rax
movq %rax, (%rcx)
movq 0x10(%rbx), %rdi
movl 0x8(%rdi), %r15d
movl $0x5, %esi
callq 0x3270
movq 0x10(%rbx), %rcx
subl 0x8(%rcx), %r15d
addq 0x20(%rbx), %r15
movq %r15, 0x20(%rbx)
cmpl $0x1, %eax
je 0x22b3e
leal 0x4(%rax), %edx
cmpl $0x2, %edx
jb 0x22b5f
cmpl $0x2, %eax
je 0x22b5f
movl 0x58(%rcx), %eax
andl %ebp, %eax
cmpl $0x80, %eax
jne 0x22aa9
movl $0x1, 0x40(%rbx)
movq %r15, 0x58(%rbx)
jmp 0x22b48
movl $0x1, 0x8c(%rbx)
movq 0x10(%rbx), %rcx
movl $0x1000, %eax           # imm = 0x1000
subl 0x20(%rcx), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xc482(%rip), %rdx      # 0x2efe8
movq (%rdx), %rdi
movq 0x30(%rcx), %rdx
testq %rdx, %rdx
leaq 0x3ded(%rip), %rcx      # 0x26964
cmovneq %rdx, %rcx
leaq 0x544e(%rip), %rsi      # 0x27fd0
leaq 0x5440(%rip), %r8       # 0x27fc9
movl %eax, %edx
movl $0x25d, %r9d            # imm = 0x25D
xorl %eax, %eax
callq 0x3630
movl $0x1, 0x88(%rbx)
jmp 0x22b48