Function at 0x515240
Capabilities:
Encrypt data using rc4 prga

Disassembly:
push ebp
mov ebp, esp
push ebx
push edi
push esi
sub esp, 0x1c
mov esi, ecx
mov edi, dword [ebp + 0xc]
test edi, edi
je 0x5153ad
movzx ebx, word [ebp + 8]
mov dword [esi], 0
test bl, 1
jne 0x51540e
xor eax, eax
movzx ebx, bx
shr ebx, 1
inc eax
mov ecx, ebx
test bl, 1
je 0x51526b
mov dword [ebp - 0x20], eax
mov dword [ebp - 0x24], ecx
bsr ecx, ecx
xor ecx, 0x1f
mov eax, 0x20
sub eax, ecx
imul eax, edi
cmp eax, 0xde3
jg 0x515418
xor edx, edx
inc edx
mov eax, edx
add edx, edx
cmp eax, edi
jle 0x51529c
mov dword [ebp - 0x18], esi
mov edx, eax
sar edx, 2
cmp eax, 4
jae 0x5153c2
movzx esi, bx
xor edi, edi
mov dword [ebp - 0x14], 0
mov eax, esi
or eax, edi
je 0x515309
mov dword [ebp - 0x1c], edx
xor eax, eax
mov ebx, edi
mov edx, esi
mov ecx, edi
mov edi, esi
mov esi, 0xfffffff
and edx, esi
mov esi, dword [ebp - 0x18]
mov dword [esi + eax*4 + 4], edx
mov edx, ecx
shld edx, edi, 4
shr ebx, 0x1c
inc eax
mov esi, 0xfffffff
cmp esi, edi
mov esi, 0
sbb esi, ecx
mov esi, edx
mov edi, ebx
jb 0x5152ce
mov ecx, dword [ebp - 0x18]
mov word [ecx], ax
mov edx, dword [ebp - 0x1c]
test byte [ebp - 0x14], 1
jne 0x515428
test edx, edx
mov ecx, dword [ebp - 0x18]
mov edi, dword [ebp + 0xc]
jne 0x51543c
movsx edx, word [ecx]
mov dword [ebp - 0x14], edx
test edx, edx
je 0x5153a3
mov esi, dword [ebp - 0x20]
imul esi, edi
mov edx, 0x92492493
mov eax, esi
imul edx
add edx, esi
mov eax, edx
shr eax, 0x1f
sar edx, 4
add edx, eax
add word [ecx + 2], dx
mov eax, dword [ebp - 0x14]
cmp ax, 0x7f
jg 0x515418
test ax, ax
jle 0x5153a3
mov edi, esi
lea eax, [edx + edx*8]
lea eax, [eax + eax*2]
add eax, edx
sub edi, eax
mov eax, 0x1c
mov dword [ebp - 0x20], edi
sub eax, edi
xor ebx, ebx
xor edi, edi
mov esi, ebx
mov ecx, dword [ebp - 0x18]
mov edx, dword [ecx + edi*4 + 4]
mov ebx, edx
mov ecx, eax
shr ebx, cl
mov ecx, dword [ebp - 0x20]
shl edx, cl
add edx, esi
mov esi, dword [ebp - 0x18]
and edx, 0xfffffff
mov dword [esi + edi*4 + 4], edx
inc edi
cmp dword [ebp - 0x14], edi
jne 0x515376
test ebx, ebx
jne 0x51541d
add esp, 0x1c
pop esi
pop edi
pop ebx
pop ebp
ret 8
mov word [esi + 2], 0
mov dword [esi + 4], 1
xor eax, eax
inc eax
mov word [esi], ax
jmp 0x5153a3
movzx esi, bx
mov dword [ebp - 0x14], 0
or ecx, 0x20
xor edi, edi
mov eax, edx
mov dword [ebp - 0x1c], eax
mov eax, edi
imul eax, esi
mov dword [ebp - 0x10], eax
mov eax, esi
mul esi
mov edi, edx
mov edx, dword [ebp - 0x10]
add edi, edx
add edi, edx
mov esi, eax
mov eax, dword [ebp - 0x1c]
test dword [ebp + 0xc], eax
jne 0x51546b
mov edx, eax
sar edx, 1
cmp eax, 2
jb 0x5152c1
mov eax, edx
test edi, edi
jne 0x5152c1
jmp 0x5153d3
movzx ecx, bx
xor eax, eax
jmp 0x515278
call fcn.006b3610
mov eax, dword [ebp - 0x14]
mov dword [esi + eax*4 + 4], ebx
mov eax, dword [esi]
jmp 0x5153bc
mov ecx, dword [ebp - 0x18]
push dword [ebp - 0x24]
mov esi, edx
call fcn.00515160
mov edx, esi
jmp 0x515313
mov ebx, edx
call fcn.00719710
mov esi, ebx
test ebx, edi
je 0x515454
mov ecx, dword [ebp - 0x18]
push dword [ebp - 0x24]
call fcn.00515160
mov eax, esi
sar eax, 1
cmp esi, 1
mov edx, eax
mov ecx, dword [ebp - 0x18]
mov edi, dword [ebp + 0xc]
jbe 0x515321
jmp 0x51543c
mov eax, esi
shrd eax, edi, cl
mov edx, edi
shr edx, cl
mov dword [ebp - 0x10], 0
test cl, 0x20
cmovne eax, edx
mov dword [ebp - 0x28], eax
mov eax, dword [ebp - 0x10]
cmove eax, edx
mov dword [ebp - 0x10], eax
xor edx, edx
inc edx
mov eax, dword [ebp - 0x28]
or dword [ebp - 0x10], eax
movzx eax, bx
cmove edx, eax
mov dword [ebp - 0x10], edx
setne al
mov edx, dword [ebp - 0x14]
or dl, al
mov dword [ebp - 0x14], edx
mov eax, dword [ebp - 0x10]
mul esi
imul edi, dword [ebp - 0x10]
add edi, edx
mov esi, eax
mov eax, dword [ebp - 0x1c]
jmp 0x5153f5