Function at 0x516430
Capabilities:
Encrypt data using rc4 prga

Disassembly:
push ebp
mov ebp, esp
push ebx
push edi
push esi
sub esp, 0x1c
mov ebx, dword [ebp + 0xc]
test ebx, ebx
je 0x5165a1
movzx eax, word [ebp + 8]
mov dword [ecx], 0
test al, 1
jne 0x5165b2
xor edi, edi
movzx eax, ax
shr eax, 1
inc edi
mov edx, eax
test al, 1
je 0x516458
mov dword [ebp - 0x18], ecx
mov dword [ebp - 0x24], edx
bsr ecx, edx
xor ecx, 0x1f
mov edx, 0x20
sub edx, ecx
imul edx, ebx
cmp edx, 0xde3
jg 0x5165bc
xor esi, esi
inc esi
mov edx, esi
add esi, esi
cmp edx, ebx
jle 0x516489
mov dword [ebp - 0x1c], edi
mov esi, edx
sar esi, 2
mov dword [ebp - 0x10], esi
cmp edx, 4
mov esi, dword [ebp - 0x18]
movzx ebx, ax
jae 0x516602
xor edi, edi
xor edx, edx
mov eax, ebx
or eax, edi
je 0x5164f5
mov dword [ebp - 0x14], edx
xor eax, eax
mov esi, edi
mov edx, ebx
mov ecx, edi
mov edi, 0xfffffff
and edx, edi
mov edi, dword [ebp - 0x18]
mov dword [edi + eax*4 + 4], edx
mov edx, ecx
shld edx, ebx, 4
shr esi, 0x1c
inc eax
mov edi, 0xfffffff
cmp edi, ebx
mov ebx, 0
sbb ebx, ecx
mov ebx, edx
mov edi, esi
jb 0x5164bc
mov esi, dword [ebp - 0x18]
mov word [esi], ax
mov edx, dword [ebp - 0x14]
test dl, 1
jne 0x5165c1
mov eax, dword [ebp - 0x10]
test eax, eax
mov edi, dword [ebp - 0x1c]
mov ebx, dword [ebp + 0xc]
jne 0x5165d0
movsx ecx, word [esi]
mov dword [ebp - 0x10], ecx
test ecx, ecx
je 0x516597
imul edi, ebx
mov ecx, 0x92492493
mov eax, edi
imul ecx
add edx, edi
mov eax, edx
shr eax, 0x1f
sar edx, 4
add edx, eax
add word [esi + 2], dx
mov eax, dword [ebp - 0x10]
cmp ax, 0x7f
jg 0x5165bc
test ax, ax
jle 0x516597
lea eax, [edx + edx*8]
lea eax, [eax + eax*2]
add eax, edx
sub edi, eax
mov dword [ebp - 0x1c], edi
mov eax, 0x1c
sub eax, edi
mov dword [ebp - 0x14], eax
xor ebx, ebx
mov eax, esi
xor esi, esi
mov edi, ebx
mov edx, dword [eax + esi*4 + 4]
mov ebx, edx
mov ecx, dword [ebp - 0x14]
shr ebx, cl
mov ecx, dword [ebp - 0x1c]
shl edx, cl
add edx, edi
and edx, 0xfffffff
mov dword [eax + esi*4 + 4], edx
inc esi
cmp dword [ebp - 0x10], esi
jne 0x516560
test ebx, ebx
je 0x516597
mov ecx, eax
mov eax, dword [ebp - 0x10]
mov dword [ecx + eax*4 + 4], ebx
mov eax, dword [ecx]
inc eax
mov word [ecx], ax
add esp, 0x1c
pop esi
pop edi
pop ebx
pop ebp
ret 8
mov word [ecx + 2], 0
mov dword [ecx + 4], 1
xor eax, eax
jmp 0x516593
movzx edx, ax
xor edi, edi
jmp 0x516464
call fcn.006b7160
mov ecx, esi
push dword [ebp - 0x24]
call fcn.00516350
jmp 0x5164fe
mov ecx, esi
mov edi, eax
call fcn.00720b70
mov esi, edi
test edi, ebx
je 0x5165ea
mov ecx, dword [ebp - 0x18]
push dword [ebp - 0x24]
call fcn.00516350
mov eax, esi
sar eax, 1
cmp esi, 1
mov esi, dword [ebp - 0x18]
mov edi, dword [ebp - 0x1c]
mov ebx, dword [ebp + 0xc]
jbe 0x51650f
jmp 0x5165d0
or ecx, 0x20
xor edx, edx
mov eax, dword [ebp - 0x10]
mov dword [ebp - 0x20], eax
mov dword [ebp - 0x28], ebx
xor edi, edi
mov dword [ebp - 0x14], edx
mov esi, edi
imul esi, ebx
mov eax, ebx
mul ebx
add edx, esi
add edx, esi
mov edi, edx
mov ebx, eax
mov eax, dword [ebp - 0x20]
test dword [ebp + 0xc], eax
je 0x516668
mov eax, ebx
shrd eax, edi, cl
mov esi, edi
shr esi, cl
test cl, 0x20
cmovne eax, esi
mov edx, 0
cmovne esi, edx
or esi, eax
setne byte [ebp - 0x10]
mov eax, dword [ebp - 0x28]
mov edx, 1
cmovne eax, edx
imul edi, eax
mul ebx
add edi, edx
mov edx, dword [ebp - 0x14]
or dl, byte [ebp - 0x10]
mov dword [ebp - 0x14], edx
mov ebx, eax
mov edx, dword [ebp - 0x20]
mov eax, edx
sar eax, 1
mov dword [ebp - 0x10], eax
cmp edx, 2
jae 0x516682
mov esi, dword [ebp - 0x18]
mov edx, dword [ebp - 0x14]
jmp 0x5164af
mov eax, dword [ebp - 0x10]
mov dword [ebp - 0x20], eax
test edi, edi
mov esi, dword [ebp - 0x18]
mov edx, dword [ebp - 0x14]
jne 0x5164af
jmp 0x516612