// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/io/outstream.cpp
// Function: smooth::IO::OutStream::OutputData(void const*, int)
S::Bool S::IO::OutStream::OutputData(const Void *pointer, Int bytes)
{
	if (streamType == STREAM_NONE)	 { lastError = IO_ERROR_NOTOPEN; return False; }
	if (packageSize <= 0)		 { lastError = IO_ERROR_UNKNOWN; return False; }
	if (bytes > 0 && pointer == NIL) { lastError = IO_ERROR_BADPARAM; return False; }
	if (bytes < 0)			 { lastError = IO_ERROR_BADPARAM; return False; }

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

	Int	 bytesleft	= bytes;
	Int	 databufferpos	= 0;

	while (bytesleft)
	{
		Int	 amount = ((packageSize - currentBufferPos) < (bytesleft)) ? (packageSize - currentBufferPos) : (bytesleft);

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

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

		if (size < currentFilePos) size = currentFilePos;

		if (!WriteData()) { lastError = IO_ERROR_UNKNOWN; return False; }
	}

	return True;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movswl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0xe815a
movq -0x30(%rbp), %rax
movw $0x5, 0xf8(%rax)
movb $0x0, -0x1(%rbp)
jmp 0xe82b2
movq -0x30(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jg 0xe817a
movq -0x30(%rbp), %rax
movw $0x4, 0xf8(%rax)
movb $0x0, -0x1(%rbp)
jmp 0xe82b2
cmpl $0x0, -0x1c(%rbp)
jle 0xe819d
cmpq $0x0, -0x18(%rbp)
jne 0xe819d
movq -0x30(%rbp), %rax
movw $0x2, 0xf8(%rax)
movb $0x0, -0x1(%rbp)
jmp 0xe82b2
cmpl $0x0, -0x1c(%rbp)
jge 0xe81b9
movq -0x30(%rbp), %rax
movw $0x2, 0xf8(%rax)
movb $0x0, -0x1(%rbp)
jmp 0xe82b2
movq -0x30(%rbp), %rax
testb $0x1, 0x60(%rax)
je 0xe81d6
movq -0x30(%rbp), %rax
testb $0x1, 0x61(%rax)
jne 0xe81d6
movq -0x30(%rbp), %rdi
callq 0x5a7a0
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0xe82ae
movq -0x30(%rbp), %rcx
movl 0x38(%rcx), %eax
subl 0x50(%rcx), %eax
cmpl -0x20(%rbp), %eax
jge 0xe820b
movq -0x30(%rbp), %rcx
movl 0x38(%rcx), %eax
subl 0x50(%rcx), %eax
movl %eax, -0x34(%rbp)
jmp 0xe8211
movl -0x20(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, -0x28(%rbp)
addq $0x20, %rdi
callq 0x71100
movq %rax, %rdi
movq -0x30(%rbp), %rax
movslq 0x50(%rax), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movslq -0x24(%rbp), %rax
addq %rax, %rsi
movslq -0x28(%rbp), %rdx
callq 0x593a0
movq -0x30(%rbp), %rcx
movl -0x28(%rbp), %edx
movl -0x20(%rbp), %eax
subl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x28(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl 0x50(%rcx), %eax
movl %eax, 0x50(%rcx)
movslq -0x28(%rbp), %rax
addq 0x48(%rcx), %rax
movq %rax, 0x48(%rcx)
movq 0x10(%rcx), %rax
cmpq 0x48(%rcx), %rax
jge 0xe8289
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rdi
callq 0x5be10
testb $0x1, %al
jne 0xe82a9
movq -0x30(%rbp), %rax
movw $0x4, 0xf8(%rax)
movb $0x0, -0x1(%rbp)
jmp 0xe82b2
jmp 0xe81e3
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)