Function at 0x40d070
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
sub esp, 0x10
lea eax, [esp + 8]
push ebx
mov ebx, ecx
push eax
call fcn.0040cdd0
test eax, eax
jne 0x40d08b
pop ebx
add esp, 0x10
ret 4
mov ecx, dword [esp + 0x18]
push ebp
push esi
mov esi, dword [esp + 0x18]
lea eax, [ecx - 1]
push edi
cmp eax, 0xa
ja case.0x40d0aa.6
xor edx, edx
mov dl, byte [eax + 0x40d374]
jmp dword [edx*4 + 0x40d35c]
mov eax, dword [ebx + 0xc]
mov dword [esp + 0x10], 0
test eax, eax
jbe 0x40d195
mov eax, dword [ebx + 8]
mov dword [esp + 0x24], 0
test eax, eax
jbe 0x40d176
xor eax, eax
xor ecx, ecx
mov al, byte [esi + 3]
mov cl, byte [esi + 2]
xor edx, edx
mov dword [esp + 0x14], eax
mov dl, byte [esi + 1]
xor eax, eax
mov al, byte [esi]
add ecx, edx
add ecx, eax
mov eax, 0xaaaaaaab
mul ecx
mov ebp, edx
shr ebp, 1
call fcn.004b09b7
cdq
mov ecx, 0x14
idiv ecx
lea edi, [edx + ebp + 0x1e]
test edi, 0xffffff00
je 0x40d11b
mov edi, 0xff
call fcn.004b09b7
cdq
mov ecx, 0x14
idiv ecx
lea eax, [edx + ebp + 0x14]
test eax, 0xffffff00
je 0x40d138
mov eax, 0xff
mov ecx, dword [esp + 0x14]
and edi, 0xff
shl ecx, 8
or edi, ecx
and eax, 0xff
shl edi, 8
or edi, eax
mov eax, dword [esp + 0x24]
shl edi, 8
and ebp, 0xff
add esi, 4
or edi, ebp
inc eax
mov dword [esi - 4], edi
mov ecx, dword [ebx + 8]
cmp eax, ecx
mov dword [esp + 0x24], eax
jb 0x40d0d7
mov edx, dword [ebx + 0x10]
mov edi, dword [ebx + 8]
mov eax, dword [esp + 0x10]
mov ecx, dword [ebx + 0xc]
sub edx, edi
inc eax
cmp eax, ecx
mov dword [esp + 0x10], eax
lea esi, [esi + edx*4]
jb 0x40d0c4
mov dword [ebx + 0x1c], 1
jmp case.0x40d0aa.6
mov eax, dword [ebx + 0xc]
xor ebp, ebp
test eax, eax
jbe 0x40d208
mov eax, dword [ebx + 8]
xor edi, edi
test eax, eax
jbe 0x40d1f5
xor eax, eax
xor edx, edx
mov al, byte [esi + 2]
mov dl, byte [esi + 1]
mov ecx, eax
xor eax, eax
mov al, byte [esi]
add ecx, edx
add ecx, eax
mov eax, 0xaaaaaaab
mul ecx
shr edx, 1
xor ecx, ecx
and edx, 0xff
mov ch, byte [esi + 3]
add esi, 4
or ecx, edx
shl ecx, 8
or ecx, edx
shl ecx, 8
or ecx, edx
inc edi
mov dword [esi - 4], ecx
mov eax, dword [ebx + 8]
cmp edi, eax
jb 0x40d1b3
mov edx, dword [ebx + 0x10]
mov edi, dword [ebx + 8]
mov eax, dword [ebx + 0xc]
sub edx, edi
inc ebp
cmp ebp, eax
lea esi, [esi + edx*4]
jb 0x40d1aa
mov dword [ebx + 0x1c], 2
jmp case.0x40d0aa.6
mov eax, dword [ebx + 0xc]
xor edi, edi
test eax, eax
jbe 0x40d285
mov ecx, dword [ebx + 8]
xor eax, eax
test ecx, ecx
jbe 0x40d272
xor ecx, ecx
xor edx, edx
mov cl, byte [esi + 2]
mov dl, byte [esi + 1]
inc ecx
or ebp, 0xffffffff
neg ecx
shl ecx, 0x10
and ecx, 0xff0000
inc edx
neg edx
shl edx, 8
and edx, 0xff00
add esi, 4
or ecx, edx
mov dl, byte [esi - 4]
sub ebp, edx
xor edx, edx
mov dl, byte [esi - 1]
and ebp, 0xff
or ecx, ebp
shl edx, 0x18
or ecx, edx
inc eax
mov dword [esi - 4], ecx
mov ecx, dword [ebx + 8]
cmp eax, ecx
jb 0x40d226
mov eax, dword [ebx + 0x10]
mov edx, dword [ebx + 8]
sub eax, edx
inc edi
lea esi, [esi + eax*4]
mov eax, dword [ebx + 0xc]
cmp edi, eax
jb 0x40d21d
mov dword [ebx + 0x1c], 3
jmp case.0x40d0aa.6
mov eax, dword [ebx + 0xc]
xor ebp, ebp
test eax, eax
jbe 0x40d2d9
mov eax, dword [ebx + 8]
xor edi, edi
test eax, eax
jbe 0x40d2c2
xor ecx, ecx
xor edx, edx
mov ch, byte [esi + 2]
mov dl, byte [esi]
mov cl, byte [esi + 1]
add esi, 4
shl ecx, 8
or ecx, edx
inc edi
mov dword [esi - 4], ecx
mov eax, dword [ebx + 8]
cmp edi, eax
jb 0x40d2a3
mov eax, dword [ebx + 0x10]
mov edx, dword [ebx + 8]
shl eax, 1
sub eax, edx
add ebp, 2
lea esi, [esi + eax*4]
mov eax, dword [ebx + 0xc]
cmp ebp, eax
jb 0x40d29a
mov dword [ebx + 0x1c], 0xa
jmp case.0x40d0aa.6
mov eax, dword [ebx + 0xc]
xor edi, edi
test eax, eax
jbe 0x40d33f
mov ecx, dword [ebx + 8]
xor eax, eax
test ecx, ecx
jbe 0x40d328
xor ecx, ecx
xor edx, edx
mov cl, byte [esi + 3]
mov dl, byte [esi + 2]
and ecx, 0xfffffffe
add esi, 4
shl ecx, 7
or ecx, edx
xor edx, edx
mov dl, byte [esi - 3]
shl ecx, 8
or ecx, edx
xor edx, edx
mov dl, byte [esi - 4]
shl ecx, 8
or ecx, edx
inc eax
mov dword [esi - 4], ecx
mov ecx, dword [ebx + 8]
cmp eax, ecx
jb 0x40d2f4
mov eax, dword [ebx + 0x10]
mov edx, dword [ebx + 8]
shl eax, 1
sub eax, edx
add edi, 2
lea esi, [esi + eax*4]
mov eax, dword [ebx + 0xc]
cmp edi, eax
jb 0x40d2eb
mov dword [ebx + 0x1c], 0xb
mov ecx, ebx
call fcn.0040ce20
pop edi
pop esi
pop ebp
mov eax, 1
pop ebx
add esp, 0x10
ret 4