Function at 0x505340
Capabilities:
Encrypt data using rc4 prga

Disassembly:
sub esp, 0x28
cmp dword [esp + 0x38], 0
push ebx
push ebp
push esi
push edi
mov edi, dword [esp + 0x44]
je 0x505614
mov ebp, dword [esp + 0x3c]
mov eax, dword [esp + 0x40]
movzx ecx, byte [edi + eax - 1]
movzx edx, byte [edi + ebp - 1]
dec dword [esp + 0x48]
lea esi, [edi - 1]
mov eax, edx
imul eax, ecx
sub eax, 0xffffff80
mov ebx, eax
sar ebx, 8
add ebx, eax
sar ebx, 8
mov dword [esp + 0x30], ecx
mov dword [esp + 0x10], edx
mov dword [esp + 0x14], ebx
test ecx, ecx
je 0x5053a3
mov eax, 0xff00
cdq
idiv ecx
mov edx, dword [esp + 0x10]
mov dword [esp + 0x18], eax
jmp 0x5053ab
mov dword [esp + 0x18], 0
test edx, edx
je 0x5053c7
mov eax, 0xff00
cdq
idiv dword [esp + 0x10]
mov ebx, dword [esp + 0x14]
mov edx, dword [esp + 0x10]
mov dword [esp + 0x1c], eax
jmp 0x5053cf
mov dword [esp + 0x1c], 0
xor eax, eax
test esi, esi
jle 0x5055f8
mov eax, 0xff
sub eax, ecx
mov dword [esp + 0x28], eax
mov eax, 0xff
sub eax, edx
mov dword [esp + 0x2c], eax
mov eax, dword [esp + 0x40]
sub eax, ebp
mov dword [esp + 0x24], eax
mov dword [esp + 0x20], esi
mov dword [esp + 0x34], esi
jmp 0x505407
mov eax, dword [esp + 0x24]
movzx ebx, byte [eax + ebp]
movzx esi, byte [ebp]
mov edx, dword [esp + 0x4c]
mov ecx, ebx
imul ecx, dword [esp + 0x18]
mov eax, esi
imul eax, dword [esp + 0x1c]
dec edx
sar ecx, 8
sar eax, 8
cmp edx, 0xa
ja case.default.0x505431
jmp dword [edx*4 + 0x50561c]
imul eax, ecx
sub eax, 0xffffff80
mov ecx, eax
sar ecx, 8
add ecx, eax
sar ecx, 8
jmp case.default.0x505431
mov edx, eax
imul edx, ecx
sub edx, 0xffffff80
mov edi, edx
sar edi, 8
add edi, edx
sar edi, 8
jmp 0x505590
lea edx, [eax + eax]
cmp eax, 0x7f
jg 0x505481
imul edx, ecx
sub edx, 0xffffff80
mov ecx, edx
sar ecx, 8
add ecx, edx
sar ecx, 8
jmp case.default.0x505431
add edx, 0xffffff01
mov eax, edx
imul eax, ecx
sub eax, 0xffffff80
mov edi, eax
sar edi, 8
add edi, eax
sar edi, 8
sub edx, edi
add ecx, edx
jmp case.default.0x505431
cmp eax, ecx
jge case.default.0x505431
mov ecx, eax
jmp case.default.0x505431
cmp eax, ecx
jle case.default.0x505431
mov ecx, eax
jmp case.default.0x505431
mov edx, 0xff
sub edx, ecx
test eax, eax
jne 0x5054d2
xor ecx, ecx
jmp case.default.0x505431
cmp eax, edx
jl 0x5054e0
mov ecx, 0xff
jmp case.default.0x505431
imul eax, eax, 0x1fe
add eax, edx
lea ecx, [edx + edx]
cdq
idiv ecx
mov ecx, eax
jmp case.default.0x505431
mov edx, 0xff
sub edx, eax
jne 0x505508
mov ecx, 0xff
jmp case.default.0x505431
cmp edx, ecx
jl 0x505513
xor ecx, ecx
jmp case.default.0x505431
mov eax, edx
imul eax, eax, 0x1fe
add eax, ecx
add ecx, ecx
cdq
idiv ecx
mov ecx, 0xff
sub ecx, eax
jmp case.default.0x505431
lea edx, [ecx + ecx]
cmp ecx, 0x7f
jg 0x505545
imul edx, eax
sub edx, 0xffffff80
mov ecx, edx
sar ecx, 8
add ecx, edx
sar ecx, 8
jmp case.default.0x505431
lea ecx, [edx - 0xff]
mov edx, ecx
imul edx, eax
sub edx, 0xffffff80
mov edi, edx
sar edi, 8
add edi, edx
sar edi, 8
sub ecx, edi
jmp 0x505592
push eax
mov edi, ecx
call fcn.00504c10
add esp, 4
mov ecx, eax
jmp case.default.0x505431
sub eax, ecx
cdq
mov ecx, eax
xor ecx, edx
sub ecx, edx
jmp case.default.0x505431
mov edx, eax
imul edx, ecx
sub edx, 0xffffff80
mov edi, edx
sar edi, 8
add edi, edx
sar edi, 7
and edi, 0xfffffffe
sub eax, edi
add ecx, eax
imul ecx, dword [esp + 0x14]
mov eax, dword [esp + 0x28]
imul eax, esi
mov esi, dword [esp + 0x2c]
sub ecx, 0xffffff80
imul esi, ebx
mov edx, ecx
sar edx, 8
add edx, ecx
sub esi, 0xffffff80
mov ecx, esi
sar ecx, 8
add ecx, esi
sar ecx, 8
sar edx, 8
add dl, cl
sub eax, 0xffffff80
mov ecx, eax
sar ecx, 8
add ecx, eax
sar ecx, 8
add dl, cl
mov byte [ebp], dl
inc ebp
dec dword [esp + 0x20]
jne 0x505403
mov ecx, dword [esp + 0x30]
mov ebx, dword [esp + 0x14]
mov eax, dword [esp + 0x34]
mov edx, dword [esp + 0x10]
mov ebp, dword [esp + 0x3c]
mov edi, dword [esp + 0x44]
add dword [esp + 0x40], edi
sub cl, bl
add cl, dl
mov byte [eax + ebp], cl
add ebp, edi
cmp dword [esp + 0x48], 0
mov dword [esp + 0x3c], ebp
jne 0x505356
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x28
ret