Function at 0x408344
Capabilities:
Write file on windows

Disassembly:
push r15
push r14
push r12
push rsi
push rdi
push rbx
sub rsp, 0xa8
mov rsi, rcx
test r9, r9
je 0x40838e
mov r15, r9
mov r14, r8
mov rbx, qword [rsp + 0x100]
mov ecx, edx
call sub.KERNEL32.dll_GetStdHandle
test rax, rax
je 0x408396
mov rdi, rax
cmp rax, 0xffffffffffffffff
jne 0x4083bc
call sub.KERNEL32.dll_GetLastError
shl rax, 0x20
or rax, 2
jmp 0x4083a0
xorps xmm0, xmm0
movups xmmword [rsi], xmm0
jmp 0x4083ab
movabs rax, 0x600000002
mov qword [rsi + 8], rax
mov qword [rsi], 1
add rsp, 0xa8
pop rbx
pop rdi
pop rsi
pop r12
pop r14
pop r15
ret
lea rdx, [rsp + 0x78]
and dword [rdx], 0
mov rcx, rdi
call sub.KERNEL32.dll_GetConsoleMode
test eax, eax
je 0x408427
movzx eax, byte [rbx + 4]
test rax, rax
je 0x4084a3
cmp al, 4
jae 0x4085ff
mov cl, byte [r14]
mov edx, ecx
and dl, 0xc0
cmp dl, 0x80
jne 0x40850e
mov byte [rbx + rax], cl
mov al, byte [rbx + 4]
inc al
mov byte [rbx + 4], al
movzx ecx, byte [rbx]
lea rdx, [0x0040ca2f]
movzx r14d, byte [rcx + rdx]
cmp r14b, al
jbe 0x408532
mov qword [rsi + 8], 1
and qword [rsi], 0
jmp 0x4083ab
movups xmm0, xmmword [0x0040cc78]
lea rax, [rsp + 0x50]
movaps xmmword [rax], xmm0
mov ecx, 0xffffffff
cmp r15, rcx
cmovb rcx, r15
xorps xmm0, xmm0
movups xmmword [rsp + 0x38], xmm0
mov dword [rsp + 0x30], ecx
mov qword [rsp + 0x28], r14
mov qword [rsp + 0x20], rax
mov rcx, rdi
xor edx, edx
xor r8d, r8d
xor r9d, r9d
call sub.ntdll.dll_NtWriteFile
cmp eax, 0x103
jne 0x40848b
mov rcx, rdi
mov edx, 0xffffffff
call sub.KERNEL32.dll_WaitForSingleObject
mov eax, dword [rsp + 0x50]
cmp eax, 0x103
je 0x408603
test eax, eax
js 0x40851e
mov rax, qword [rsp + 0x58]
mov qword [rsi + 8], rax
xor eax, eax
jmp 0x4085e3
mov r8d, 0x1000
cmp r15, r8
cmovb r8, r15
lea r12, [rsp + 0x50]
mov rcx, r12
mov rdx, r14
call fcn.00406c72
cmp qword [r12], 0
je 0x408563
mov r8, qword [rsp + 0x58]
test r8, r8
je 0x408588
cmp r8, r15
ja 0x4085ff
lea rbx, [rsp + 0x78]
mov rcx, rbx
mov rdx, r14
call fcn.00406c72
cmp qword [rbx], 0
jne 0x4085ff
mov r8, qword [rsp + 0x80]
mov r9, qword [rsp + 0x88]
jmp 0x40856d
mov byte [rbx + 4], 0
lea rax, str.Windows_stdio_in_console_mode_does_not_support_writing_non_UTF_8_byte_sequences
jmp 0x4083a0
mov ecx, eax
call sub.ntdll.dll_RtlNtStatusToDosError
shl rax, 0x20
or rax, 2
jmp 0x4085da
movzx r8d, al
cmp r8b, 5
jae 0x4085ff
lea r15, [rsp + 0x78]
mov rcx, r15
mov rdx, rbx
call fcn.00406c72
mov byte [rbx + 4], 0
cmp qword [r15], 0
je 0x4085aa
lea rax, str.Windows_stdio_in_console_mode_does_not_support_writing_non_UTF_8_byte_sequences
jmp 0x4085da
mov r8, qword [rsp + 0x58]
mov r9, qword [rsp + 0x60]
mov rcx, rsi
mov rdx, rdi
add rsp, 0xa8
pop rbx
pop rdi
pop rsi
pop r12
pop r14
pop r15
jmp 0x40864c
movzx eax, byte [r14]
lea rcx, [0x0040ca2f]
movzx ecx, byte [rax + rcx]
cmp rcx, 2
jb 0x40855a
cmp rcx, r15
jbe 0x40855a
mov byte [rbx], al
mov byte [rbx + 4], 1
jmp 0x4085f2
cmp qword [rsp + 0x88], r14
jne 0x4085ff
mov r8, qword [rsp + 0x80]
lea rbx, [rsp + 0x50]
mov rcx, rbx
mov rdx, rdi
mov r9, r14
call 0x40864c
cmp qword [rbx], 0
je 0x4085eb
mov rax, qword [rsp + 0x58]
mov qword [rsi + 8], rax
mov eax, 1
mov qword [rsi], rax
jmp 0x4083ab
cmp qword [rsp + 0x58], r14
jne 0x4085ff
mov qword [rsi + 8], 1
jmp 0x40849c
ud2
lea rcx, [rsp + 0x70]
mov byte [rcx + 4], 0
and dword [rcx], 0
lea rax, str.fatal_runtime_error:_I_O_error:_operation_failed_to_complete_synchronously_n
lea rdx, [rsp + 0x78]
mov qword [rdx], rax
mov qword [rdx + 8], 1
lea rax, [rsp + 0x48]
mov qword [rdx + 0x10], rax
xorps xmm0, xmm0
movups xmmword [rdx + 0x18], xmm0
call fcn.0040882b
mov rcx, rax
call fcn.00408222
mov ecx, 7
int 0x29
ud2
push r15
push r14
push rsi
push rdi
push rbx
mov eax, 0x2040
call fcn.00405da4
sub rsp, rax
mov rbx, rdx
mov rsi, rcx
cmp r9, 0x1001
jae 0x408674
mov rdi, r9
jmp 0x4086b3
xor eax, eax
cmp rax, 0xfffffffffffffffc
je 0x4087d0
mov rdi, rax
dec rax
cmp byte [r8 + rdi + 0x1000], 0xc0
jl 0x408676
add rdi, 4
add rdi, 0xffc
cmp rdi, r9
jae 0x4086ad
cmp byte [r8 + rdi], 0xbf
jg 0x4086b3
jmp 0x4087d0
jne 0x4087d0
lea rax, [rsp + 0x40]
mov qword [rsp + 0x20], rax
mov dword [rsp + 0x28], 0x1000
mov ecx, 0xfde9
mov edx, 8
mov r9d, edi
call sub.KERNEL32.dll_MultiByteToWideChar
test eax, eax
je 0x4087d0
cmp eax, 0x1001
jae 0x4087d0
movsxd r14, eax
lea r15, [rsp + 0x30]
lea r8, [rsp + 0x40]
mov rcx, r15
mov rdx, rbx
mov r9, r14
call fcn.004087d4
cmp qword [r15], 0
je 0x40871d
mov rax, qword [rsp + 0x38]
mov qword [rsi + 8], rax
mov qword [rsi], 1
jmp 0x40872f
mov r15, qword [rsp + 0x38]
cmp r15, r14
jne 0x40873e
mov qword [rsi + 8], rdi
and qword [rsi], 0
add rsp, 0x2040
pop rbx
pop rdi
pop rsi
pop r14
pop r15
ret
jae 0x4087d0
movzx eax, word [rsp + r15*2 + 0x40]
add eax, 0x2312
cmp ax, 0x312
jae 0x408786
lea r8, [rsp + r15*2]
add r8, 0x40
lea rdi, [rsp + 0x30]
mov r9d, 1
mov rcx, rdi
mov rdx, rbx
call fcn.004087d4
cmp qword [rdi], 0
je 0x408783
mov rcx, qword [rsp + 0x38]
call fcn.0040822c
inc r15
add r15, r15
xor eax, eax
xor edi, edi
cmp r15, rax
je 0x408727
movzx ecx, word [rsp + rax + 0x40]
mov edx, 1
cmp cx, 0x80
jb 0x4087c7
mov edx, 2
cmp cx, 0x800
jb 0x4087c7
add ecx, 0x2312
xor edx, edx
cmp cx, 0x312
setae dl
lea rdx, [rdx*2 + 1]
add rdi, rdx
add rax, 2
jmp 0x40878d
ud2