// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/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 0x132ff
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x88(%rdi)
jne 0x133fc
cmpl $0x2, 0x4(%rbx)
jne 0x13343
movq 0x8(%rbx), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x15e14
testl %eax, %eax
jne 0x133fc
movl $0x1, 0x8c(%rbx)
xorl %eax, %eax
jmp 0x133fc
movq 0x10(%rbx), %rdi
movl $0x1000, 0x20(%rdi)     # imm = 0x1000
movq %rsi, 0x18(%rdi)
movl $0x1000, %r15d          # imm = 0x1000
movl $0xc0, %ebp
cmpl $0x0, 0x20(%rdi)
je 0x133f4
movl 0x8(%rdi), %r14d
testl %r14d, %r14d
jne 0x133a5
movq 0x30(%rbx), %rdx
subq 0x20(%rbx), %rdx
jle 0x133ea
movq 0x8(%rbx), %rdi
movq 0x60(%rbx), %rsi
cmpq %r15, %rdx
cmovgeq %r15, %rdx
callq 0x15e14
movq %rax, %r14
movq 0x10(%rbx), %rdi
movl %r14d, 0x8(%rdi)
testl %r14d, %r14d
je 0x133ea
movq 0x60(%rbx), %rax
movq %rax, (%rdi)
movl $0x5, %esi
callq 0x30e0
movq 0x10(%rbx), %rdi
subl 0x8(%rdi), %r14d
addq 0x20(%rbx), %r14
movq %r14, 0x20(%rbx)
cmpl $0x1, %eax
je 0x133ea
leal 0x4(%rax), %ecx
cmpl $0x2, %ecx
jb 0x13407
cmpl $0x2, %eax
je 0x13407
movl 0x58(%rdi), %eax
andl %ebp, %eax
cmpl $0x80, %eax
jne 0x1335d
movl $0x1, 0x40(%rbx)
movq %r14, 0x58(%rbx)
jmp 0x133f4
movl $0x1, 0x8c(%rbx)
movl $0x1000, %eax           # imm = 0x1000
subl 0x20(%rdi), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xfbea(%rip), %rcx      # 0x22ff8
movq (%rcx), %rdx
movq 0x30(%rdi), %rsi
testq %rsi, %rsi
leaq 0x8f87(%rip), %rcx      # 0x1c3a6
cmovneq %rsi, %rcx
leaq 0x9505(%rip), %rsi      # 0x1c92f
leaq 0x94f7(%rip), %r8       # 0x1c928
movq %rdx, %rdi
movl %eax, %edx
movl $0x25d, %r9d            # imm = 0x25D
xorl %eax, %eax
callq 0x3320
movl $0x1, 0x88(%rbx)
movq 0x10(%rbx), %rdi
jmp 0x133f4