Function at 0x504820
Capabilities:
Encrypt data using rc4 prga

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x3c
push ebx
test edx, edx
mov dword [ebp - 0x18], ecx
mov ebx, 0xb
cmovne ebx, edx
mov dword [ebp - 0x24], ebx
push esi
push edi
cmp ebx, 5
jb 0x504a1c
cmp ebx, 0xc
jbe 0x504853
mov eax, 0xffffffd4
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov eax, dword [ebp + 0x10]
mov esi, dword [ebp + 0xc]
bsr eax, eax
bsr ecx, esi
add eax, 2
inc ecx
cmp ecx, eax
cmovb eax, ecx
cmp ebx, eax
jb 0x504a1c
xor eax, eax
mov edi, 0x3e
cmp dword [ebp + 0x14], eax
push 0
sete al
sub edi, ebx
push esi
push 0x40000000
push 0
lea eax, [eax*2 - 1]
mov dword [ebp - 0x1c], edi
movzx eax, ax
mov dword [ebp - 0x20], eax
call fcn.00546f60
xor ecx, ecx
mov dword [ebp - 0x28], edx
xor edx, edx
mov dword [ebp - 0x2c], eax
lea eax, [edi - 0x14]
mov dword [ebp - 0x14], 0
bts ecx, eax
mov dword [ebp - 4], 0
cmp eax, 0x20
mov edi, 1
cmovae edx, ecx
xor ecx, edx
cmp eax, 0x40
mov eax, dword [ebp - 0x18]
cmovae edx, ecx
mov dword [ebp - 0x34], ecx
mov ecx, ebx
mov dword [ebp - 0x30], edx
shl edi, cl
mov edx, esi
shr edx, cl
xor ebx, ebx
mov ecx, dword [ebp + 8]
mov dword [ebp - 0x10], edi
mov dword [ebp - 0x38], edx
nop dword [eax + eax]
mov ecx, dword [ecx + ebx*4]
cmp ecx, esi
je 0x504a13
test ecx, ecx
jne 0x504906
xor edx, edx
jmp 0x5049b0
cmp ecx, edx
ja 0x504916
mov ecx, dword [ebp - 0x20]
dec edi
movzx edx, cx
jmp 0x5049ad
mov eax, dword [ebp - 0x28]
mul ecx
mov esi, eax
mov eax, dword [ebp - 0x2c]
mul ecx
mov ecx, dword [ebp - 0x1c]
add esi, edx
mov dword [ebp - 0xc], eax
mov edx, esi
mov dword [ebp - 8], esi
call fcn.00519d00
movzx esi, ax
cmp si, 8
jge 0x504980
mov ecx, dword [ebp - 0x1c]
movsx edi, si
mov eax, edi
cdq
call fcn.00519d20
sub dword [ebp - 0xc], eax
mov ecx, dword [edi*4 + 0x5954e0]
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 0x504979
ja 0x504972
cmp dword [ebp - 0xc], eax
jbe 0x504979
mov eax, 1
jmp 0x50497b
xor eax, eax
mov edi, dword [ebp - 0x10]
add esi, eax
movsx eax, si
sub edi, eax
movzx ecx, si
cmp si, word [ebp - 4]
mov eax, ebx
movzx edx, si
cmovle eax, dword [ebp - 0x14]
mov esi, dword [ebp + 0xc]
mov dword [ebp - 0x14], eax
mov eax, dword [ebp - 4]
movzx eax, ax
cmovle ecx, eax
movzx eax, cx
mov dword [ebp - 4], eax
mov eax, dword [ebp - 0x18]
mov dword [ebp - 0x10], edi
mov ecx, dword [ebp + 8]
mov word [eax + ebx*2], dx
inc ebx
mov edx, dword [ebp - 0x38]
cmp ebx, dword [ebp + 0x10]
jbe 0x5048f0
mov ecx, dword [ebp - 0x14]
movzx ebx, word [eax + ecx*2]
lea edx, [eax + ecx*2]
movsx ecx, bx
mov eax, edi
sar ecx, 1
neg eax
cmp eax, ecx
jl 0x504a01
push dword [ebp - 0x20]
mov ecx, dword [ebp - 0x18]
push dword [ebp + 0x10]
push esi
push dword [ebp + 8]
mov esi, dword [ebp - 0x24]
mov edx, esi
call fcn.005045c0
add esp, 0x10
cmp eax, 0xffffff88
jbe 0x504a0a
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov esi, dword [ebp - 0x24]
lea ecx, [ebx + edi]
mov word [edx], cx
mov eax, esi
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