Function at 0x511624
Capabilities:
Encrypt data using rc4 prga

Disassembly:
push ebp
mov ebp, esp
mov edx, dword [ebp + 0xc]
sub esp, 0x50
push edi
mov edi, dword [ebp + 8]
test edi, edi
je 0x5118cf
test edx, edx
je 0x5118cf
mov eax, dword [edi]
xor ecx, ecx
inc ecx
cmp eax, ecx
jl 0x5118cf
cmp dword [edi + 4], ecx
jl 0x5118cf
push esi
mov esi, dword [edx]
cmp esi, ecx
jle 0x5118ce
mov eax, dword [edx + 4]
cmp eax, ecx
mov dword [ebp - 0x10], eax
jle 0x5118ce
test byte [ebp + 0x10], cl
je 0x51167f
dec esi
or dword [ebp - 0x24], 0xffffffff
mov dword [ebp - 0x1c], esi
jmp 0x511686
and dword [ebp - 0x1c], 0
mov dword [ebp - 0x24], ecx
test byte [ebp + 0x10], 2
mov ecx, dword [edx + 0x10]
je 0x511699
mov esi, ecx
dec eax
neg esi
mov dword [ebp - 0x14], esi
jmp 0x51169e
xor eax, eax
mov dword [ebp - 0x14], ecx
imul ecx, eax
add ecx, dword [ebp - 0x1c]
mov eax, dword [edx + 0x14]
lea eax, [eax + ecx*4]
mov dword [ebp - 0x20], eax
mov eax, dword [edx]
shl eax, 8
mov ecx, 0x100
sub eax, ecx
cdq
idiv dword [edi]
push ebx
mov ebx, dword [edi + 0x14]
mov dword [ebp - 8], ebx
mov ebx, dword [edi + 4]
mov esi, dword [edi + 0x10]
sub esi, dword [edi]
mov dword [ebp - 0x48], eax
mov eax, dword [ebp - 0x10]
shl eax, 8
sub eax, ecx
cdq
idiv ebx
mov dword [ebp - 0x4c], eax
xor eax, eax
cmp ebx, eax
mov dword [ebp - 0x1c], eax
jle 0x5118cb
mov edx, esi
shl edx, 2
mov dword [ebp - 0x50], edx
mov esi, dword [ebp - 0x20]
mov edx, eax
sar edx, 8
imul edx, dword [ebp - 0x14]
lea ebx, [esi + edx*4]
xor edx, edx
and dword [ebp - 0x18], edx
and eax, 0xff
cmp dword [edi], edx
mov dword [ebp - 0x10], eax
mov dword [ebp - 0x20], ebx
jle 0x5118b0
mov eax, dword [ebp - 0x24]
mov esi, edx
sar esi, 8
imul esi, eax
and edx, 0xff
lea ebx, [ebx + esi*4]
mov dword [ebp - 0xc], edx
mov edx, dword [ebp - 0x14]
lea esi, [ebx + edx*4]
lea edx, [ebx + eax*4]
lea eax, [esi + eax*4]
mov dword [ebp - 0x30], eax
mov al, byte [eax + 3]
or al, byte [edx + 3]
mov dword [ebp - 0x44], ebx
or al, byte [esi + 3]
mov dword [ebp - 0x34], esi
or al, byte [ebx + 3]
mov dword [ebp - 0x40], edx
jbe 0x511898
mov edi, dword [ebp - 0xc]
imul edi, dword [ebp - 0x10]
mov esi, ecx
sub esi, dword [ebp - 0x10]
mov eax, ecx
sub eax, dword [ebp - 0xc]
imul esi, dword [ebp - 0xc]
imul eax, dword [ebp - 0x10]
sar esi, 8
mov edx, 0x101
sar eax, 8
sub edx, esi
sar edi, 8
sub edx, eax
sub edx, edi
mov dword [ebp - 0x28], edi
mov dword [ebp - 0x2c], eax
mov dword [ebp - 0x38], esi
mov dword [ebp - 0x3c], edx
pxor mm0, mm0
mov esi, dword [ebp - 0x44]
mov edi, dword [ebp - 0x40]
movd mm1, dword [esi]
movd mm3, dword [edi]
punpcklbw mm1, mm0
punpcklbw mm3, mm0
movd mm2, dword [ebp - 0x3c]
movd mm4, dword [ebp - 0x38]
punpcklwd mm2, mm2
punpcklwd mm4, mm4
punpcklwd mm2, mm2
punpcklwd mm4, mm4
pmullw mm1, mm2
pmullw mm3, mm4
movq mm5, mm1
paddw mm5, mm3
mov esi, dword [ebp - 0x34]
mov edi, dword [ebp - 0x30]
movd mm1, dword [esi]
movd mm3, dword [edi]
punpcklbw mm1, mm0
punpcklbw mm3, mm0
movd mm2, dword [ebp - 0x2c]
movd mm4, dword [ebp - 0x28]
punpcklwd mm2, mm2
punpcklwd mm4, mm4
punpcklwd mm2, mm2
punpcklwd mm4, mm4
pmullw mm1, mm2
pmullw mm3, mm4
paddw mm5, mm1
paddw mm5, mm3
psrlw mm5, 8
packuswb mm5, mm0
movd dword [ebp - 4], mm5
cmp byte [ebp - 1], 0
lea eax, [ebp - 4]
mov dword [ebp - 0x3c], eax
mov eax, dword [ebp + 0x14]
mov edx, dword [eax + 8]
mov dword [ebp - 0x40], edx
je 0x511895
mov dword [ebp - 0x44], eax
mov eax, dword [0x5ab9e4]
inc dword [eax + 0x164]
pxor mm5, mm5
mov eax, dword [ebp - 0x3c]
movd mm4, dword [eax]
punpcklbw mm4, mm5
mov eax, dword [ebp - 8]
movd mm1, dword [eax]
punpcklbw mm1, mm5
movd mm2, dword [ebp - 0x40]
punpcklwd mm2, mm2
punpcklwd mm2, mm2
pmullw mm4, mm2
psrlw mm4, 8
movq mm0, mm4
punpckhwd mm0, mm0
punpckhwd mm0, mm0
movq mm3, mm0
pxor mm0, qword [0x5aa990]
pmullw mm1, mm0
paddw mm1, qword [0x5aa988]
movq mm0, mm1
psrlw mm0, 8
paddw mm0, mm1
psrlw mm0, 8
paddusb mm0, mm4
mov edx, dword [ebp - 0x44]
movq mm1, qword [edx]
psllw mm1, 4
psllw mm3, 4
pmulhw mm1, mm3
paddsw mm0, mm1
packuswb mm0, mm5
movd dword [eax], mm0
mov edi, dword [ebp + 8]
inc dword [ebp - 0x18]
mov edx, dword [ebp - 0xc]
mov eax, dword [ebp - 0x18]
add edx, dword [ebp - 0x48]
add dword [ebp - 8], 4
cmp eax, dword [edi]
jl 0x511718
mov edx, dword [ebp - 0x50]
inc dword [ebp - 0x1c]
add dword [ebp - 8], edx
mov eax, dword [ebp - 0x10]
mov edx, dword [ebp - 0x1c]
add eax, dword [ebp - 0x4c]
cmp edx, dword [edi + 4]
jl 0x5116f1
emms
pop ebx
pop esi
pop edi
leave
ret