// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/io/instream.cpp
// Function: smooth::IO::InStream::ReadData()
S::Bool S::IO::InStream::ReadData()
{
	if (streamType == STREAM_NONE) { lastError = IO_ERROR_NOTOPEN; return False; }

	if (streamType != STREAM_DRIVER) return True;

	/* Loop until we have some data.
	 */
	Int	 decsize = 0;

	do
	{
		packageSize    = stdpacksize;
		size	       = origsize;
		currentFilePos = origfilepos;

		if (filter == NIL)
		{
			/* Read unfiltered data.
			 */
			driver->Seek(currentFilePos);

			if (size != -1)	dataBuffer.Resize(packageSize < size - currentFilePos ? packageSize : size - currentFilePos);
			else		dataBuffer.Resize(packageSize);

			decsize = driver->ReadData(dataBuffer, dataBuffer.Size());
		}
		else
		{
			/* Read filtered data.
			 */
			if (filter->GetPackageSize() > 0) packageSize = filter->GetPackageSize();

			dataBuffer.Resize(packageSize);

			decsize = filter->ReadData(dataBuffer);
		}

		/* Update package size and buffer positions.
		 */
		if (packageSize <= size - currentFilePos || filter != NIL || size == -1)
		{
			if (decsize == -1) { packageSize = 0; return False; }

			packageSize = decsize;
			origfilepos = currentFilePos + packageSize;

			if (packageSize + currentFilePos > size && size != -1) size = packageSize + currentFilePos;
		}
		else
		{
			packageSize = decsize;

			if (decsize <= 0) { packageSize = 0; return False; }
		}

		currentBufferPos = 0;

		/* Bail out if more data is requested, but we do not have any more.
		 */
		if (packageSize == 0 && driver->GetPos() == driver->GetSize()) return False;
	}
	while (packageSize == 0);

	return True;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movzwl 0x8(%rdi), %eax
testl %eax, %eax
je 0x9f219
movb $0x1, %bl
cmpl $0x2, %eax
jne 0x9f22f
leaq 0x20(%r14), %r15
movl 0x3c(%r14), %eax
movl %eax, 0x38(%r14)
movq 0x18(%r14), %rax
movq %rax, 0x10(%r14)
movq 0x58(%r14), %rsi
movq %rsi, 0x48(%r14)
movq 0xf0(%r14), %rax
testq %rax, %rax
je 0x9f133
movl 0x8(%rax), %eax
testl %eax, %eax
jle 0x9f115
movl %eax, 0x38(%r14)
movl 0x38(%r14), %esi
movq %r15, %rdi
callq 0x62eaa
movq 0xf0(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x28(%rax)
jmp 0x9f188
movq 0xe8(%r14), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x10(%r14), %rsi
movslq 0x38(%r14), %rax
cmpq $-0x1, %rsi
je 0x9f15d
subq 0x48(%r14), %rsi
cmpq %rax, %rsi
cmovgl %eax, %esi
movq %r15, %rdi
jmp 0x9f162
movq %r15, %rdi
movl %eax, %esi
callq 0x62eaa
movq 0x28(%r14), %rax
movq 0xe8(%r14), %rdi
testq %rax, %rax
je 0x9f17c
movq (%rax), %rsi
jmp 0x9f17e
xorl %esi, %esi
movl 0x30(%r14), %edx
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x10(%r14), %rdx
movq 0x48(%r14), %rcx
cmpq $-0x1, %rdx
je 0x9f1b9
movslq 0x38(%r14), %rsi
movq %rdx, %rdi
subq %rcx, %rdi
cmpq %rsi, %rdi
jge 0x9f1b9
cmpq $0x0, 0xf0(%r14)
jne 0x9f1b9
movl %eax, 0x38(%r14)
testl %eax, %eax
jg 0x9f1db
jmp 0x9f225
cmpl $-0x1, %eax
je 0x9f225
movslq %eax, %rsi
addq %rsi, %rcx
movl %eax, 0x38(%r14)
movq %rcx, 0x58(%r14)
cmpq $-0x1, %rdx
je 0x9f1db
cmpq %rdx, %rcx
jle 0x9f1db
movq %rcx, 0x10(%r14)
movl $0x0, 0x50(%r14)
cmpl $0x0, 0x38(%r14)
jne 0x9f20c
movq 0xe8(%r14), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, %r12
movq 0xe8(%r14), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
cmpq %rax, %r12
je 0x9f22d
cmpl $0x0, 0x38(%r14)
je 0x9f0e6
jmp 0x9f22f
movw $0x5, 0xf8(%r14)
jmp 0x9f22d
movl $0x0, 0x38(%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop