Function at 0x140182130
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
push rbx
push rbp
push rsi
push rdi
push r12
push r13
push r14
push r15
sub rsp, 0x88
mov rax, qword [0x140209000]
xor rax, rsp
mov qword [rsp + 0x70], rax
mov rax, qword [rcx + 0xc0]
mov rbx, rcx
mov qword [rsp + 0x38], r9
mov qword [rsp + 0x40], r8
mov qword [rsp + 0x60], rdx
cmp rax, qword [rcx + 0xc8]
jae 0x140182184
movzx edx, byte [rax]
inc rax
mov qword [rcx + 0xc0], rax
jmp 0x1401821a7
cmp dword [rcx + 0x30], 0
je 0x1401821a5
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
movzx edx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x1401821a7
xor dl, dl
mov ecx, 0x30
mov r8, rbx
lea rsi, [rcx + rbx]
movzx ecx, dl
mov dword [rsp + 0x24], ecx
cmp rax, qword [rbx + 0xc8]
jae 0x1401821d6
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
mov byte [rsp + 0x20], cl
jmp 0x140182202
cmp dword [rsi], 0
je 0x1401821fd
mov rcx, rbx
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
mov byte [rsp + 0x20], cl
jmp 0x140182202
mov byte [rsp + 0x20], 0
cmp rax, qword [rbx + 0xc8]
jae 0x14018221a
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14018223f
cmp dword [rsi], 0
je 0x14018223d
mov rcx, rbx
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14018223f
xor cl, cl
movzx eax, cl
mov rcx, rbx
mov dword [rsp + 0x2c], eax
mov r12d, eax
call fcn.1401770e0
mov rcx, rbx
movsxd r15, eax
call fcn.1401770e0
mov rcx, qword [rbx + 0xc0]
mov dword [rsp + 0x50], eax
cmp rcx, qword [rbx + 0xc8]
jae 0x14018227f
movzx edx, byte [rcx]
inc rcx
mov qword [rbx + 0xc0], rcx
jmp 0x1401822a4
cmp dword [rsi], 0
je 0x1401822a2
mov rcx, rbx
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
movzx edx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x1401822a4
xor dl, dl
mov rcx, rbx
movzx edi, dl
call fcn.1401770e0
mov rcx, rbx
call fcn.1401770e0
mov rcx, rbx
call fcn.1401770e0
mov rcx, rbx
mov dword [rsp + 0x30], eax
call fcn.1401770e0
mov ebp, eax
mov dword [rsp + 0x28], eax
mov rax, qword [rbx + 0xc0]
cmp rax, qword [rbx + 0xc8]
jae 0x1401822f0
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140182315
cmp dword [rsi], 0
je 0x140182313
mov rcx, rbx
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140182315
xor cl, cl
movzx edx, cl
mov dword [rsp + 0x58], edx
cmp rax, qword [rbx + 0xc8]
jae 0x140182334
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14018235d
cmp dword [rsi], 0
je 0x14018235b
mov rcx, rbx
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
mov edx, dword [rsp + 0x58]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14018235d
xor cl, cl
xor r14d, r14d
movzx eax, cl
mov qword [rsp + 0x48], r14
mov dword [rsp + 0x6c], r14d
mov dword [rsp + 0x54], r14d
lea r13d, [r14 + 1]
cmp ebp, 0x1000000
jg 0x140182b4d
mov r8d, dword [rsp + 0x30]
cmp r8d, 0x1000000
jg 0x140182b4d
cmp r12d, 8
jb 0x14018239e
sub r12d, 8
shr eax, 5
mov ecx, r13d
and eax, r13d
mov ebp, r14d
sub ecx, eax
mov dword [rsp + 0x5c], ecx
cmp byte [rsp + 0x20], r14b
je 0x1401823d9
mov ecx, edi
sub ecx, 8
je 0x1401823d4
sub ecx, 7
je 0x140182422
sub ecx, r13d
je 0x140182422
sub ecx, 8
je 0x1401823f6
cmp ecx, 8
jne 0x1401823fd
jmp 0x1401823f6
mov edi, r13d
jmp 0x1401823f9
mov ecx, edx
sub ecx, 8
je 0x14018242c
sub ecx, 7
je 0x140182422
sub ecx, r13d
je 0x140182415
sub ecx, 8
je 0x1401823f4
cmp ecx, 8
jne 0x1401823fd
mov edi, edx
shr edi, 3
test edi, edi
jne 0x14018242f
mov rax, qword gs:[0x58]
mov rcx, qword [rax]
lea rax, str.bad_format
jmp 0x140182b60
cmp r12d, 3
jne 0x140182422
lea edi, [r12 - 1]
jmp 0x14018242f
mov ebp, r13d
mov edi, 3
jmp 0x14018242f
mov edi, r13d
mov rax, qword [rsp + 0x60]
mov r12d, dword [rsp + 0x28]
mov dword [rax], r8d
mov rax, qword [rsp + 0x40]
mov dword [rax], r12d
mov rax, qword [rsp + 0x38]
test rax, rax
je 0x140182450
mov dword [rax], edi
test r8d, r8d
js 0x140182b4d
test r12d, r12d
js 0x140182b4d
je 0x140182476
mov eax, 0x7fffffff
cdq
idiv r12d
cmp r8d, eax
jg 0x140182b4d
mov ecx, r12d
imul ecx, r8d
test ecx, ecx
js 0x140182b4d
xor edx, edx
mov eax, 0x7fffffff
div edi
cmp ecx, eax
jg 0x140182b4d
test r12d, r12d
je 0x1401824ad
mov eax, 0x7fffffff
cdq
idiv r12d
cmp r8d, eax
jg 0x140182b38
mov eax, r12d
imul eax, edi
imul eax, r8d
movsxd rcx, eax
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov qword [rsp + 0x40], rax
mov rsi, rax
test rax, rax
je 0x140182b38
movsxd rdx, dword [rsp + 0x24]
test edx, edx
je 0x140182510
cmp qword [rbx + 0x10], r14
je 0x140182509
mov ecx, dword [rbx + 0xc8]
sub ecx, dword [rbx + 0xc0]
cmp ecx, edx
jge 0x140182509
mov rax, qword [rbx + 0xc8]
sub edx, ecx
mov rcx, qword [rbx + 0x28]
mov qword [rbx + 0xc0], rax
call qword [rbx + 0x18]
jmp 0x140182510
add qword [rbx + 0xc0], rdx
cmp byte [rsp + 0x20], r14b
jne 0x1401825d4
mov edx, dword [rsp + 0x2c]
mov r15d, edi
mov dword [rsp + 0x24], ebp
mov dword [rsp + 0x38], edi
cmp edx, 8
jae 0x1401827ff
mov dword [rsp + 0x24], ebp
mov dword [rsp + 0x38], edi
test ebp, ebp
jne 0x1401827ff
mov r13d, ebp
test r12d, r12d
jle 0x140182ae8
imul r15d, dword [rsp + 0x30]
cmp dword [rsp + 0x5c], r14d
je 0x1401825a4
mov ecx, dword [rsp + 0x28]
mov eax, r15d
neg eax
mov r14d, ecx
movsxd r12, eax
lea eax, [rcx - 1]
imul eax, edi
imul eax, dword [rsp + 0x30]
movsxd rsi, eax
add rsi, qword [rsp + 0x40]
nop
mov r8d, r15d
mov rdx, rsi
mov rcx, rbx
call fcn.140176f50
add rsi, r12
sub r14, 1
jne 0x140182580
mov r12d, dword [rsp + 0x28]
mov r15d, edi
jmp 0x140182ae3
mov r14d, dword [rsp + 0x28]
movsxd r12, r15d
nop dword [rax]
mov r8d, r15d
mov rdx, rsi
mov rcx, rbx
call fcn.140176f50
add rsi, r12
sub r14, 1
jne 0x1401825b0
mov r12d, dword [rsp + 0x28]
mov r15d, edi
jmp 0x140182ae3
cmp dword [rsp + 0x50], r14d
jne 0x1401825fc
mov rcx, rsi
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rax, qword gs:[0x58]
mov rcx, qword [rax]
lea rax, str.bad_palette
jmp 0x140182b60
test r15d, r15d
je 0x14018264e
jns 0x140182613
mov rax, qword [rbx + 0xc8]
mov qword [rbx + 0xc0], rax
jmp 0x14018264e
cmp qword [rbx + 0x10], r14
je 0x140182647
mov ecx, dword [rbx + 0xc8]
sub ecx, dword [rbx + 0xc0]
cmp ecx, r15d
jge 0x140182647
mov rax, qword [rbx + 0xc8]
sub r15d, ecx
mov rcx, qword [rbx + 0x28]
mov edx, r15d
mov qword [rbx + 0xc0], rax
call qword [rbx + 0x18]
jmp 0x14018264e
add qword [rbx + 0xc0], r15
mov r15d, dword [rsp + 0x50]
test r15d, r15d
js 0x140182b2f
xor edx, edx
mov eax, 0x7fffffff
div edi
cmp r15d, eax
jg 0x140182b2f
mov esi, edi
imul esi, r15d
movsxd rcx, esi
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov qword [rsp + 0x48], rax
test rax, rax
je 0x140182b2a
test ebp, ebp
je 0x1401827c8
mov rsi, rax
cmp edi, 3
je 0x1401826b5
mov r8d, 0x1791
lea rdx, str.C:DataVisualStudioNipponEditorStbImage_stb_image.h
lea rcx, str.tga_comp__STBI_rgb
call qword [sym.imp.api_ms_win_crt_runtime_l1_1_0.dll__wassert]
mov dword [rsp + 0x24], ebp
mov dword [rsp + 0x38], edi
test r15d, r15d
jle 0x1401827c0
mov r12d, edi
nop dword [rax]
mov rcx, rbx
call fcn.1401770e0
movzx r8d, ax
mov eax, r8d
shr eax, 0xa
and eax, 0x1f
imul ecx, eax, 0xff
mov eax, 0x84210843
imul ecx
add edx, ecx
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, r8d
shr eax, 5
and r8d, 0x1f
and eax, 0x1f
mov byte [rsi], dl
imul ecx, eax, 0xff
mov eax, 0x84210843
imul ecx
add edx, ecx
imul ecx, r8d, 0xff
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, 0x84210843
mov byte [rsi + 1], dl
imul ecx
add edx, ecx
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov byte [rsi + 2], dl
add rsi, r12
sub r15, r13
jne 0x1401826d0
mov r12d, dword [rsp + 0x28]
mov r15d, edi
mov rdi, qword [rsp + 0x48]
mov edx, dword [rsp + 0x2c]
mov ecx, dword [rsp + 0x30]
mov eax, r12d
imul eax, ecx
mov esi, r15d
test eax, eax
je 0x140182a56
mov r12, qword [rsp + 0x40]
lea r8, [rsp + 0x6c]
sub r12, r8
movsxd rcx, r15d
mov qword [rsp + 0x60], rax
mov ebp, r14d
nop dword [rax]
cmp edx, 8
jb 0x140182850
test ebp, ebp
jne 0x140182840
mov rax, qword [rbx + 0xc0]
cmp rax, qword [rbx + 0xc8]
jae 0x140182807
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14018282d
mov r15d, edi
mov rdi, rsi
jmp 0x14018275b
mov r15d, edi
mov dword [rsp + 0x38], edi
mov r8d, esi
mov dword [rsp + 0x24], ebp
mov rdx, rax
mov rcx, rbx
mov rdi, rax
call fcn.140176f50
test eax, eax
jne 0x14018275b
mov rcx, qword [rsp + 0x40]
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rcx, rdi
jmp 0x1401825de
mov rdi, r14
jmp 0x14018275f
cmp dword [rbx + 0x30], r14d
je 0x14018282b
mov rcx, rbx
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14018282d
xor cl, cl
movzx eax, cl
mov ebp, eax
and ebp, 0x7f
inc ebp
shr eax, 7
mov dword [rsp + 0x54], eax
jmp 0x140182850
cmp dword [rsp + 0x54], r14d
je 0x140182850
test r13d, r13d
je 0x1401829fc
cmp byte [rsp + 0x20], r14b
je 0x1401828e9
cmp dword [rsp + 0x58], 8
jne 0x1401828b2
mov rax, qword [rbx + 0xc0]
cmp rax, qword [rbx + 0xc8]
jae 0x140182884
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
movzx eax, cl
jmp 0x1401828ba
cmp dword [rbx + 0x30], r14d
je 0x1401828ab
mov rcx, rbx
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
movzx eax, cl
jmp 0x1401828ba
xor cl, cl
movzx eax, cl
jmp 0x1401828ba
mov rcx, rbx
call fcn.1401770e0
test r15d, r15d
je 0x1401829f1
cmp eax, dword [rsp + 0x50]
mov ecx, r14d
mov r8, rsi
cmovl ecx, eax
imul ecx, r15d
movsxd rdx, ecx
lea rcx, [rsp + 0x6c]
add rdx, rdi
call sub.VCRUNTIME140.dll_memcpy
jmp 0x1401829f1
cmp dword [rsp + 0x24], r14d
je 0x140182990
cmp r15d, 3
je 0x140182914
mov r8d, 0x17c6
lea rdx, str.C:DataVisualStudioNipponEditorStbImage_stb_image.h
lea rcx, str.tga_comp__STBI_rgb
call qword [sym.imp.api_ms_win_crt_runtime_l1_1_0.dll__wassert]
mov rcx, rbx
call fcn.1401770e0
movzx r8d, ax
mov eax, r8d
shr eax, 0xa
and eax, 0x1f
imul ecx, eax, 0xff
mov eax, 0x84210843
imul ecx
add edx, ecx
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, r8d
shr eax, 5
and r8d, 0x1f
and eax, 0x1f
mov byte [rsp + 0x6c], dl
imul ecx, eax, 0xff
mov eax, 0x84210843
imul ecx
add edx, ecx
imul ecx, r8d, 0xff
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, 0x84210843
mov byte [rsp + 0x6d], dl
imul ecx
add edx, ecx
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov byte [rsp + 0x6e], dl
jmp 0x1401829f1
mov rdi, r14
test r15d, r15d
je 0x1401829f1
nop dword [rax + rax]
mov rax, qword [rbx + 0xc0]
cmp rax, qword [rbx + 0xc8]
jae 0x1401829bf
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x1401829e5
cmp dword [rbx + 0x30], r14d
je 0x1401829e3
mov rcx, rbx
call fcn.140176ed0
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x1401829e5
xor cl, cl
mov byte [rsp + rdi + 0x6c], cl
inc rdi
cmp rdi, rsi
jl 0x1401829a0
mov rax, qword [rsp + 0x60]
mov r13d, r14d
movsxd rcx, r15d
mov rdi, r14
test r15d, r15d
je 0x140182a30
lea rcx, [rsp + 0x6c]
mov r8, rsi
add rcx, r12
lea rdx, [rsp + 0x6c]
call sub.VCRUNTIME140.dll_memcpy
nop dword [rax]
inc rdi
cmp rdi, rsi
jl 0x140182a20
mov rax, qword [rsp + 0x60]
movsxd rcx, r15d
mov rdi, qword [rsp + 0x48]
dec ebp
mov edx, dword [rsp + 0x2c]
add r12, rcx
sub rax, 1
mov qword [rsp + 0x60], rax
jne 0x140182790
mov r12d, dword [rsp + 0x28]
mov ecx, dword [rsp + 0x30]
cmp dword [rsp + 0x5c], r14d
je 0x140182ace
test r12d, r12d
jle 0x140182ace
mov r11d, r15d
lea r10d, [r12 - 1]
imul r10d, r15d
mov ebx, r14d
mov r15, qword [rsp + 0x40]
imul r11d, ecx
imul r10d, ecx
nop
mov r8d, r11d
test r11d, r11d
jle 0x140182aba
movsxd rax, ebx
movsxd r9, r10d
sub r9, rax
lea rdx, [rax + r15]
nop word [rax + rax]
movzx eax, byte [rdx + r9]
dec r8d
movzx ecx, byte [rdx]
mov byte [rdx], al
mov byte [rdx + r9], cl
lea rdx, [rdx + 1]
test r8d, r8d
jg 0x140182aa0
add ebx, r11d
sub r10d, r11d
add r14d, 2
cmp r14d, r12d
jl 0x140182a80
mov r15d, dword [rsp + 0x38]
mov rcx, qword [rsp + 0x48]
test rcx, rcx
je 0x140182ade
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov r13d, dword [rsp + 0x24]
mov rsi, qword [rsp + 0x40]
cmp r15d, 3
jb 0x140182b25
test r13d, r13d
jne 0x140182b25
imul r12d, dword [rsp + 0x30]
mov rdx, rsi
test r12d, r12d
je 0x140182b25
mov r9d, r15d
mov r8d, r12d
nop word [rax + rax]
movzx ecx, byte [rdx]
movzx eax, byte [rdx + 2]
mov byte [rdx], al
mov byte [rdx + 2], cl
add rdx, r9
sub r8, 1
jne 0x140182b10
mov rax, rsi
jmp 0x140182b6b
mov rsi, qword [rsp + 0x40]
mov rcx, rsi
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rax, qword gs:[0x58]
mov rcx, qword [rax]
lea rax, str.outofmem
jmp 0x140182b60
mov rax, qword gs:[0x58]
mov rcx, qword [rax]
lea rax, str.too_large
mov edx, 0x28
mov qword [rdx + rcx], rax
xor eax, eax
mov rcx, qword [rsp + 0x70]
xor rcx, rsp
call fcn.1401981a0
add rsp, 0x88
pop r15
pop r14
pop r13
pop r12
pop rdi
pop rsi
pop rbp
pop rbx
ret