Function at 0x140040ac0
Capabilities:
Encrypt data using rc4 prga

Disassembly:
push r15
push r14
push r13
push r12
push rbp
push rdi
push rsi
push rbx
sub rsp, 0x38
test r9d, r9d
mov r12, rcx
mov ebp, edx
mov r13, r8
jle 0x140040d3d
sub r9d, 1
mov rbx, r8
xor r15d, r15d
mov edi, 0x23
movsxd r14, r9d
lea eax, [r15 + 1]
cmp eax, ebp
jge 0x140040c98
lea esi, [r15 + 2]
cmp ebp, esi
jge 0x140040b20
mov byte [rbx], 0
mov eax, esi
add rsp, 0x38
pop rbx
pop rsi
pop rdi
pop rbp
pop r12
pop r13
pop r14
pop r15
ret
mov rax, qword [r12 + 0x18]
mov rdx, qword [r12 + 0x20]
cmp rax, rdx
jae 0x140040ca0
lea rcx, [rax + 1]
cmp rcx, rdx
mov qword [r12 + 0x18], rcx
movzx eax, byte [rax]
jae 0x140040cbd
lea r8, [rcx + 1]
mov qword [r12 + 0x18], r8
movzx r9d, byte [rcx]
shl r9d, 8
or r9d, eax
lea eax, [r9 - 0xd800]
cmp eax, 0x7ff
ja 0x140040d57
lea esi, [r15 + 4]
cmp ebp, esi
jl 0x140040b07
cmp r8, rdx
jae 0x140040cf0
lea rcx, [r8 + 1]
cmp rcx, rdx
mov qword [r12 + 0x18], rcx
movzx r15d, byte [r8]
jae 0x140040d16
lea rdx, [rcx + 1]
mov qword [r12 + 0x18], rdx
movzx edx, byte [rcx]
shl edx, 8
or edx, r15d
cmp edx, 0x3ff
ja 0x140040b07
cmp eax, 0x3ff
ja 0x140040b07
shl eax, 0xa
lea r9d, [rdx + rax + 0x10000]
mov eax, r9d
mov r8d, edi
mov edx, 0x66666667
or eax, 1
bsr eax, eax
xor eax, 0x1f
sub r8d, eax
mov eax, r8d
sar r8d, 0x1f
imul edx
mov ecx, edx
sar ecx, 1
sub ecx, r8d
mov r8, rbx
lea edx, [rcx + rcx*2 - 3]
sub r8, r13
add edx, edx
cmp r8, r14
lea eax, [rdx - 6]
jge 0x140040c45
lea r10, [rbx + 1]
mov r8d, 0x100
mov r11d, r9d
sar r8d, cl
mov ecx, edx
mov rdx, r10
neg r8d
shr r11d, cl
sub rdx, r13
or r8d, r11d
cmp r14, rdx
mov byte [rbx], r8b
jle 0x140040d4f
mov edx, r9d
mov ecx, eax
add rbx, 2
shr edx, cl
and edx, 0x3f
or edx, 0xffffff80
mov byte [rbx - 1], dl
cmp eax, 5
jle 0x140040c89
lea ecx, [rax - 6]
mov rax, rbx
sub rax, r13
cmp r14, rax
jle 0x140040c89
mov eax, r9d
lea rdx, [rbx + 1]
shr eax, cl
and eax, 0x3f
or eax, 0xffffff80
cmp ecx, 6
mov byte [rbx], al
jne 0x140040ce4
mov rax, rdx
sub rax, r13
cmp r14, rax
jle 0x140040ce4
and r9d, 0x3f
add rbx, 2
or r9d, 0xffffff80
mov byte [rbx - 1], r9b
mov r15d, esi
lea eax, [r15 + 1]
cmp eax, ebp
jl 0x140040aff
mov esi, r15d
jmp 0x140040b07
mov rcx, r12
call fcn.14003a1b0
mov rax, qword [r12 + 0x18]
mov rdx, qword [r12 + 0x20]
cmp rax, rdx
jb 0x140040b33
xor eax, eax
mov rcx, r12
mov dword [rsp + 0x2c], eax
call fcn.14003a1b0
mov r8, qword [r12 + 0x18]
mov rdx, qword [r12 + 0x20]
mov eax, dword [rsp + 0x2c]
cmp r8, rdx
jb 0x140040d47
xor r9d, r9d
jmp 0x140040b59
mov rbx, rdx
jmp 0x140040c89
mov rcx, r12
mov dword [rsp + 0x2c], eax
call fcn.14003a1b0
mov r8, qword [r12 + 0x18]
mov rdx, qword [r12 + 0x20]
mov eax, dword [rsp + 0x2c]
cmp r8, rdx
jb 0x140040b7f
xor r15d, r15d
mov rcx, r12
mov dword [rsp + 0x2c], eax
call fcn.14003a1b0
mov rcx, qword [r12 + 0x18]
cmp rcx, qword [r12 + 0x20]
mov eax, dword [rsp + 0x2c]
jb 0x140040b95
xor edx, edx
jmp 0x140040ba4
mov eax, 0xffffffea
jmp 0x140040b0c
mov rcx, r8
jmp 0x140040b48
mov rbx, r10
jmp 0x140040c45
test r9d, r9d
je 0x140040b07
cmp r9d, 0x7f
ja 0x140040bc9
mov rax, rbx
mov r15d, esi
sub rax, r13
cmp rax, r14
jge 0x140040af3
mov byte [rbx], r9b
add rbx, 1
jmp 0x140040af3