Function at 0x140040d90
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 0x140041012
sub r9d, 1
mov rbx, r8
xor r15d, r15d
mov edi, 0x23
movsxd r14, r9d
lea eax, [r15 + 1]
cmp eax, ebp
jge 0x140040f6b
lea esi, [r15 + 2]
cmp ebp, esi
jge 0x140040df0
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 0x140040f73
lea rcx, [rax + 1]
mov qword [r12 + 0x18], rcx
movzx r9d, byte [rax]
shl r9d, 8
cmp rcx, rdx
jae 0x140040f91
lea r8, [rcx + 1]
mov qword [r12 + 0x18], r8
movzx eax, byte [rcx]
or r9d, eax
lea eax, [r9 - 0xd800]
cmp eax, 0x7ff
ja 0x14004102c
lea esi, [r15 + 4]
cmp ebp, esi
jl 0x140040dd7
cmp r8, rdx
jae 0x140040fc5
lea rcx, [r8 + 1]
mov qword [r12 + 0x18], rcx
movzx r15d, byte [r8]
shl r15d, 8
cmp rcx, rdx
jae 0x140040feb
lea rdx, [rcx + 1]
mov qword [r12 + 0x18], rdx
movzx ecx, byte [rcx]
mov edx, r15d
or edx, ecx
cmp edx, 0x3ff
ja 0x140040dd7
cmp eax, 0x3ff
ja 0x140040dd7
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 0x140040f18
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 0x140041024
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 0x140040f5c
lea ecx, [rax - 6]
mov rax, rbx
sub rax, r13
cmp r14, rax
jle 0x140040f5c
mov eax, r9d
lea rdx, [rbx + 1]
shr eax, cl
and eax, 0x3f
or eax, 0xffffff80
cmp ecx, 6
mov byte [rbx], al
jne 0x140040fc0
mov rax, rdx
sub rax, r13
cmp r14, rax
jle 0x140040fc0
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 0x140040dcf
mov esi, r15d
jmp 0x140040dd7
mov rcx, r12
call fcn.14003a1b0
mov rax, qword [r12 + 0x18]
mov rdx, qword [r12 + 0x20]
cmp rax, rdx
jb 0x140040e03
xor r9d, r9d
mov rcx, r12
mov dword [rsp + 0x2c], r9d
call fcn.14003a1b0
mov r8, qword [r12 + 0x18]
mov rdx, qword [r12 + 0x20]
mov r9d, dword [rsp + 0x2c]
cmp r8, rdx
jb 0x14004101c
xor eax, eax
jmp 0x140040e29
mov rbx, rdx
jmp 0x140040f5c
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 0x140040e4f
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 0x140040e69
xor ecx, ecx
jmp 0x140040e75
mov eax, 0xffffffea
jmp 0x140040ddc
mov rcx, r8
jmp 0x140040e1d
mov rbx, r10
jmp 0x140040f18
test r9d, r9d
je 0x140040dd7
cmp r9d, 0x7f
ja 0x140040e9c
mov rax, rbx
mov r15d, esi
sub rax, r13
cmp rax, r14
jge 0x140040dc3
mov byte [rbx], r9b
add rbx, 1
jmp 0x140040dc3