Function at 0x51d710
Capabilities:
Encode data using xor

Disassembly:
push ebp
mov ebp, esp
push ecx
push ebx
mov ebx, dword [ebp + 0x10]
push esi
mov esi, dword [ebp + 8]
push edi
mov eax, dword [esi + 0x1e4]
mov edx, dword [esi + 0xa94]
add eax, 0x355
and edx, dword [ebp + 0x18]
shl eax, 4
add eax, edx
lea ecx, [esi + eax*2]
mov eax, dword [esi + 0x20]
cmp ebx, 0xffffffff
jne 0x51d882
mov ebx, dword [ebp + 0xc]
mov dword [esi + eax*4 + 0x28], 0
mov eax, dword [esi + 0x20]
mov dword [esi + eax*4 + 0xfc], ecx
mov eax, dword [esi + 0x20]
inc eax
mov dword [esi + 0x20], eax
mov edi, dword [ebx]
mov edx, dword [ebx + 0x18]
mov ecx, dword [ebx + 0x14]
mov dword [ebp + 8], eax
mov eax, edi
sub eax, edx
mov dword [ebp + 0x10], edx
movzx edx, byte [eax + ecx - 1]
mov ecx, 8
sub cl, byte [esi + 0xa98]
mov eax, dword [esi + 0xa9c]
and eax, dword [ebp + 0x18]
shr edx, cl
mov ecx, dword [esi + 0xa98]
shl eax, cl
add edx, eax
mov eax, edi
sub eax, dword [ebx + 0x18]
imul ecx, edx, 0x600
mov edx, dword [ebx + 0x14]
movzx edx, byte [eax + edx]
add ecx, 0xaa0
add ecx, esi
cmp dword [esi + 0x1e4], 7
mov dword [ebp + 0x18], ecx
jge 0x51d7cd
push edx
push 8
push ecx
push esi
call fcn.0051e9c0
add esp, 0x10
jmp 0x51d831
sub edi, dword [esi + 0x1e8]
sub edi, dword [ebp + 0x10]
mov eax, dword [ebx + 0x14]
mov ebx, 0x100
add edx, ebx
movzx edi, byte [edi + eax - 1]
mov ecx, dword [ebp + 8]
mov eax, edx
shr eax, 7
add edi, edi
and eax, 1
mov dword [esi + ecx*4 + 0x28], eax
mov ecx, ebx
and ecx, edi
mov eax, edx
shr eax, 8
add ecx, ebx
add eax, ecx
add edx, edx
mov ecx, dword [ebp + 0x18]
lea ecx, [ecx + eax*2]
mov eax, dword [esi + 0x20]
mov dword [esi + eax*4 + 0xfc], ecx
inc dword [esi + 0x20]
mov eax, dword [esi + 0x20]
mov dword [ebp + 8], eax
mov eax, edi
xor eax, edx
not eax
and ebx, eax
cmp edx, 0x10000
jb 0x51d7e5
mov ebx, dword [ebp + 0xc]
mov eax, dword [esi + 0x1e4]
cmp eax, 3
jg 0x51d851
xor eax, eax
mov dword [esi + 0x1e4], eax
mov eax, dword [ebp + 0x14]
sub dword [ebx + 0x18], eax
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
cmp eax, 9
jg 0x51d86c
add eax, 0xfffffffd
mov dword [esi + 0x1e4], eax
mov eax, dword [ebp + 0x14]
sub dword [ebx + 0x18], eax
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
add eax, 0xfffffffa
mov dword [esi + 0x1e4], eax
mov eax, dword [ebp + 0x14]
sub dword [ebx + 0x18], eax
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov edi, dword [ebp + 0x14]
mov dword [esi + eax*4 + 0x28], 1
mov eax, dword [esi + 0x20]
push edi
mov dword [esi + eax*4 + 0xfc], ecx
mov eax, dword [esi + 0x20]
inc eax
mov dword [esi + 0x20], eax
mov ecx, dword [esi + 0x1e4]
add ecx, 0x3610
lea eax, [esi + eax*4]
lea ecx, [esi + ecx*2]
cmp ebx, 4
jae 0x51d8e2
mov dword [eax + 0x28], 1
mov eax, dword [esi + 0x20]
push ebx
push edx
push esi
mov dword [esi + eax*4 + 0xfc], ecx
inc dword [esi + 0x20]
call fcn.0051ecd0
mov eax, dword [ebp + 0xc]
add esp, 0x10
sub dword [eax + 0x18], edi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov dword [eax + 0x28], 0
mov eax, dword [esi + 0x20]
mov dword [esi + eax*4 + 0xfc], ecx
lea eax, [ebx - 4]
inc dword [esi + 0x20]
push eax
push edx
push esi
call fcn.0051e870
mov eax, dword [ebp + 0xc]
add esp, 0x10
sub dword [eax + 0x18], edi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret