// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/io/instream.cpp
// Function: smooth::IO::InStream::InputString(int)
S::String S::IO::InStream::InputString(Int bytes)
{
	if (streamType == STREAM_NONE)	{ lastError = IO_ERROR_NOTOPEN; return NIL; }
	if (bytes <= 0)			{ lastError = IO_ERROR_BADPARAM; return NIL; }

	if (bitstreamActive && !keepBits) CompleteBitstream();

	Int	 bytesleft	= bytes;
	Int	 databufferpos	= 0;

	Buffer<UnsignedByte>	 stringBuffer(bytes + 1);

	while (bytesleft)
	{
		if (currentFilePos >= (origfilepos + packageSize)) { lastError = IO_ERROR_UNKNOWN; return NIL; }

		while (currentBufferPos >= packageSize)
		{
			/* If no more data is available, set lastError and return NIL.
			 */
			if (!ReadData()) { lastError = IO_ERROR_NODATA; return NIL; }
		}

		/* Get amount of data read and copy to string buffer.
		 */
		Int	 amount = ((packageSize - currentBufferPos) < (bytesleft)) ? (packageSize - currentBufferPos) : (bytesleft);

		memcpy((UnsignedByte *) stringBuffer + databufferpos, (UnsignedByte *) dataBuffer + currentBufferPos, amount);

		bytesleft	 -= amount;
		databufferpos	 += amount;
		currentBufferPos += amount;
		currentFilePos	 += amount;
	}

	stringBuffer[bytes] = 0;

	return String((char *) (UnsignedByte *) stringBuffer);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x68(%rbp)
movq %rdi, %rax
movq %rax, -0x60(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movswl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0xe60af
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rax
movw $0x5, 0xf8(%rax)
xorl %esi, %esi
callq 0x5da90
jmp 0xe62bc
cmpl $0x0, -0x14(%rbp)
jg 0xe60d2
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rax
movw $0x2, 0xf8(%rax)
xorl %esi, %esi
callq 0x5da90
jmp 0xe62bc
movq -0x58(%rbp), %rax
testb $0x1, 0x60(%rax)
je 0xe60ef
movq -0x58(%rbp), %rax
testb $0x1, 0x61(%rax)
jne 0xe60ef
movq -0x58(%rbp), %rdi
callq 0x5bd50
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x14(%rbp), %esi
addl $0x1, %esi
leaq -0x38(%rbp), %rdi
callq 0x71080
cmpl $0x0, -0x18(%rbp)
je 0xe6269
movq -0x58(%rbp), %rdx
movq 0x48(%rdx), %rax
movq 0x58(%rdx), %rcx
movslq 0x38(%rdx), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jl 0xe616d
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rax
movw $0x4, 0xf8(%rax)
xorl %esi, %esi
callq 0x5da90
jmp 0xe6147
movl $0x1, -0x48(%rbp)
jmp 0xe62b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x71000
jmp 0xe62c9
jmp 0xe616f
movq -0x58(%rbp), %rcx
movl 0x50(%rcx), %eax
cmpl 0x38(%rcx), %eax
jl 0xe61ba
movq -0x58(%rbp), %rdi
callq 0x59c50
movb %al, -0x69(%rbp)
jmp 0xe6189
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0xe61b8
jmp 0xe6192
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rax
movw $0x8, 0xf8(%rax)
xorl %esi, %esi
callq 0x5da90
jmp 0xe61ac
movl $0x1, -0x48(%rbp)
jmp 0xe62b3
jmp 0xe616f
movq -0x58(%rbp), %rcx
movl 0x38(%rcx), %eax
subl 0x50(%rcx), %eax
cmpl -0x18(%rbp), %eax
jge 0xe61d8
movq -0x58(%rbp), %rcx
movl 0x38(%rcx), %eax
subl 0x50(%rcx), %eax
movl %eax, -0x70(%rbp)
jmp 0xe61de
movl -0x18(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x71100
movq %rax, -0x78(%rbp)
jmp 0xe61f3
movq -0x58(%rbp), %rdi
movq -0x78(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
addq $0x20, %rdi
callq 0x71100
movq %rax, -0x80(%rbp)
jmp 0xe6218
movq -0x58(%rbp), %rax
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movslq 0x50(%rax), %rax
addq %rax, %rsi
movslq -0x4c(%rbp), %rdx
callq 0x593a0
movq -0x58(%rbp), %rax
movl -0x4c(%rbp), %edx
movl -0x18(%rbp), %ecx
subl %edx, %ecx
movl %ecx, -0x18(%rbp)
movl -0x4c(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movl %ecx, -0x1c(%rbp)
movl -0x4c(%rbp), %ecx
addl 0x50(%rax), %ecx
movl %ecx, 0x50(%rax)
movslq -0x4c(%rbp), %rcx
addq 0x48(%rax), %rcx
movq %rcx, 0x48(%rax)
jmp 0xe610b
movl -0x14(%rbp), %esi
leaq -0x38(%rbp), %rdi
callq 0x717e0
movq %rax, -0x90(%rbp)
jmp 0xe627e
movq -0x90(%rbp), %rax
movb $0x0, (%rax)
leaq -0x38(%rbp), %rdi
callq 0x71100
movq %rax, -0x98(%rbp)
jmp 0xe629a
movq -0x98(%rbp), %rsi
movq -0x68(%rbp), %rdi
callq 0x5c1f0
jmp 0xe62ac
movl $0x1, -0x48(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x71000
movq -0x60(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x5b6b0
nopw %cs:(%rax,%rax)