Function at 0x140040974
Capabilities:
Write file on windows

Disassembly:
mov rax, rsp
push rbp
push rsi
push rdi
push r12
push r13
push r14
push r15
lea rbp, [rax - 0x57]
sub rsp, 0xd0
mov qword [rbp - 9], 0xfffffffffffffffe
mov qword [rax + 8], rbx
mov rax, qword [0x14006d200]
xor rax, rsp
mov qword [rbp + 0x17], rax
mov rsi, r8
mov qword [rbp - 0x41], r8
movsxd r14, edx
mov rbx, rcx
mov rax, qword [rbp + 0x7f]
mov qword [rbp - 0x59], rax
mov rax, r14
mov r13, r14
sar r13, 6
mov qword [rbp - 0x39], r13
lea rcx, [0x140000000]
and eax, 0x3f
lea r15, [rax + rax*8]
mov rax, qword [rcx + r13*8 + 0x71dd0]
mov rax, qword [rax + r15*8 + 0x28]
mov qword [rbp - 0x19], rax
mov r12d, r9d
add r12, r8
mov qword [rbp - 0x61], r12
call qword [sym.imp.KERNEL32.dll_GetConsoleOutputCP]
mov dword [rbp - 0x49], eax
xor edi, edi
mov r10, qword [rbp - 0x59]
cmp byte [r10 + 0x28], dil
jne 0x140040a14
mov rcx, r10
call fcn.140032770
mov r10, qword [rbp - 0x59]
mov rcx, qword [r10 + 0x18]
mov ecx, dword [rcx + 0xc]
mov dword [rbp - 0x45], ecx
xor eax, eax
mov qword [rbx], rax
mov dword [rbx + 8], eax
cmp qword [rbp - 0x41], r12
jae 0x140040dbf
mov r9, r14
sar r9, 6
mov qword [rbp - 0x11], r9
mov edx, edi
mov al, byte [rsi]
mov byte [rbp - 0x71], al
mov dword [rbp - 0x6d], edi
mov r12d, 1
lea r11, [0x140000000]
cmp ecx, 0xfde9
jne 0x140040bd9
mov edx, edi
mov r14, rdi
lea rcx, [r15*8 + 0x3e]
add rcx, qword [r11 + r9*8 + 0x71dd0]
cmp byte [rcx], dil
je 0x140040a86
inc edx
inc r14
inc rcx
cmp r14, 5
jl 0x140040a73
test r14, r14
jle 0x140040b6f
mov rax, qword [r11 + r13*8 + 0x71dd0]
movzx ecx, byte [rax + r15*8 + 0x3e]
movsx r12d, byte [rcx + r11 + 0x6d640]
inc r12d
mov eax, r12d
sub eax, edx
mov dword [rbp - 0x51], eax
mov rdx, qword [rbp - 0x61]
sub rdx, rsi
movsxd r8, eax
cmp r8, rdx
jg 0x140040d3c
mov rcx, rdi
lea rdx, [r15*8 + 0x3e]
add rdx, qword [r11 + r9*8 + 0x71dd0]
mov al, byte [rdx]
mov byte [rbp + rcx - 1], al
inc rcx
inc rdx
cmp rcx, r14
jl 0x140040ad7
test r8, r8
jle 0x140040b07
lea rcx, [rbp - 1]
add rcx, r14
mov rdx, rsi
call fcn.14004c990
mov r10, qword [rbp - 0x59]
lea r11, [0x140000000]
mov rdx, rdi
mov rcx, qword [r11 + r13*8 + 0x71dd0]
add rcx, rdx
mov byte [rcx + r15*8 + 0x3e], dil
inc rdx
cmp rdx, r14
jl 0x140040b0a
mov qword [rbp - 0x31], rdi
lea rax, [rbp - 1]
mov qword [rbp - 0x29], rax
mov eax, edi
cmp r12d, 4
sete al
inc eax
mov r12d, eax
mov r8d, eax
mov qword [rsp + 0x20], r10
lea r9, [rbp - 0x31]
lea rdx, [rbp - 0x29]
lea rcx, [rbp - 0x6d]
call fcn.14003efb8
cmp rax, 0xffffffffffffffff
je 0x140040dbf
mov eax, dword [rbp - 0x51]
dec eax
movsxd rcx, eax
add rsi, rcx
jmp 0x140040c6a
movzx eax, byte [rsi]
movsx r13, byte [rax + r11 + 0x6d640]
lea ecx, [r13 + 1]
mov r8, qword [rbp - 0x61]
sub r8, rsi
movsxd rax, ecx
cmp rax, r8
jg 0x140040d6a
mov qword [rbp - 0x51], rdi
mov qword [rbp - 0x21], rsi
mov eax, edi
cmp ecx, 4
sete al
inc eax
mov r14d, eax
mov r8d, eax
mov qword [rsp + 0x20], r10
lea r9, [rbp - 0x51]
lea rdx, [rbp - 0x21]
lea rcx, [rbp - 0x6d]
call fcn.14003efb8
cmp rax, 0xffffffffffffffff
je 0x140040dbf
add rsi, r13
mov r12d, r14d
mov r13, qword [rbp - 0x39]
jmp 0x140040c6a
mov r8, qword [r11 + r13*8 + 0x71dd0]
mov cl, byte [r8 + r15*8 + 0x3d]
test cl, 4
je 0x140040c0c
mov al, byte [r8 + r15*8 + 0x3e]
mov byte [rbp + 7], al
mov al, byte [rsi]
mov byte [rbp + 8], al
and cl, 0xfb
mov byte [r8 + r15*8 + 0x3d], cl
mov r8d, 2
lea rdx, [rbp + 7]
jmp 0x140040c55
movzx r9d, byte [rsi]
mov rax, qword [r10 + 0x18]
mov rcx, qword [rax]
cmp word [rcx + r9*2], di
jge 0x140040c4f
lea r14, [rsi + 1]
cmp r14, qword [rbp - 0x61]
jae 0x140040d9c
mov r9, r10
mov r8d, 2
mov rdx, rsi
lea rcx, [rbp - 0x6d]
call fcn.14003d77c
cmp eax, 0xffffffff
je 0x140040dbf
mov rsi, r14
jmp 0x140040c6a
mov r8, r12
mov rdx, rsi
mov r9, r10
lea rcx, [rbp - 0x6d]
call fcn.14003d77c
cmp eax, 0xffffffff
je 0x140040dbf
inc rsi
mov qword [rsp + 0x38], rdi
mov qword [rsp + 0x30], rdi
mov dword [rsp + 0x28], 5
lea rax, [rbp + 0xf]
mov qword [rsp + 0x20], rax
mov r9d, r12d
lea r8, [rbp - 0x6d]
xor edx, edx
mov ecx, dword [rbp - 0x49]
call fcn.14003f15c
mov r14d, eax
test eax, eax
je 0x140040dbf
mov qword [rsp + 0x20], rdi
lea r9, [rbp - 0x69]
mov r8d, eax
lea rdx, [rbp + 0xf]
mov r12, qword [rbp - 0x19]
mov rcx, r12
call qword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x140040db7
mov edx, esi
sub edx, dword [rbp - 0x41]
add edx, dword [rbx + 8]
mov dword [rbx + 4], edx
cmp dword [rbp - 0x69], r14d
jb 0x140040dbf
cmp byte [rbp - 0x71], 0xa
jne 0x140040d22
mov eax, 0xd
mov word [rbp - 0x71], ax
mov qword [rsp + 0x20], rdi
lea r9, [rbp - 0x69]
lea r8d, [rax - 0xc]
lea rdx, [rbp - 0x71]
mov rcx, r12
call qword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x140040db7
cmp dword [rbp - 0x69], 1
jb 0x140040dbf
inc dword [rbx + 8]
inc dword [rbx + 4]
mov edx, dword [rbx + 4]
cmp rsi, qword [rbp - 0x61]
jae 0x140040dbf
mov r10, qword [rbp - 0x59]
mov r9, qword [rbp - 0x11]
mov ecx, dword [rbp - 0x45]
jmp 0x140040a3d
test rdx, rdx
jle 0x140040d65
sub rsi, r14
mov rcx, qword [r11 + r13*8 + 0x71dd0]
add rcx, r14
mov al, byte [rsi + r14]
mov byte [rcx + r15*8 + 0x3e], al
inc edi
inc r14
movsxd rax, edi
cmp rax, rdx
jl 0x140040d44
add dword [rbx + 4], edx
jmp 0x140040dbf
test r8, r8
jle 0x140040d96
mov rdx, rdi
mov r9, qword [rbp - 0x39]
mov rcx, qword [r11 + r9*8 + 0x71dd0]
add rcx, rdx
mov al, byte [rdx + rsi]
mov byte [rcx + r15*8 + 0x3e], al
inc edi
inc rdx
movsxd rax, edi
cmp rax, r8
jl 0x140040d76
add dword [rbx + 4], r8d
jmp 0x140040dbf
mov byte [r8 + r15*8 + 0x3e], r9b
mov rax, qword [r11 + r13*8 + 0x71dd0]
or byte [rax + r15*8 + 0x3d], 4
lea eax, [rdx + 1]
mov dword [rbx + 4], eax
jmp 0x140040dbf
call qword [sym.imp.KERNEL32.dll_GetLastError]
mov dword [rbx], eax
mov rax, rbx
mov rcx, qword [rbp + 0x17]
xor rcx, rsp
call fcn.140021e10
mov rbx, qword [rsp + 0x110]
add rsp, 0xd0
pop r15
pop r14
pop r13
pop r12
pop rdi
pop rsi
pop rbp
ret