// File: /workspace/github_c_makefile_star2_O2/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 0x9a716
movb $0x1, %bl
cmpl $0x2, %eax
jne 0x9a738
leaq 0x20(%r14), %r15
movl 0x3c(%r14), %esi
movl %esi, 0x38(%r14)
movq 0x18(%r14), %rax
movq %rax, 0x10(%r14)
movq 0x58(%r14), %rax
movq %rax, 0x48(%r14)
movq 0xf0(%r14), %rcx
testq %rcx, %rcx
je 0x9a63d
movl 0x8(%rcx), %eax
testl %eax, %eax
jle 0x9a623
movl %eax, 0x38(%r14)
movl %eax, %esi
movq %r15, %rdi
callq 0x63b3a
movq 0xf0(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x28(%rax)
jmp 0x9a695
movq 0xe8(%r14), %rdi
movq (%rdi), %rcx
movq %rax, %rsi
callq *0x20(%rcx)
movq 0x10(%r14), %rax
movl 0x38(%r14), %ecx
movq %rax, %rsi
subq 0x48(%r14), %rsi
movslq %ecx, %rcx
cmpq %rcx, %rsi
cmovgl %ecx, %esi
cmpq $-0x1, %rax
cmovel %ecx, %esi
movq %r15, %rdi
callq 0x63b3a
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x9a682
movq (%rax), %rsi
jmp 0x9a684
xorl %esi, %esi
movq 0xe8(%r14), %rdi
movl 0x30(%r14), %edx
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x10(%r14), %rdx
movq 0x48(%r14), %rcx
cmpq $-0x1, %rdx
je 0x9a6bc
movslq 0x38(%r14), %rsi
movq %rdx, %rdi
subq %rcx, %rdi
cmpq %rsi, %rdi
jge 0x9a6bc
cmpq $0x0, 0xf0(%r14)
je 0x9a722
cmpl $-0x1, %eax
je 0x9a731
movslq %eax, %rsi
addq %rsi, %rcx
movl %eax, 0x38(%r14)
movq %rcx, 0x58(%r14)
cmpq $-0x1, %rdx
je 0x9a6de
cmpq %rdx, %rcx
jle 0x9a6de
movq %rcx, 0x10(%r14)
andl $0x0, 0x50(%r14)
testl %eax, %eax
jne 0x9a738
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 0x9a736
cmpl $0x0, 0x38(%r14)
je 0x9a5f2
jmp 0x9a738
movw $0x5, 0xf8(%r14)
jmp 0x9a736
movl %eax, 0x38(%r14)
testl %eax, %eax
jle 0x9a731
andl $0x0, 0x50(%r14)
jmp 0x9a738
andl $0x0, 0x38(%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq