Function at 0x539650
Capabilities:
Encrypt data using rc4 prga

Disassembly:
sub esp, 0x20
mov ecx, dword [esp + 0x30]
xor eax, eax
cmp dword [esp + 0x34], 4
push ebp
mov ebp, ecx
mov dword [esp + 4], eax
mov dword [esp + 0x18], eax
jb 0x5398f7
mov edx, dword [ecx]
push edi
mov edi, edx
and edi, 0xf
add edi, 5
cmp edi, 0xf
jbe 0x53968a
pop edi
mov eax, 0xffffffd4
pop ebp
add esp, 0x20
ret
mov eax, dword [esp + 0x34]
mov ecx, edi
push ebx
push esi
mov esi, 1
shr edx, 4
shl esi, cl
mov ebx, 4
mov dword [eax], edi
inc edi
mov dword [esp + 0x14], esi
mov dword [esp + 0x1c], edi
lea eax, [esi + 1]
mov dword [esp + 0x18], eax
cmp eax, 1
jle 0x5398ca
nop dword [eax]
mov esi, dword [esp + 0x38]
mov ecx, dword [esp + 0x10]
cmp ecx, dword [esi]
mov esi, dword [esp + 0x14]
ja 0x5398ad
cmp dword [esp + 0x24], 0
je 0x5397b1
mov edi, ecx
cmp dx, 0xffff
jne 0x53971b
mov esi, dword [esp + 0x44]
add esi, 0xfffffffb
add esi, dword [esp + 0x40]
add edi, 0x18
cmp ebp, esi
jae 0x539706
mov edx, dword [ebp + 2]
add ebp, 2
mov ecx, ebx
shr edx, cl
jmp 0x53970c
shr edx, 0x10
add ebx, 0x10
cmp dx, 0xffff
je 0x5396f3
mov esi, dword [esp + 0x14]
mov ecx, dword [esp + 0x10]
mov eax, edx
and eax, 3
cmp al, 3
jne 0x539736
shr edx, 2
add edi, 3
mov eax, edx
add ebx, 2
and eax, 3
cmp al, 3
je 0x539724
mov eax, edx
add ebx, 2
and eax, 3
add edi, eax
mov eax, dword [esp + 0x38]
cmp edi, dword [eax]
ja 0x5398bd
cmp ecx, edi
jae 0x539772
mov esi, ecx
xor eax, eax
mov ecx, edi
sub ecx, dword [esp + 0x10]
mov dword [esp + 0x10], edi
mov edi, dword [esp + 0x34]
shr ecx, 1
lea edi, [edi + esi*2]
mov esi, dword [esp + 0x14]
rep stosd dword es:[edi], eax
adc ecx, ecx
rep stosw word es:[edi], ax
mov eax, dword [esp + 0x44]
mov edi, dword [esp + 0x40]
add eax, 0xfffffff9
add eax, edi
cmp ebp, eax
jbe 0x53979c
mov eax, dword [esp + 0x44]
mov ecx, ebx
sar ecx, 3
add eax, 0xfffffffc
add ecx, ebp
add eax, edi
cmp ecx, eax
jbe 0x53979c
shr edx, 2
jmp 0x5397ad
mov eax, ebx
and ebx, 7
sar eax, 3
mov ecx, ebx
add ebp, eax
mov edx, dword [ebp]
shr edx, cl
mov edi, dword [esp + 0x1c]
movzx eax, si
lea ecx, [esi - 1]
mov dword [esp + 0x28], eax
and ecx, edx
add eax, eax
add ebx, edi
mov dword [esp + 0x2c], eax
sub eax, dword [esp + 0x18]
dec eax
movzx eax, ax
mov dword [esp + 0x24], eax
movzx eax, dx
mov dword [esp + 0x20], eax
mov eax, dword [esp + 0x24]
cwde
cmp ecx, eax
jae 0x5397f0
mov eax, dword [esp + 0x28]
dec eax
and eax, dword [esp + 0x20]
dec ebx
movzx ecx, ax
jmp 0x539813
mov esi, dword [esp + 0x2c]
dec esi
and esi, dword [esp + 0x20]
movzx eax, si
movsx edx, ax
sub eax, dword [esp + 0x24]
cmp edx, dword [esp + 0x14]
movzx ecx, ax
movzx eax, si
cmovl ecx, eax
movzx ecx, cx
mov esi, dword [esp + 0x34]
dec ecx
movsx eax, cx
cdq
xor eax, edx
sub eax, edx
mov edx, dword [esp + 0x18]
cwde
sub edx, eax
mov eax, dword [esp + 0x10]
mov dword [esp + 0x18], edx
mov word [esi + eax*2], cx
inc eax
mov esi, dword [esp + 0x14]
mov dword [esp + 0x10], eax
xor eax, eax
test cx, cx
sete al
mov dword [esp + 0x24], eax
cmp edx, esi
jge 0x53985f
nop dword [eax]
sar esi, 1
dec edi
cmp edx, esi
jl 0x539850
mov dword [esp + 0x1c], edi
mov dword [esp + 0x14], esi
mov edx, dword [esp + 0x40]
add edx, dword [esp + 0x44]
lea eax, [edx - 7]
cmp ebp, eax
jbe 0x539888
mov eax, ebx
lea ecx, [edx - 4]
sar eax, 3
add eax, ebp
cmp eax, ecx
jbe 0x539888
sub ebp, edx
lea ebx, [ebx + ebp*8]
mov ebp, ecx
add ebx, 0x20
jmp 0x539892
mov eax, ebx
sar eax, 3
add ebp, eax
and ebx, 7
mov edx, dword [ebp]
mov ecx, ebx
mov eax, dword [esp + 0x18]
and ecx, 0x1f
shr edx, cl
cmp eax, 1
jg 0x5396c0
mov ecx, dword [esp + 0x10]
cmp eax, 1
je 0x5398ce
pop esi
pop ebx
pop edi
or eax, 0xffffffff
pop ebp
add esp, 0x20
ret
pop esi
pop ebx
pop edi
mov eax, 0xffffffd0
pop ebp
add esp, 0x20
ret
xor ecx, ecx
jmp 0x5398ad
lea eax, [ecx - 1]
mov ecx, dword [esp + 0x38]
pop esi
mov dword [ecx], eax
lea eax, [ebx + 7]
sar eax, 3
mov ecx, 0xffffffb8
sub eax, dword [esp + 0x3c]
add eax, ebp
cmp eax, dword [esp + 0x40]
pop ebx
pop edi
cmova eax, ecx
pop ebp
add esp, 0x20
ret
mov eax, 0xffffffb8
pop ebp
add esp, 0x20
ret