Function at 0x516640
Capabilities:
Encode data using xor

Disassembly:
mov eax, 8
call fcn.005650a0
mov ecx, dword [esp + 0x18]
push esi
mov esi, dword [esp + 0x10]
mov eax, dword [esi + 0x174]
mov dword [esp + 0x10], eax
xor eax, eax
add ecx, dword [esi + 0x38]
adc eax, dword [esi + 0x3c]
cmp eax, 0xf
ja 0x51687e
jb 0x516679
cmp ecx, 0xffffffe0
ja 0x51687e
cmp dword [esi + 0x16c], 0
mov dword [esi + 0x38], ecx
mov dword [esi + 0x3c], eax
je 0x5166a2
lea ecx, [esi + 0x60]
push ecx
lea edx, [esi + 0x40]
push edx
call fcn.00515780
add esp, 8
mov dword [esi + 0x16c], 0
movzx eax, byte [esi + 0xd]
movzx ecx, byte [esi + 0xe]
movzx edx, byte [esi + 0xf]
push ebx
movzx ebx, byte [esi + 0xc]
shl ebx, 8
or ebx, eax
shl ebx, 8
or ebx, ecx
push ebp
mov ebp, dword [esp + 0x1c]
shl ebx, 8
push edi
mov edi, dword [esi + 0x168]
or ebx, edx
test edi, edi
je 0x516716
cmp dword [esp + 0x28], 0
je 0x5166fe
mov al, byte [ebp]
mov dl, byte [edi + esi + 0x10]
mov ecx, dword [esp + 0x24]
dec dword [esp + 0x28]
xor dl, al
mov byte [ecx], dl
xor byte [edi + esi + 0x40], al
inc ecx
inc edi
inc ebp
and edi, 0xf
mov dword [esp + 0x24], ecx
jne 0x5166d2
jmp 0x516706
test edi, edi
jne 0x51686e
lea eax, [esi + 0x60]
push eax
lea ecx, [esi + 0x40]
push ecx
call fcn.00515780
add esp, 8
mov edx, dword [esp + 0x28]
cmp edx, 0xc00
jb 0x51679b
mov eax, 0xaaaaaaab
mul edx
shr edx, 0xb
mov dword [esp + 0x10], edx
push 0xc00
lea eax, [esi + 0x60]
push eax
lea eax, [esi + 0x40]
push eax
mov ecx, ebp
call fcn.00515900
mov edx, dword [esp + 0x28]
mov eax, dword [esp + 0x30]
push esi
push edx
push 0xc0
push eax
push ebp
call dword [esp + 0x4c]
add ebx, 0xc0
mov eax, ebx
shr eax, 8
mov byte [esi + 0xe], al
mov eax, 0xc00
add dword [esp + 0x44], eax
sub dword [esp + 0x48], eax
mov ecx, ebx
mov edx, ebx
shr ecx, 0x18
shr edx, 0x10
add esp, 0x20
add ebp, eax
sub dword [esp + 0x10], 1
mov byte [esi + 0xc], cl
mov byte [esi + 0xd], dl
mov byte [esi + 0xf], bl
jne 0x516734
mov edx, dword [esp + 0x28]
mov ecx, edx
and ecx, 0xfffffff0
mov dword [esp + 0x14], ecx
je 0x516808
push ecx
mov eax, ecx
lea ecx, [esi + 0x60]
push ecx
lea edx, [esi + 0x40]
shr eax, 4
push edx
mov ecx, ebp
mov dword [esp + 0x1c], eax
call fcn.00515900
mov eax, dword [esp + 0x28]
mov ecx, dword [esp + 0x1c]
mov edx, dword [esp + 0x30]
push esi
push eax
push ecx
push edx
push ebp
call dword [esp + 0x4c]
add ebx, dword [esp + 0x30]
add esp, 0x20
mov eax, ebx
shr eax, 0x18
mov byte [esi + 0xc], al
mov eax, dword [esp + 0x14]
add dword [esp + 0x24], eax
mov ecx, ebx
mov edx, ebx
shr edx, 8
shr ecx, 0x10
add ebp, eax
sub dword [esp + 0x28], eax
mov byte [esi + 0xe], dl
mov edx, dword [esp + 0x28]
mov byte [esi + 0xd], cl
mov byte [esi + 0xf], bl
test edx, edx
je 0x51686e
mov eax, dword [esp + 0x1c]
mov edx, dword [esi + 0x170]
push eax
lea ecx, [esi + 0x10]
push ecx
push esi
call edx
inc ebx
mov ecx, ebx
shr ecx, 0x10
mov eax, ebx
shr eax, 0x18
mov edx, ebx
mov byte [esi + 0xd], cl
mov ecx, dword [esp + 0x30]
shr edx, 8
add esp, 0xc
mov byte [esi + 0xc], al
mov byte [esi + 0xe], dl
mov byte [esi + 0xf], bl
lea eax, [edi + ecx]
sub ebp, ecx
jmp 0x516850
mov cl, byte [eax + ebp]
mov bl, byte [esi + edi + 0x10]
mov edx, dword [esp + 0x28]
xor byte [esi + edi + 0x40], cl
xor bl, cl
dec edx
mov byte [eax], bl
inc edi
inc eax
mov dword [esp + 0x28], edx
test edx, edx
jne 0x516850
mov dword [esi + 0x168], edi
pop edi
pop ebp
pop ebx
xor eax, eax
pop esi
add esp, 8
ret
or eax, 0xffffffff
pop esi
add esp, 8
ret