Function at 0x50f510
Capabilities:
Encrypt data using rc4 prga

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x3c
push ebx
push esi
mov esi, edx
mov dword [ebp - 4], ecx
mov dword [ebp - 0x14], esi
push edi
test esi, esi
jne 0x50f5e8
mov esi, 0xb
mov dword [ebp - 0x14], esi
mov eax, dword [ebp + 0x10]
mov edi, dword [ebp + 0xc]
bsr eax, eax
bsr ecx, edi
add eax, 2
inc ecx
cmp ecx, eax
cmovb eax, ecx
cmp esi, eax
jb 0x50f725
xor eax, eax
cmp dword [ebp + 0x14], eax
push 0
sete al
push edi
push 0x40000000
push 0
lea eax, [eax*2 - 1]
movzx eax, ax
mov dword [ebp - 0x20], eax
call fcn.00525470
mov dword [ebp - 0x2c], eax
mov ecx, 0x2a
sub ecx, esi
mov dword [ebp - 0x28], edx
mov eax, 0x3e
xor edx, edx
sub eax, esi
mov ebx, 1
mov dword [ebp - 0x18], eax
xor eax, eax
bts eax, ecx
cmp ecx, 0x20
cmovae edx, eax
xor eax, edx
cmp ecx, 0x40
mov ecx, esi
mov dword [ebp - 0x34], eax
cmovae edx, eax
mov esi, edi
shr esi, cl
xor eax, eax
shl ebx, cl
mov dword [ebp - 0x30], edx
xor edx, edx
mov dword [ebp - 0x24], esi
xor esi, esi
mov dword [ebp - 0x10], ebx
mov dword [ebp - 0xc], eax
movzx ecx, ax
movzx eax, ax
mov dword [ebp - 0x38], eax
mov eax, dword [ebp + 8]
mov dword [ebp - 0x1c], ecx
mov dword [ebp - 0x3c], edx
mov ecx, dword [eax + esi*4]
cmp ecx, edi
je 0x50f71c
test ecx, ecx
jne 0x50f606
xor edi, edi
jmp 0x50f6b3
cmp esi, 5
jb 0x50f725
cmp esi, 0xc
jbe 0x50f531
mov eax, 0xffffffd4
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
cmp ecx, dword [ebp - 0x24]
ja 0x50f617
mov ecx, dword [ebp - 0x20]
dec ebx
movzx edi, cx
jmp 0x50f6b0
mov eax, dword [ebp - 0x28]
mul ecx
mov ebx, eax
mov eax, dword [ebp - 0x2c]
mul ecx
mov ecx, dword [ebp - 0x18]
add ebx, edx
mov dword [ebp - 0xc], eax
mov edx, ebx
mov dword [ebp - 8], ebx
call fcn.00525010
movzx ebx, ax
cmp bx, 8
jge 0x50f67e
mov ecx, dword [ebp - 0x18]
movsx edi, bx
mov eax, edi
cdq
call fcn.00525030
sub dword [ebp - 0xc], eax
mov ecx, dword [edi*4 + 0x5a51f0]
sbb dword [ebp - 8], edx
mov eax, dword [ebp - 0x30]
mul ecx
mov edi, eax
mov eax, dword [ebp - 0x34]
mul ecx
add edi, edx
cmp dword [ebp - 8], edi
jb 0x50f67a
ja 0x50f673
cmp dword [ebp - 0xc], eax
jbe 0x50f67a
mov eax, 1
jmp 0x50f67c
xor eax, eax
add ebx, eax
movzx edx, bx
movsx eax, bx
mov ecx, edx
mov ebx, dword [ebp - 0x10]
mov edi, edx
sub ebx, eax
cmp dx, word [ebp - 0x38]
mov eax, esi
cmovle eax, dword [ebp - 0x3c]
cmp dx, word [ebp - 0x1c]
mov dword [ebp - 0x3c], eax
mov eax, dword [ebp - 0x1c]
mov edx, dword [ebp - 0x3c]
movzx eax, ax
cmovle ecx, eax
movzx eax, cx
mov dword [ebp - 0xc], eax
mov dword [ebp - 0x10], ebx
mov eax, dword [ebp - 4]
mov ecx, esi
inc esi
mov word [eax + ecx*2], di
mov eax, dword [ebp - 0xc]
mov edi, dword [ebp + 0xc]
cmp esi, dword [ebp + 0x10]
jbe 0x50f5c0
mov esi, dword [ebp - 4]
mov eax, ebx
movzx edi, word [esi + edx*2]
lea edx, [esi + edx*2]
movsx ecx, di
neg eax
sar ecx, 1
cmp eax, ecx
jl 0x50f70a
push dword [ebp - 0x20]
mov edi, dword [ebp - 0x14]
mov ecx, esi
push dword [ebp + 0x10]
mov edx, edi
push dword [ebp + 0xc]
push dword [ebp + 8]
call fcn.0050f2c0
add esp, 0x10
cmp eax, 0xffffff88
jbe 0x50f713
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
lea eax, [edi + ebx]
mov edi, dword [ebp - 0x14]
mov word [edx], ax
mov eax, edi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
xor eax, eax
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
pop edi
pop esi
or eax, 0xffffffff
pop ebx
mov esp, ebp
pop ebp
ret