// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/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 0x2d8b3b
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x88(%rdi)
jne 0x2d8c39
cmpl $0x2, 0x4(%rbx)
jne 0x2d8b7f
movl 0x8(%rbx), %edi
movl $0x1000, %edx           # imm = 0x1000
callq 0x17a60
testl %eax, %eax
jne 0x2d8c39
movl $0x1, 0x8c(%rbx)
xorl %eax, %eax
jmp 0x2d8c39
movq 0x10(%rbx), %rdi
movl $0x1000, 0x20(%rdi)     # imm = 0x1000
movq %rsi, 0x18(%rdi)
movl $0x1000, %r15d          # imm = 0x1000
pushq $0x5
popq %rbp
movl $0xc0, %r12d
cmpl $0x0, 0x20(%rdi)
je 0x2d8c31
movl 0x8(%rdi), %r14d
testl %r14d, %r14d
jne 0x2d8be4
movq 0x30(%rbx), %rdx
subq 0x20(%rbx), %rdx
jle 0x2d8c27
movl 0x8(%rbx), %edi
movq 0x60(%rbx), %rsi
cmpq %r15, %rdx
cmovgeq %r15, %rdx
callq 0x17a60
movq %rax, %r14
movq 0x10(%rbx), %rdi
movl %r14d, 0x8(%rdi)
testl %r14d, %r14d
je 0x2d8c27
movq 0x60(%rbx), %rax
movq %rax, (%rdi)
movl %ebp, %esi
callq 0x21c115
movq 0x10(%rbx), %rdi
subl 0x8(%rdi), %r14d
addq 0x20(%rbx), %r14
movq %r14, 0x20(%rbx)
cmpl $0x1, %eax
je 0x2d8c27
leal 0x4(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2d8c42
cmpl $0x2, %eax
je 0x2d8c42
movl 0x58(%rdi), %eax
andl %r12d, %eax
cmpl $0x80, %eax
jne 0x2d8b9d
movl $0x1, 0x40(%rbx)
movq %r14, 0x58(%rbx)
jmp 0x2d8c31
movl $0x1, 0x8c(%rbx)
movl $0x1000, %eax           # imm = 0x1000
subl 0x20(%rdi), %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x15f31f(%rip), %rcx    # 0x437f68
movq (%rcx), %rdx
movq 0x30(%rdi), %rsi
testq %rsi, %rsi
leaq 0x91916(%rip), %rcx     # 0x36a570
cmovneq %rsi, %rcx
leaq 0xaed2b(%rip), %rsi     # 0x387990
leaq 0xaed00(%rip), %r8      # 0x38796c
movq %rdx, %rdi
movl %eax, %edx
movl $0x25d, %r9d            # imm = 0x25D
xorl %eax, %eax
callq 0x17a50
movl $0x1, 0x88(%rbx)
movq 0x10(%rbx), %rdi
jmp 0x2d8c31