Function at 0x140040770
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
push rdi
push r15
sub rsp, 0x188
mov rax, qword [0x140163f80]
xor rax, rsp
mov qword [rsp + 0x150], rax
mov rax, qword [rcx]
xor r15d, r15d
mov qword [rsp + 0x88], r8
mov rdi, rcx
mov qword [rsp + 0x80], rdx
mov qword [rsp + 0x70], rcx
mov dword [rax + 8], r15d
call fcn.14003fa80
mov rdx, qword [rdi]
movsxd rcx, dword [rdx + 8]
test eax, eax
jne 0x1400407d3
mov edx, ecx
xor r8d, r8d
mov rcx, rdi
call fcn.14003f0d0
xor eax, eax
jmp 0x140040db8
mov qword [rsp + 0x160], r14
cmp ecx, 3
jne 0x140040805
cmp dword [rdi + 0x4850], ecx
je 0x1400407fa
cmp dword [rdi + 0x484c], r15d
jne 0x140040805
cmp dword [rdi + 0x4848], r15d
jne 0x140040805
mov qword [rsp + 0x48], 1
jmp 0x14004080a
mov qword [rsp + 0x48], r15
mov qword [rsp + 0x1b8], rbx
xorps xmm0, xmm0
mov qword [rsp + 0x180], rbp
xorps xmm1, xmm1
mov qword [rsp + 0x178], rsi
mov r14, rcx
mov qword [rsp + 0x40], rcx
movdqu xmmword [rsp + 0x50], xmm0
movdqu xmmword [rsp + 0x60], xmm1
test ecx, ecx
jle 0x140040928
mov rbp, r15
lea rbx, [rsp + 0xac]
lea rsi, [rdi + 0x46a4]
nop word [rax + rax]
mov rax, qword [rdi]
mov ecx, dword [rax]
add ecx, 3
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov qword [rsi + 0x44], rax
test rax, rax
je 0x14004094d
mov eax, dword [rdi + 0x4688]
cdq
mov dword [rbx + 0xc], r15d
idiv dword [rsi]
mov r9d, eax
mov dword [rbx - 4], eax
mov eax, dword [rdi + 0x468c]
cdq
idiv dword [rsi + 4]
xor edx, edx
mov ecx, eax
mov dword [rbx], eax
sar ecx, 1
mov r8d, eax
mov dword [rbx + 8], ecx
mov rcx, qword [rdi]
mov eax, dword [rcx]
mov rcx, qword [rsi + 0x2c]
dec eax
add eax, r9d
mov qword [rbx - 0xc], rcx
div r9d
mov qword [rbx - 0x14], rcx
mov dword [rbx + 4], eax
cmp r9d, 1
jne 0x1400408e5
cmp r8d, r9d
jne 0x1400408d6
lea rax, [0x14003fd60]
jmp 0x140040910
cmp r8d, 2
jne 0x140040909
lea rax, [0x14003fd70]
jmp 0x140040910
cmp r9d, 2
jne 0x140040909
cmp r8d, 1
jne 0x1400408fa
lea rax, [0x14003ff40]
jmp 0x140040910
cmp r8d, 2
jne 0x140040909
mov rax, qword [rdi + 0x4880]
jmp 0x140040910
lea rax, [0x1400402f0]
mov qword [rbx - 0x1c], rax
inc rbp
add rbx, 0x30
add rsi, 0x60
cmp rbp, r14
jl 0x140040860
mov rax, qword [rdi]
mov qword [rsp + 0x170], r12
mov ecx, dword [rax]
mov r8d, dword [rax + 4]
test ecx, ecx
js 0x140040d61
jne 0x140040981
lea r9d, [rcx*4]
jmp 0x1400409a3
mov rdx, qword [rdi]
xor r8d, r8d
mov rcx, rdi
mov edx, dword [rdx + 8]
call fcn.14003f0d0
mov rax, qword gs:[0x58]
mov edx, Ordinal_27
mov rcx, qword [rax]
lea rax, str.outofmem
mov qword [rdx + rcx], rax
xor eax, eax
jmp 0x140040d98
mov eax, 0x7fffffff
cdq
idiv ecx
cmp eax, 4
jl 0x140040d61
lea r9d, [rcx*4]
test r9d, r9d
js 0x140040d61
test r8d, r8d
js 0x140040d61
je 0x1400409c0
mov eax, 0x7fffffff
cdq
idiv r8d
cmp r9d, eax
jg 0x140040d61
imul r8d, ecx
lea eax, [r8*4 + 1]
movsxd rcx, eax
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov rdx, qword [rdi]
mov r12, rax
test rax, rax
je 0x140040d64
xor eax, eax
mov dword [rsp + 0x30], eax
cmp dword [rdx + 4], eax
jbe 0x140040d2f
mov r14, qword [rsp + 0x60]
mov r15, qword [rsp + 0x58]
mov rbx, qword [rsp + 0x50]
mov qword [rsp + 0x168], r13
mov r13, qword [rsp + 0x68]
mov qword [rsp + 0x38], r12
nop dword [rax]
nop dword [rax + rax]
imul eax, dword [rdx]
xor ebp, ebp
shl eax, 2
mov esi, eax
add rsi, r12
mov qword [rsp + 0x78], rsi
cmp qword [rsp + 0x40], rbp
jle 0x140040b08
lea rsi, [rdi + 0x46c0]
mov rdi, qword [rsp + 0x38]
lea rbx, [rsp + 0xb4]
nop dword [rax]
nop word [rax + rax]
mov r13d, dword [rbx - 8]
lea r14, [rbx - 0x14]
mov r9d, dword [rbx - 0xc]
lea r15, [rbx - 0x1c]
mov eax, r13d
mov r12, r14
sar eax, 1
cmp dword [rbx], eax
jl 0x140040a84
mov r8, qword [r15]
mov rdx, r14
jmp 0x140040a8a
mov r8, qword [r14]
mov rdx, r15
mov rdx, qword [rdx]
mov rcx, qword [rsi + 0x28]
mov dword [rsp + 0x20], r9d
mov r9d, dword [rbx - 4]
call qword [rbx - 0x24]
mov qword [rsp + rbp*8 + 0x50], rax
mov eax, dword [rbx]
inc eax
mov dword [rbx], eax
cmp eax, r13d
jl 0x140040ace
inc dword [rbx + 4]
mov eax, dword [rbx + 4]
mov rcx, qword [r12]
mov dword [rbx], 0
mov qword [r15], rcx
cmp eax, dword [rsi]
jge 0x140040ace
movsxd rax, dword [rsi + 4]
add rax, rcx
mov qword [r14], rax
inc rbp
add rbx, 0x30
add rsi, 0x60
cmp rbp, qword [rsp + 0x40]
jl 0x140040a60
mov r13, qword [rsp + 0x68]
mov r14, qword [rsp + 0x60]
mov r15, qword [rsp + 0x58]
mov rbx, qword [rsp + 0x50]
mov rsi, qword [rsp + 0x78]
mov qword [rsp + 0x38], rdi
mov r12, qword [rsp + 0x38]
mov rdi, qword [rsp + 0x70]
mov rax, qword [rdi]
mov rdx, rax
mov ecx, dword [rax + 8]
cmp ecx, 3
jne 0x140040b8c
cmp qword [rsp + 0x48], 0
je 0x140040b64
xor r9d, r9d
cmp dword [rax], r9d
jbe 0x140040d14
lea r8, [rsi + 2]
nop
movzx eax, byte [r9 + rbx]
mov byte [r8 - 2], al
lea r8, [r8 + 4]
movzx eax, byte [r9 + r15]
mov byte [r8 - 5], al
movzx eax, byte [r9 + r14]
inc r9d
mov byte [r8 - 4], al
mov byte [r8 - 3], 0xff
mov rdx, qword [rdi]
cmp r9d, dword [rdx]
jb 0x140040b30
jmp 0x140040d14
mov eax, dword [rax]
mov r9, r14
mov dword [rsp + 0x28], 4
mov r8, r15
mov rdx, rbx
mov dword [rsp + 0x20], eax
mov rcx, rsi
call qword [rdi + 0x4878]
mov rdx, qword [rdi]
jmp 0x140040d14
cmp ecx, 4
jne 0x140040cd8
mov ecx, dword [rdi + 0x484c]
test ecx, ecx
jne 0x140040c1c
xor r10d, r10d
cmp dword [rax], r10d
jbe 0x140040d14
lea r9, [rsi + 2]
nop
movzx r8d, byte [r10 + r13]
lea r9, [r9 + 4]
movzx ecx, byte [r10 + rbx]
imul ecx, r8d
sub ecx, 0xffffff80
mov eax, ecx
shr eax, 8
add eax, ecx
shr eax, 8
mov byte [r9 - 6], al
movzx ecx, byte [r10 + r15]
imul ecx, r8d
sub ecx, 0xffffff80
mov eax, ecx
shr eax, 8
add eax, ecx
shr eax, 8
mov byte [r9 - 5], al
movzx ecx, byte [r10 + r14]
inc r10d
mov byte [r9 - 3], 0xff
imul ecx, r8d
sub ecx, 0xffffff80
mov eax, ecx
shr eax, 8
add eax, ecx
shr eax, 8
mov byte [r9 - 4], al
mov rdx, qword [rdi]
cmp r10d, dword [rdx]
jb 0x140040bb0
jmp 0x140040d14
mov eax, dword [rax]
cmp ecx, 2
mov r10, qword [rdi + 0x4878]
mov rcx, rsi
mov dword [rsp + 0x28], 4
mov r9, r14
mov dword [rsp + 0x20], eax
mov r8, r15
mov rdx, rbx
jne 0x140040cd0
call r10
mov rdx, qword [rdi]
xor r9d, r9d
cmp dword [rdx], r9d
jbe 0x140040d14
lea r8, [rsi + 2]
nop dword [rax]
movzx edx, byte [r9 + r13]
inc r9d
movzx eax, byte [r8 - 2]
lea r8, [r8 + 4]
not al
movzx ecx, al
imul ecx, edx
sub ecx, 0xffffff80
mov eax, ecx
shr eax, 8
add eax, ecx
shr eax, 8
mov byte [r8 - 6], al
movzx eax, byte [r8 - 5]
not al
movzx ecx, al
imul ecx, edx
sub ecx, 0xffffff80
mov eax, ecx
shr eax, 8
add eax, ecx
shr eax, 8
mov byte [r8 - 5], al
movzx eax, byte [r8 - 4]
not al
movzx ecx, al
imul ecx, edx
sub ecx, 0xffffff80
mov eax, ecx
shr eax, 8
add eax, ecx
shr eax, 8
mov byte [r8 - 4], al
mov rdx, qword [rdi]
cmp r9d, dword [rdx]
jb 0x140040c60
jmp 0x140040d14
call r10
mov rdx, qword [rdi]
jmp 0x140040d14
xor r9d, r9d
cmp dword [rax], r9d
jbe 0x140040d14
lea r8, [rsi + 1]
nop dword [rax]
nop dword [rax + rax]
movzx ecx, byte [r9 + rbx]
inc r9d
mov byte [r8 + 1], cl
mov byte [r8], cl
mov byte [r8 - 1], cl
mov byte [r8 + 2], 0xff
lea r8, [r8 + 4]
mov rdx, qword [rdi]
cmp r9d, dword [rdx]
jb 0x140040cf0
mov eax, dword [rsp + 0x30]
inc eax
mov dword [rsp + 0x30], eax
cmp eax, dword [rdx + 4]
jb 0x140040a20
mov r13, qword [rsp + 0x168]
mov edx, dword [rdx + 8]
xor r8d, r8d
mov rcx, rdi
call fcn.14003f0d0
mov rcx, qword [rdi]
mov rax, qword [rsp + 0x80]
mov edx, dword [rcx]
mov dword [rax], edx
mov rcx, qword [rdi]
mov rax, qword [rsp + 0x88]
mov edx, dword [rcx + 4]
mov dword [rax], edx
mov rax, r12
jmp 0x140040d90
mov rdx, qword [rdi]
mov edx, dword [rdx + 8]
xor r8d, r8d
mov rcx, rdi
call fcn.14003f0d0
mov rax, qword gs:[0x58]
mov edx, Ordinal_27
mov rcx, qword [rax]
lea rax, str.outofmem
mov qword [rdx + rcx], rax
xor eax, eax
mov r12, qword [rsp + 0x170]
mov rsi, qword [rsp + 0x178]
mov rbp, qword [rsp + 0x180]
mov rbx, qword [rsp + 0x1b8]
mov r14, qword [rsp + 0x160]
mov rcx, qword [rsp + 0x150]
xor rcx, rsp
call fcn.1400f0f30
add rsp, 0x188
pop r15
pop rdi
ret