// File: /workspace/github_c_makefile_star2_O1/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 0x12c75
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x88(%rdi)
jne 0x12d7c
cmpl $0x2, 0x4(%rbx)
jne 0x12cb7
movq 0x8(%rbx), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x1582a
testl %eax, %eax
jne 0x12d7c
movl $0x1, 0x8c(%rbx)
jmp 0x12d7c
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 0x12d70
cmpl $0x0, 0x8(%rax)
jne 0x12d15
movq 0x30(%rbx), %rdx
subq 0x20(%rbx), %rdx
jle 0x12d66
cmpq %r14, %rdx
cmovgeq %r14, %rdx
movq 0x8(%rbx), %rdi
movq 0x60(%rbx), %rsi
callq 0x1582a
movq 0x10(%rbx), %rcx
movl %eax, 0x8(%rcx)
testl %eax, %eax
je 0x12d66
movq 0x60(%rbx), %rax
movq %rax, (%rcx)
movq 0x10(%rbx), %rdi
movl 0x8(%rdi), %r15d
movl $0x5, %esi
callq 0x30e0
movq 0x10(%rbx), %rcx
subl 0x8(%rcx), %r15d
addq 0x20(%rbx), %r15
movq %r15, 0x20(%rbx)
cmpl $0x1, %eax
je 0x12d66
leal 0x4(%rax), %edx
cmpl $0x2, %edx
jb 0x12d87
cmpl $0x2, %eax
je 0x12d87
movl 0x58(%rcx), %eax
andl %ebp, %eax
cmpl $0x80, %eax
jne 0x12cd1
movl $0x1, 0x40(%rbx)
movq %r15, 0x58(%rbx)
jmp 0x12d70
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 0xf26a(%rip), %rdx      # 0x21ff8
movq (%rdx), %rdi
movq 0x30(%rcx), %rdx
testq %rdx, %rdx
leaq 0x84f7(%rip), %rcx      # 0x1b296
cmovneq %rdx, %rcx
leaq 0x8a65(%rip), %rsi      # 0x1b80f
leaq 0x8a57(%rip), %r8       # 0x1b808
movl %eax, %edx
movl $0x25d, %r9d            # imm = 0x25D
xorl %eax, %eax
callq 0x3320
movl $0x1, 0x88(%rbx)
jmp 0x12d70