Function at 0x509940
Capabilities:
Encrypt data using rc4 prga

Disassembly:
push ebp
push edi
push esi
push ebx
sub esp, 0x5c
mov edx, dword [0xbd70c4]
mov esi, dword [esp + 0x70]
mov edi, dword [esp + 0x74]
test edx, edx
je 0x5099d1
mov eax, dword [0xbe2440]
test eax, eax
je 0x509aa1
test edi, edi
je 0x5099d1
cmp edi, 1
movzx ecx, byte [esi]
jbe 0x5099d1
mov eax, dword [sym.imp.msvcrt.dll__iob]
mov ebp, 1
xor ebx, ebx
add eax, 0x40
mov dword [esp + 0x4c], eax
jmp 0x5099b5
jb 0x5099a4
cmp cl, 0xfe
jb 0x5099e0
mov ecx, dword [0xbd70c4]
xor ebp, 1
sub ecx, 1
mov dword [esp + 0x1c], ecx
sar ecx, 1
cmp ebp, ecx
je 0x509a00
cmp edi, ebx
jbe 0x5099d1
mov eax, edi
movzx ecx, byte [esi + ebx]
sub eax, ebx
cmp eax, 1
jbe 0x5099d1
movzx edx, byte [esi + ebx + 1]
movzx eax, byte [esi + ebx + 2]
add ebx, 3
cmp cl, 1
jne 0x509987
shr al, 7
cmp edi, ebx
movzx ebp, al
ja 0x5099a8
add esp, 0x5c
pop ebx
pop esi
pop edi
pop ebp
ret
mov eax, dword [esp + 0x4c]
movzx ecx, cl
mov dword [esp + 8], ecx
mov dword [esp + 4], str.Unknown_CC_encoding:__x_n
mov dword [esp], eax
call sub.msvcrt.dll_fprintf
jmp 0x5099a4
mov ecx, eax
movzx edx, dl
shl ecx, 8
or ecx, edx
mov eax, ecx
shr ax, 8
mov edx, eax
mov eax, ecx
and eax, 0x7f
and edx, 0x7f
test al, 0x60
mov word [esp + 0x30], cx
jne 0x509c2a
test al, 0x10
je 0x509a90
mov ecx, dword [esp + 0x1c]
and eax, 8
sar eax, 3
mov dword [0xbe2444], eax
and ecx, 1
cmp eax, ecx
jne 0x5099a4
movzx eax, word [esp + 0x30]
cmp ax, word [0xbe24e8]
je 0x509a90
movzx eax, dl
test al, 0x40
jne 0x509c6f
movzx ecx, byte [esp + 0x30]
and ecx, 0x77
cmp cl, 0x14
jne 0x509a90
cmp dl, 0x2c
je 0x509d1d
ja 0x509ca1
test dl, dl
lea esi, [esi]
jne 0x509c7e
mov dword [0x9137a0], 1
movzx ecx, word [esp + 0x30]
mov word [0xbe24e8], cx
jmp 0x5099a4
xor eax, eax
mov byte [eax + 0xbe2460], al
add eax, 1
cmp eax, 0x80
jne 0x509aa3
mov byte [0xbe248a], 0xe1
mov byte [0xbe24bc], 0xe9
mov byte [0xbe24be], 0xed
mov byte [0xbe24bf], 0xf3
mov byte [0xbe24c0], 0xfa
mov byte [0xbe24db], 0xe7
mov byte [0xbe24dc], 0xf7
mov byte [0xbe24dd], 0xd1
mov byte [0xbe24de], 0xf1
mov byte [0xbe24df], 0xa4
mov dword [0xbe250c], 0
mov dword [0xbe25cc], 0
mov dword [0xbe2510], 0
mov dword [0xbe25d0], 0
mov dword [0xbe2514], 0
mov dword [0xbe25d4], 0
mov dword [0xbe2518], 0
mov dword [0xbe25d8], 0
mov dword [0xbe251c], 0
mov dword [0xbe25dc], 0
mov dword [0xbe2520], 0
mov dword [0xbe25e0], 0
mov dword [0xbe2524], 0
mov dword [0xbe25e4], 0
mov dword [0xbe2528], 0
mov dword [0xbe25e8], 0
mov dword [0xbe252c], 0
mov dword [0xbe25ec], 0
mov dword [0xbe2530], 0
mov dword [0xbe25f0], 0
mov dword [0xbe2534], 0
mov dword [0xbe25f4], 0
mov dword [0xbe2538], 0
mov dword [0xbe25f8], 0
mov dword [0xbe2500], 0
mov dword [0xbe25c0], 0
mov dword [0xbe24e0], 0xbe25c0
mov dword [0xbe24e4], 0xbe2500
mov dword [0xbe2444], 0xffffffff
mov dword [0xbe2440], 1
jmp 0x509966
mov ecx, dword [esp + 0x1c]
and ecx, 1
cmp ecx, dword [0xbe2444]
jne 0x5099a4
movsx eax, byte [eax + 0xbe2460]
mov byte [esp + 0x28], dl
call fcn.00509620
movzx edx, byte [esp + 0x28]
movzx edx, dl
test dl, 0x60
je 0x509a90
movsx eax, byte [edx + 0xbe2460]
call fcn.00509620
jmp 0x509a90
mov eax, 0xa
call fcn.00509620
jmp 0x509a90
sub edx, 0x25
cmp dl, 2
ja 0x509a90
sub eax, 0x23
mov dword [0x9137a4], eax
mov dword [0x9137a0], 2
jmp 0x509a90
cmp dl, 0x2e
je 0x509d72
jb 0x509c6f
cmp dl, 0x2f
nop
jne 0x509a90
mov edx, dword [0xbe24e4]
mov eax, dword [0xbe24e0]
mov dword [esp], 2
mov dword [0xbe24e0], edx
mov dword [0xbe23f0], edx
mov dword [0xbe24e4], eax
call fcn.00509580
mov edx, dword [0xbe24e4]
xor eax, eax
mov dword [edx], 0
mov ecx, dword [edx + eax*4 + 0xc]
mov dword [esp + 0x2c], eax
mov dword [esp + 0x28], edx
mov dword [esp], ecx
call fcn.008f2ba8
mov eax, dword [esp + 0x2c]
mov edx, dword [esp + 0x28]
mov dword [edx + eax*4 + 0xc], 0
add eax, 1
cmp eax, 0xc
jne 0x509cec
jmp 0x509a90
mov dword [0xbe23f0], 0
mov dword [esp], 2
call fcn.00509580
mov edx, dword [0xbe24e0]
xor eax, eax
mov dword [edx], 0
mov ecx, dword [edx + eax*4 + 0xc]
mov dword [esp + 0x2c], eax
mov dword [esp + 0x28], edx
mov dword [esp], ecx
call fcn.008f2ba8
mov eax, dword [esp + 0x2c]
mov edx, dword [esp + 0x28]
mov dword [edx + eax*4 + 0xc], 0
add eax, 1
cmp eax, 0xc
jne 0x509d41
jmp 0x509a90
mov edx, dword [0xbe24e4]
xor eax, eax
mov dword [edx], 0
mov ecx, dword [edx + eax*4 + 0xc]
mov dword [esp + 0x2c], eax
mov dword [esp + 0x28], edx
mov dword [esp], ecx
call fcn.008f2ba8
mov eax, dword [esp + 0x2c]
mov edx, dword [esp + 0x28]
mov dword [edx + eax*4 + 0xc], 0
add eax, 1
cmp eax, 0xc
jne 0x509d80
jmp 0x509a90