Function at 0x508500
Capabilities:
Encode data using xor
Generate random numbers using the delphi lcg

Disassembly:
push ebp
mov ebp, esp
push ebx
push edi
push esi
sub esp, 0x1c
mov eax, dword [ebp + 8]
mov edi, 0xffffff9a
test eax, eax
je 0x508818
mov ecx, dword [eax + 0xe0]
test ecx, ecx
je 0x508818
cmp dword [ecx], 0
je 0x508813
mov edx, dword [ebp + 0x10]
xor edi, edi
test edx, edx
je 0x508818
mov eax, dword [ebp + 0xc]
mov dword [ecx + 0x10], eax
mov dword [ecx + 0x14], edx
mov dword [ebp - 0x10], ecx
mov eax, dword [ebp - 0x10]
mov esi, dword [eax + 0x7c]
mov eax, dword [ebp - 0x10]
mov eax, dword [eax + 8]
mov ecx, dword [ebp - 0x10]
mov ecx, dword [ecx + 0x78]
mov ebx, ecx
add ebx, eax
adc esi, 0
cmp ebx, edx
sbb esi, 0
mov esi, dword [ebp - 0x10]
jae 0x508580
cmp dword [esi + 0xc8], 0
je 0x508580
add ecx, eax
mov dword [esi + 0x14], ecx
je 0x508818
lea eax, [esi + 4]
mov dword [ebp - 0x24], eax
lea eax, [esi + 0x88]
mov dword [ebp - 0x28], eax
xor edi, edi
xor eax, eax
dec eax
mov dword [ebp - 0x1c], eax
mov ebx, dword [esi + 8]
test ebx, ebx
je 0x50862e
mov eax, dword [esi + 0xb8]
test eax, eax
je 0x5085b9
cmp dword [esi + 0xc8], 0
je 0x50878d
test ebx, ebx
jne 0x5085c9
mov eax, dword [esi + 0x78]
or eax, dword [esi + 0x7c]
je 0x508822
mov eax, dword [esi + 0x14]
cmp eax, ebx
cmovb ebx, eax
test ebx, ebx
je 0x5085e8
xor eax, eax
mov ecx, dword [esi + 4]
mov edx, dword [esi + 0x10]
mov cl, byte [ecx + eax]
mov byte [edx + eax], cl
inc eax
cmp ebx, eax
jne 0x5085d7
add dword [esi + 0x68], ebx
adc dword [esi + 0x6c], 0
push ebx
push dword [esi + 0x10]
push dword [esi + 0x70]
call fcn.0042cac0
add esp, 0xc
mov dword [esi + 0x70], eax
sub dword [esi + 0x80], ebx
sbb dword [esi + 0x84], 0
sub dword [esi + 8], ebx
sub dword [esi + 0x14], ebx
add dword [esi + 0x10], ebx
add dword [esi + 4], ebx
add dword [esi + 0x18], ebx
add edi, ebx
cmp dword [esi + 0x14], 0
jne 0x508597
jmp 0x508818
mov ebx, dword [esi + 0x78]
mov eax, dword [esi + 0x7c]
mov ecx, ebx
or ecx, eax
je 0x50880c
mov ecx, 0x4000
cmp ebx, ecx
cmovae ebx, ecx
test eax, eax
cmovne ebx, ecx
mov eax, dword [esi + 0xc0]
add eax, dword [esi + 0x40]
mov ecx, dword [esi + 0xc4]
adc ecx, dword [esi + 0x44]
push 0
push ecx
push eax
push dword [esi + 0xb4]
push dword [ebp - 0x28]
call fcn.00512720
add esp, 0x14
test eax, eax
jne 0x508825
mov eax, dword [esi]
mov dword [ebp - 0x18], eax
mov ecx, dword [esi + 0x8c]
mov dword [ebp - 0x14], ebx
mov ebx, dword [esi + 0xb4]
mov esi, dword [esi + 0xa4]
call dword [section..00cfg]
push dword [ebp - 0x14]
push dword [ebp - 0x18]
push ebx
mov ebx, dword [ebp - 0x14]
push esi
call ecx
add esp, 0x10
cmp eax, ebx
jne 0x508825
mov dword [ebp - 0x20], edi
mov edx, dword [ebp + 8]
cmp dword [edx + 0xe4], 0
mov edi, dword [ebp - 0x10]
je 0x50876d
xor esi, esi
mov eax, dword [edx + 0xf4]
mov ecx, eax
and ecx, 0xfffd
or eax, 2
xor ecx, 3
imul ecx, eax
mov eax, dword [edi]
xor ch, byte [eax + esi]
mov byte [eax + esi], ch
mov edi, dword [edx + 0xf8]
mov dword [ebp - 0x18], edi
mov eax, dword [edx + 0xec]
mov edx, dword [ebp + 8]
mov ebx, dword [edx + 0xf4]
mov edx, eax
xor dl, ch
movzx edx, dl
shr eax, 8
xor eax, dword [edi + edx*4]
mov edx, dword [ebp + 8]
mov dword [edx + 0xec], eax
mov edx, 0xff
and eax, edx
mov edx, dword [ebp + 8]
add eax, dword [edx + 0xf0]
imul eax, eax, 0x8088405
inc eax
mov dword [edx + 0xf0], eax
shr eax, 0x18
mov edx, ebx
mov edi, 0xff
and edx, edi
xor edx, eax
shr ebx, 8
mov eax, dword [ebp - 0x18]
xor ebx, dword [eax + edx*4]
mov edi, dword [ebp - 0x10]
mov eax, dword [ebp + 8]
mov dword [eax + 0xf4], ebx
mov ebx, dword [ebp - 0x14]
mov edx, dword [ebp + 8]
mov eax, dword [edi]
mov byte [eax + esi], ch
inc esi
cmp ebx, esi
jne 0x5086cc
add dword [edi + 0x40], ebx
adc dword [edi + 0x44], 0
sub dword [edi + 0x78], ebx
sbb dword [edi + 0x7c], 0
mov eax, dword [edi]
mov dword [edi + 4], eax
mov dword [edi + 8], ebx
mov esi, edi
mov edi, dword [ebp - 0x20]
jmp 0x5085a2
cmp eax, 0xc
je 0x50861f
mov ebx, dword [esi + 0x10]
mov eax, dword [esi + 0x18]
mov dword [ebp - 0x14], eax
push 2
push dword [ebp - 0x24]
call fcn.0045f4a0
add esp, 8
mov ecx, eax
test eax, eax
mov dword [ebp - 0x20], edi
js 0x5087c1
cmp dword [esi + 0x1c], 0
mov eax, 0xfffffffd
cmovne ecx, eax
mov dword [ebp - 0x18], ecx
mov ecx, ebx
mov eax, dword [ebp - 0x14]
mov edi, dword [esi + 0x18]
sub edi, eax
mov ebx, 0
sbb ebx, ebx
mov eax, dword [esi + 0x70]
add dword [esi + 0x68], edi
adc dword [esi + 0x6c], ebx
push edi
push ecx
push eax
call fcn.0042cac0
add esp, 0xc
mov dword [esi + 0x70], eax
sub dword [esi + 0x80], edi
sbb dword [esi + 0x84], ebx
mov eax, dword [ebp - 0x20]
add edi, eax
mov eax, dword [ebp - 0x18]
test eax, eax
jne 0x50882a
mov esi, dword [ebp - 0x10]
jmp 0x50861f
xor ebx, ebx
jmp 0x5085a2
mov edi, 0xffffff9c
mov eax, edi
add esp, 0x1c
pop esi
pop edi
pop ebx
pop ebp
ret
mov dword [ebp - 0x1c], edi
mov edi, dword [ebp - 0x1c]
jmp 0x508818
mov dword [ebp - 0x1c], edi
mov edi, eax
cmp eax, 1
jne 0x508818
jmp 0x508825