Function at 0x580900
Capabilities:
Read file on windows
Write file on windows

Disassembly:
push r15
push r14
push r13
push r12
push rbp
push rdi
push rsi
push rbx
sub rsp, 0x68
mov rax, qword [r8]
mov rbx, rcx
mov qword [rsp + 0xb8], rdx
mov rsi, r8
test rdx, rdx
je 0x580978
movzx ecx, byte [rsp + 0xb8]
mov rdi, rdx
mov edx, 1
add rdi, rdi
mov qword [rsp + 0x50], rdi
shl edx, cl
movsxd rcx, edx
mov qword [rsp + 0x28], rcx
sub rax, rcx
cmp rdi, 1
jle 0x580967
mov rdx, rdi
sar rdx, 1
neg rdx
cmp qword [rsp + 0x28], 0
mov qword [rsp + 0x58], rdx
jg 0x5809a3
add rsp, 0x68
pop rbx
pop rsi
pop rdi
pop rbp
pop r12
pop r13
pop r14
pop r15
ret
mov qword [rsp + 0x58], 0xffffffffffffffff
sub rax, 2
mov qword [rsp + 0xb8], 1
mov qword [rsp + 0x50], 2
mov qword [rsp + 0x28], 2
mov qword [rsp + 0x30], rax
mov qword [rsp + 0x48], 1
nop dword [rax]
mov rdi, qword [rsp + 0x48]
mov rcx, qword [rsp + 0xb8]
mov rax, qword [rsp + 0x58]
sub rcx, rdi
add rax, rdi
cmp rdi, qword [rsp + 0xb8]
mov edi, 1
cmovg rcx, rax
mov eax, 1
xor ebp, ebp
shl rax, cl
shl edi, cl
mov qword [rsp + 0x38], rax
movsxd rax, edi
mov rdi, rbp
mov qword [rsp + 0x40], rax
nop dword [rax]
mov rcx, qword [rsp + 0x40]
mov rax, rdi
mov r15d, 0
lea rdx, [rdi + rcx]
sub rax, rcx
test qword [rsp + 0x38], rdi
mov rcx, qword [rbx]
cmove rax, rdx
mov rdx, qword [rbx + 0x10]
xor r8d, r8d
add rax, qword [rsp + 0x30]
not rdx
and rdx, rax
shl edx, 5
call sub.msvcrt.dll_fseek
mov ecx, 0x20
call sub.msvcrt.dll_malloc
mov r9, qword [rbx]
mov r8d, 0x20
mov edx, 1
mov rcx, rax
mov r14, rax
call sub.msvcrt.dll_fread
mov rdx, qword [rsi]
cmp rax, 0x20
mov rax, qword [rbx + 0x10]
cmovne r14, r15
sub rdx, qword [rsp + 0x28]
xor r8d, r8d
mov rcx, qword [rbx]
not rax
and rdx, rax
shl edx, 5
call sub.msvcrt.dll_fseek
mov ecx, 0x20
call sub.msvcrt.dll_malloc
mov r9, qword [rbx]
mov r8d, 0x20
mov edx, 1
mov rcx, rax
mov r13, rax
call sub.msvcrt.dll_fread
mov edx, 1
mov ecx, 0x20
cmp rax, 0x20
cmovne r13, r15
call sub.msvcrt.dll_calloc
mov rdx, qword [rsi]
mov r15, rax
lea rax, [rdx + rdx]
test rdx, rdx
mov rcx, rax
not rcx
cmovs rax, rcx
cmp rax, 0x7f
jbe 0x580c28
xor edx, edx
nop dword [rax + rax]
mov r8d, eax
mov ecx, edx
shr rax, 7
or r8d, 0xffffff80
add edx, 1
mov byte [r15 + rcx], r8b
cmp rax, 0x7f
ja 0x580ae8
add rdx, r15
mov byte [rdx], al
mov ecx, pe_nt_image_headers64
add rdi, 1
call sub.msvcrt.dll_malloc
movdqu xmm2, xmmword [r15]
mov ecx, 0x20
mov r12, rax
mov rax, qword [rbx + 0x18]
movdqu xmm3, xmmword [r15 + 0x10]
movdqu xmm4, xmmword [r14]
movdqu xmm5, xmmword [r14 + 0x10]
movdqu xmm0, xmmword [rax]
movups xmmword [r12], xmm0
movdqu xmm1, xmmword [rax + 0x10]
movdqu xmm0, xmmword [r13]
movups xmmword [r12 + 0x20], xmm2
movups xmmword [r12 + 0x10], xmm1
movdqu xmm1, xmmword [r13 + 0x10]
movups xmmword [r12 + 0x30], xmm3
movups xmmword [r12 + 0x40], xmm4
movups xmmword [r12 + 0x50], xmm5
movups xmmword [r12 + 0x60], xmm0
movups xmmword [r12 + 0x70], xmm1
call sub.msvcrt.dll_malloc
mov r9d, 0x20
mov edx, pe_nt_image_headers64
mov rcx, r12
mov r8, rax
mov rbp, rax
call fcn.00583100
mov rdx, qword [rbx + 0x10]
xor r8d, r8d
mov rcx, qword [rbx]
not rdx
and rdx, qword [rsi]
shl edx, 5
call sub.msvcrt.dll_fseek
mov r9, qword [rbx]
mov edx, 1
mov rcx, rbp
mov r8d, 0x20
call sub.msvcrt.dll_fwrite
mov rcx, rbp
add qword [rsi], 1
call sub.msvcrt.dll_free
mov rcx, r12
call sub.msvcrt.dll_free
mov rcx, r14
call sub.msvcrt.dll_free
mov rcx, r13
call sub.msvcrt.dll_free
mov rcx, r15
call sub.msvcrt.dll_free
cmp rdi, qword [rsp + 0x28]
jne 0x580a00
add qword [rsp + 0x48], 1
mov rcx, qword [rsp + 0x28]
mov rax, qword [rsp + 0x48]
add qword [rsp + 0x30], rcx
cmp rax, qword [rsp + 0x50]
jl 0x5809b8
jmp 0x580967
mov rdx, r15
jmp 0x580b05