Function at 0x140040f20
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
push rbx
push r12
push r13
sub rsp, 0x10
mov r13, rcx
xor r12d, r12d
mov rcx, qword [rcx]
mov rbx, rdx
cmp dword [r13 + 0x14], r12d
jle 0x140041239
mov qword [rsp + 0x38], rbp
mov qword [rsp + 0x40], rsi
mov qword [rsp + 0x48], rdi
mov qword [rsp + 8], r14
mov qword [rsp], r15
nop dword [rax + rax]
movsxd rax, dword [r13 + 0x1c]
mov r14, rcx
mov r15d, dword [r14]
lea rcx, [rcx + rax*4]
dec r15d
mov qword [rsp + 0x30], rcx
test r15d, r15d
jle 0x140041214
mov edx, dword [r13 + 0xc]
add r14, 4
mov r11, qword [rbx + 8]
add edx, r12d
mov rdi, qword [rbx]
xor r8d, r8d
movsxd rax, edx
sub edx, dword [rbx + 0x18]
mov r9d, dword [r14]
movsxd rcx, dword [rdi + 0x14]
imul rcx, rax
mov eax, edx
add rcx, qword [rdi]
cdq
mov qword [rbx + 0x20], rcx
idiv dword [r11 + 0x20]
movsxd rax, dword [r11 + 0x14]
movsxd rcx, edx
imul rcx, rax
add rcx, qword [r11]
sub r15d, 1
mov qword [rbx + 0x28], rcx
js 0x14004118d
nop
mov esi, dword [r14 + 4]
lea r14, [r14 + 8]
mov ebp, dword [r14]
mov eax, ebp
cdq
movzx r11d, dl
add r11d, eax
mov eax, r9d
cdq
sar r11d, 8
movzx edx, dl
add eax, edx
sar eax, 8
mov ecx, eax
cmp r11d, eax
jne 0x14004100c
mov eax, ebp
sub eax, r9d
imul eax, esi
add r8d, eax
jmp 0x140041179
movzx eax, r9b
mov edx, 0x100
sub edx, eax
imul edx, esi
lea eax, [r8 + rdx]
cdq
movzx edx, dl
add eax, edx
sar eax, 8
mov edi, eax
test eax, eax
jle 0x14004109c
mov rax, qword [rbx]
mov r8, qword [rbx + 8]
mov r9d, dword [rbx + 0x14]
mov edx, dword [rax + 0x18]
mov eax, ecx
imul edx, ecx
sub eax, r9d
movsxd r10, edx
cdq
idiv dword [r8 + 0x1c]
mov rax, qword [rbx + 0x28]
imul edx, dword [r8 + 0x18]
add r10, qword [rbx + 0x20]
movsxd r8, edx
mov edx, 0x100
movzx r9d, byte [r8 + rax]
cmp edi, 0xff
jl 0x140041078
mov eax, dword [rbx + 0x10]
inc eax
imul r9d, eax
jmp 0x140041085
imul edi, dword [rbx + 0x10]
sar edi, 8
inc edi
imul r9d, edi
movzx eax, byte [r10]
shr r9d, 8
sub edx, r9d
imul edx, eax
sar edx, 8
add dl, r9b
mov byte [r10], dl
test esi, esi
jle 0x140041171
inc ecx
sub r11d, ecx
test r11d, r11d
jle 0x140041171
mov rax, qword [rbx]
movsxd rdx, dword [rax + 0x18]
mov eax, edx
imul eax, ecx
sub ecx, dword [rbx + 0x14]
movsxd r9, eax
mov eax, esi
imul eax, dword [rbx + 0x10]
add r9, qword [rbx + 0x20]
sar eax, 8
cmp eax, 0xfe
jge 0x14004112b
lea r10d, [rax + 1]
mov rdi, rdx
nop
mov r8, qword [rbx + 8]
mov eax, ecx
cdq
inc ecx
dec r11d
idiv dword [r8 + 0x1c]
mov rax, qword [rbx + 0x28]
imul edx, dword [r8 + 0x18]
movsxd rdx, edx
movzx r8d, byte [rdx + rax]
mov edx, 0x100
movzx eax, byte [r9]
imul r8d, r10d
shr r8d, 8
sub edx, r8d
imul edx, eax
sar edx, 8
add dl, r8b
mov byte [r9], dl
add r9, rdi
test r11d, r11d
jg 0x1400410e0
jmp 0x140041171
mov r10, rdx
nop
mov r8, qword [rbx + 8]
mov eax, ecx
cdq
inc ecx
dec r11d
idiv dword [r8 + 0x1c]
mov rax, qword [rbx + 0x28]
imul edx, dword [r8 + 0x18]
movsxd rdx, edx
movzx r8d, byte [rdx + rax]
mov edx, 0x100
movzx eax, byte [r9]
sub edx, r8d
imul edx, eax
sar edx, 8
add dl, r8b
mov byte [r9], dl
add r9, r10
test r11d, r11d
jg 0x140041130
movzx r8d, bpl
imul r8d, esi
sub r15d, 1
mov r9d, ebp
jns 0x140040fd0
mov rdi, qword [rbx]
mov r11, qword [rbx + 8]
mov eax, r8d
cdq
movzx edx, dl
add eax, edx
sar eax, 8
mov r10d, eax
test eax, eax
jle 0x14004120f
mov ecx, dword [rdi + 0x18]
mov eax, r9d
cdq
movzx edx, dl
add eax, edx
mov edx, dword [rbx + 0x14]
sar eax, 8
imul ecx, eax
sub eax, edx
cdq
idiv dword [r11 + 0x1c]
mov rax, qword [rbx + 0x28]
imul edx, dword [r11 + 0x18]
movsxd r8, ecx
add r8, qword [rbx + 0x20]
movsxd rcx, edx
movzx edx, byte [rcx + rax]
mov ecx, 0x100
cmp r10d, 0xff
jl 0x1400411eb
mov eax, dword [rbx + 0x10]
inc eax
imul edx, eax
jmp 0x1400411fb
imul r10d, dword [rbx + 0x10]
sar r10d, 8
inc r10d
imul edx, r10d
movzx eax, byte [r8]
shr edx, 8
sub ecx, edx
imul ecx, eax
sar ecx, 8
add cl, dl
mov byte [r8], cl
mov rcx, qword [rsp + 0x30]
inc r12d
cmp r12d, dword [r13 + 0x14]
jl 0x140040f60
mov r15, qword [rsp]
mov r14, qword [rsp + 8]
mov rdi, qword [rsp + 0x48]
mov rsi, qword [rsp + 0x40]
mov rbp, qword [rsp + 0x38]
add rsp, 0x10
pop r13
pop r12
pop rbx
ret