Function at 0x538877
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
sub esp, 0x14
push ebx
mov ebx, dword [esp + 0x20]
push ebp
push esi
mov esi, edx
mov dword [esp + 0x14], ecx
mov eax, dword [ebx]
mov dword [esp + 0x10], esi
push edi
mov edi, ecx
test eax, eax
jne 0x5389ec
mov ecx, dword [ebx + 4]
cmp ecx, 8
jne 0x5388f6
xor ecx, ecx
test esi, esi
je 0x5388c1
mov edx, dword [esp + 0x28]
mov al, byte [ecx + edx]
inc ecx
mov byte [edi + 2], al
mov byte [edi + 1], al
mov byte [edi], al
mov byte [edi + 3], 0xff
add edi, 4
cmp ecx, esi
jne 0x5388aa
cmp dword [ebx + 0x10], 0
je 0x538c8e
mov eax, esi
neg eax
lea ecx, [edi + eax*4]
test esi, esi
je 0x538c8e
movzx eax, byte [ecx]
cmp eax, dword [ebx + 0x14]
jne 0x5388e6
mov byte [ecx + 3], 0
add ecx, 4
sub esi, 1
jne 0x5388da
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
xor edx, edx
cmp ecx, 0x10
jne 0x538947
test esi, esi
je 0x538c8e
mov ebp, dword [esp + 0x28]
inc edi
mov al, byte [ebp + edx*2]
mov byte [edi + 1], al
mov byte [edi], al
mov byte [edi - 1], al
cmp dword [ebx + 0x10], 0
je 0x538932
movzx ecx, byte [ebp + edx*2 + 1]
movzx eax, al
shl eax, 8
add ecx, eax
cmp ecx, dword [ebx + 0x14]
jne 0x538932
xor al, al
jmp 0x538934
or al, 0xff
mov byte [edi + 2], al
inc edx
add edi, 4
cmp edx, esi
jne 0x53890a
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
mov eax, 1
mov dword [esp + 0x1c], edx
shl eax, cl
dec eax
mov dword [esp + 0x20], eax
test esi, esi
je 0x538c8e
lea ecx, [edi + 1]
mov dword [esp + 0x18], ecx
nop
mov ebp, dword [ebx + 4]
xor edi, edi
test ebp, ebp
je 0x5389a8
mov esi, dword [esp + 0x28]
lea ecx, [ecx]
mov al, dl
mov cl, 7
and al, 7
add edi, edi
sub cl, al
mov eax, edx
shr eax, 3
inc edx
mov al, byte [eax + esi]
shr al, cl
and al, 1
movzx eax, al
or edi, eax
sub ebp, 1
jne 0x538977
mov esi, dword [esp + 0x14]
mov ebx, dword [esp + 0x2c]
mov ecx, dword [esp + 0x18]
mov dword [esp + 0x1c], edx
imul eax, edi, 0xff
xor edx, edx
div dword [esp + 0x20]
mov byte [ecx + 1], al
mov byte [ecx], al
mov byte [ecx - 1], al
cmp dword [ebx + 0x10], 0
je 0x5389cb
cmp edi, dword [ebx + 0x14]
jne 0x5389cb
xor al, al
jmp 0x5389cd
or al, 0xff
mov edx, dword [esp + 0x1c]
mov byte [ecx + 2], al
add ecx, 4
sub esi, 1
mov dword [esp + 0x18], ecx
mov dword [esp + 0x14], esi
jne 0x538967
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
cmp eax, 2
jne 0x538af8
cmp dword [ebx + 4], 8
jne 0x538a75
test esi, esi
je 0x538a28
mov ebp, dword [esp + 0x28]
mov ebx, esi
mov edi, edi
push 3
mov edx, ebp
mov ecx, edi
call fcn.0053d7bf
mov byte [edi + 3], 0xff
add esp, 4
add ebp, 3
add edi, 4
sub ebx, 1
jne 0x538a07
mov ebx, dword [esp + 0x2c]
cmp dword [ebx + 0x10], 0
je 0x538c8e
mov eax, esi
neg eax
lea ecx, [edi + eax*4]
test esi, esi
je 0x538c8e
lea ebx, [ebx]
movzx eax, byte [ecx]
cmp eax, dword [ebx + 0x14]
jne 0x538a65
movzx eax, byte [ecx + 1]
cmp eax, dword [ebx + 0x18]
jne 0x538a65
movzx eax, byte [ecx + 2]
cmp eax, dword [ebx + 0x1c]
jne 0x538a65
mov byte [ecx + 3], 0
add ecx, 4
sub esi, 1
jne 0x538a47
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
test esi, esi
je 0x538c8e
mov edx, dword [esp + 0x28]
add edi, 2
add edx, 4
mov cl, byte [edx - 2]
mov al, byte [edx - 4]
mov byte [edi - 1], cl
mov byte [esp + 0x2c], cl
mov cl, byte [edx]
mov byte [edi - 2], al
mov byte [edi], cl
cmp dword [ebx + 0x10], 0
mov byte [esp + 0x13], cl
je 0x538ae0
movzx ecx, al
movzx eax, byte [edx - 3]
shl ecx, 8
add ecx, eax
cmp ecx, dword [ebx + 0x14]
jne 0x538ae0
movzx ecx, byte [esp + 0x2c]
movzx eax, byte [edx - 1]
shl ecx, 8
add ecx, eax
cmp ecx, dword [ebx + 0x18]
jne 0x538ae0
movzx ecx, byte [esp + 0x13]
movzx eax, byte [edx + 1]
shl ecx, 8
add ecx, eax
cmp ecx, dword [ebx + 0x1c]
jne 0x538ae0
xor al, al
jmp 0x538ae2
or al, 0xff
mov byte [edi + 1], al
add edx, 6
add edi, 4
sub esi, 1
jne 0x538a87
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
cmp eax, 3
jne 0x538bc3
cmp dword [ebx + 4], 8
jne 0x538b41
xor ebp, ebp
test esi, esi
je 0x538c8e
lea ebx, [ebx]
mov eax, dword [esp + 0x28]
push 4
movzx ecx, byte [eax + ebp]
mov eax, dword [ebx + 8]
lea edx, [eax + ecx*4]
mov ecx, edi
call fcn.0053d7bf
inc ebp
add esp, 4
add edi, 4
cmp ebp, esi
jne 0x538b17
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
mov dword [esp + 0x1c], 0
test esi, esi
je 0x538c8e
lea ebx, [ebx]
mov ebp, dword [ebx + 4]
xor edx, edx
test ebp, ebp
je 0x538b99
mov ebx, dword [esp + 0x1c]
mov edi, dword [esp + 0x28]
mov al, bl
mov cl, 7
and al, 7
add edx, edx
sub cl, al
mov eax, ebx
shr eax, 3
inc ebx
mov al, byte [eax + edi]
shr al, cl
and al, 1
movzx eax, al
or edx, eax
sub ebp, 1
jne 0x538b68
mov esi, dword [esp + 0x14]
mov edi, dword [esp + 0x18]
mov dword [esp + 0x1c], ebx
mov ebx, dword [esp + 0x2c]
mov eax, dword [ebx + 8]
mov ecx, edi
push 4
lea edx, [eax + edx*4]
call fcn.0053d7bf
add edi, 4
add esp, 4
sub esi, 1
mov dword [esp + 0x18], edi
mov dword [esp + 0x14], esi
jne 0x538b57
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
cmp eax, 4
jne 0x538c32
xor ecx, ecx
cmp dword [ebx + 4], 8
jne 0x538c01
test esi, esi
je 0x538c8e
mov edx, dword [esp + 0x28]
inc edi
mov al, byte [edx + ecx*2]
lea edi, [edi + 4]
mov byte [edi - 3], al
mov byte [edi - 4], al
mov byte [edi - 5], al
movzx eax, byte [edx + ecx*2 + 1]
inc ecx
mov byte [edi - 2], al
cmp ecx, esi
jne 0x538bdd
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
test esi, esi
je 0x538c8e
mov edx, dword [esp + 0x28]
inc edi
mov al, byte [edx + ecx*4]
lea edi, [edi + 4]
mov byte [edi - 3], al
mov byte [edi - 4], al
mov byte [edi - 5], al
movzx eax, byte [edx + ecx*4 + 2]
inc ecx
mov byte [edi - 2], al
cmp ecx, esi
jne 0x538c0e
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
cmp eax, 6
jne 0x538c8e
cmp dword [ebx + 4], 8
jne 0x538c55
mov edx, dword [esp + 0x28]
shl esi, 2
push esi
call fcn.0053d7bf
add esp, 4
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret
test esi, esi
je 0x538c8e
mov ecx, dword [esp + 0x28]
add edi, 2
add ecx, 4
lea esp, [esp]
movzx eax, byte [ecx - 4]
lea ecx, [ecx + 8]
mov byte [edi - 2], al
lea edi, [edi + 4]
movzx eax, byte [ecx - 0xa]
mov byte [edi - 5], al
movzx eax, byte [ecx - 8]
mov byte [edi - 4], al
movzx eax, byte [ecx - 6]
mov byte [edi - 3], al
sub esi, 1
jne 0x538c67
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x14
ret