// File: enbock[P]Warp10Server/ulib/src/ByteArray.cpp
// Function: u::ByteArray::compress()
void ByteArray::compress()
{
	Bytef *compr;
	ulong cl;
	int err;
	ByteArray *ba = new ByteArray();
	ba->writeUInt(_length);

	cl = compressBound(_length);
	compr = (Bytef *)malloc(cl+ba->length());
	ba->position(0);
	ba->readBytes((char*)compr, ba->_length, 0);
	err = compress2(compr+ba->length(), &cl, (const Bytef*)_buffer, _length, Z_BEST_COMPRESSION);

	if(err != Z_OK)
	{
		assert(err == Z_OK && "ByteArray::compress(): Compression error.");
		free(compr);
		return;
	}
	size(cl);
	_length = 0;
	position(0);
	writeBytes((const char *)compr, cl+ba->length(),0);
	delete ba;
	free(compr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x58, %edi
callq 0x434cd0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x40(%rbp)
callq 0x40f0a0
jmp 0x410342
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq 0x50(%rax), %rsi
movl $0x1, %edx
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0x40fba0
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x426290
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq -0x58(%rbp), %rdi
addq %rax, %rdi
callq 0x51a280
movq %rax, -0x10(%rbp)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
xorl %ecx, %ecx
movl %ecx, %esi
callq *0x20(%rax)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x40ff80
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movq -0x48(%rbp), %rax
addq %rcx, %rdi
movq 0x38(%rax), %rdx
movq 0x50(%rax), %rcx
leaq -0x18(%rbp), %rsi
movl $0x9, %r8d
callq 0x426140
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x410469
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x59(%rbp)
jne 0x410412
movb $0x1, %al
movb %al, -0x59(%rbp)
jmp 0x410412
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x41041b
jmp 0x41041d
jmp 0x41045b
leaq 0x1cb988(%rip), %rdi    # 0x5dbdac
leaq 0x1cb9bc(%rip), %rsi    # 0x5dbde7
movl $0x1a4, %edx            # imm = 0x1A4
leaq 0x1cb9c2(%rip), %rcx    # 0x5dbdf9
callq 0x4f37a0
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x58, %esi
callq 0x433cf0
jmp 0x4104f5
movq -0x10(%rbp), %rdi
callq 0x51a5c0
jmp 0x4104ec
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x40f2c0
movq -0x48(%rbp), %rdi
movq $0x0, 0x50(%rdi)
movq (%rdi), %rax
xorl %ecx, %ecx
movl %ecx, %esi
callq *0x20(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq -0x78(%rbp), %rdx
movq -0x48(%rbp), %rdi
movq -0x70(%rbp), %rsi
addq %rax, %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x40f3a0
movq -0x28(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x4104e3
movq -0x68(%rbp), %rdi
callq 0x40f1a0
movq -0x68(%rbp), %rdi
movl $0x58, %esi
callq 0x433cf0
movq -0x10(%rbp), %rdi
callq 0x51a5c0
addq $0x80, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x4deb40
nop