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

Disassembly:
push r12
push r15
sub rsp, 0x1a8
mov rax, qword [section..data]
xor rax, rsp
mov qword [rsp + 0x170], rax
mov r12, rdx
mov qword [rsp + 0x38], rdx
lea rdx, [0x1400065ac]
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fopen]
mov r15, rax
test rax, rax
jne 0x1400037bf
lea rcx, str.Cannot_open_file__n
call fcn.140001010
lea rax, [r15 - 1]
jmp 0x140003b0d
mov edx, 0x20
lea rcx, [rsp + 0x40]
mov r9, r15
lea r8d, [rdx - 0x1f]
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
mov ecx, dword [rsp + 0x50]
mov r8d, ecx
mov eax, ecx
and r8d, 0xff0000
shr eax, 0x10
or r8d, eax
mov eax, ecx
and eax, 0xff00
shl ecx, 0x10
or eax, ecx
shr r8d, 8
mov ecx, dword [rsp + 0x54]
mov r9d, ecx
shl eax, 8
and r9d, 0xff0000
or r8d, eax
mov eax, ecx
shr eax, 0x10
or r9d, eax
mov dword [rsp + 0x50], r8d
mov eax, ecx
shr r9d, 8
and eax, 0xff00
shl ecx, 0x10
or eax, ecx
mov ecx, dword [rsp + 0x58]
shl eax, 8
mov edx, ecx
or r9d, eax
and edx, 0xff0000
mov eax, ecx
mov dword [rsp + 0x54], r9d
shr eax, 0x10
or edx, eax
mov eax, ecx
and eax, 0xff00
shr edx, 8
shl ecx, 0x10
or eax, ecx
mov ecx, dword [rsp + 0x5c]
shl eax, 8
or edx, eax
mov eax, ecx
shr eax, 0x10
mov dword [rsp + 0x58], edx
mov edx, ecx
and edx, 0xff0000
or edx, eax
mov eax, ecx
and eax, 0xff00
shl ecx, 0x10
or eax, ecx
shr edx, 8
shl eax, 8
or edx, eax
cmp dword [rsp + 0x40], 0x52415350
mov dword [rsp + 0x5c], edx
je 0x1400038b0
lea rcx, str.Unrecognized_magic._PSAR_was_expected._n
call fcn.140001010
mov rax, 0xffffffffffffffff
jmp 0x140003b0d
mov eax, r8d
mov qword [rsp + 0x188], r13
mul r9d
mov ecx, eax
mov rax, 0xffffffffffffffff
cmovo rcx, rax
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov r13, rax
test rax, rax
je 0x140003b65
mov r8d, dword [rsp + 0x54]
mov r9, r15
mov edx, dword [rsp + 0x50]
mov rcx, rax
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
test rax, rax
je 0x140003b65
mov eax, dword [rsp + 0x54]
mov qword [rsp + 0x1d0], rbx
mov qword [rsp + 0x1a0], rbp
test eax, eax
je 0x140003942
lea rcx, [r13 + 0x15]
mov edx, eax
nop dword [rax]
mov eax, dword [rcx - 5]
lea rcx, [rcx + 0x1e]
bswap eax
mov dword [rcx - 0x23], eax
mov eax, dword [rcx - 0x1e]
bswap eax
mov dword [rcx - 0x1e], eax
mov eax, dword [rcx - 0x19]
bswap eax
mov dword [rcx - 0x19], eax
sub rdx, 1
jne 0x140003920
mov ecx, dword [r13 + 0x15]
xor ebx, ebx
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov rbp, rax
test rax, rax
jne 0x14000396a
lea rcx, str.namebuf_allocation_error._n
call fcn.140001010
lea eax, [rbx - 2]
jmp 0x140003af5
mov edx, dword [r13 + 0x1a]
xor r8d, r8d
mov qword [rsp + 0x198], rsi
mov rcx, r15
mov qword [rsp + 0x190], rdi
mov qword [rsp + 0x180], r14
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fseek]
mov edx, dword [r13 + 0x15]
mov r9, r15
mov r8d, 1
mov rcx, rbp
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
mov r14d, 1
cmp dword [rsp + 0x54], r14d
jbe 0x140003abd
nop dword [rax]
mov eax, r14d
lea rcx, str._0.4d___0.16x__0.16x__s_n
imul rsi, rax, 0x1e
mov edi, ebx
mov edx, r14d
add rsi, r13
add rdi, rbp
mov qword [rsp + 0x20], rdi
mov r9d, dword [rsi + 0x15]
mov r8d, dword [rsi + 0x1a]
call fcn.140001010
mov r9, rdi
lea rdx, str._s__s
mov r8, r12
lea rcx, [rsp + 0x60]
call fcn.140001070
mov eax, dword [rsi + 0x15]
lea rdx, [0x1400065f8]
movsx rdi, byte [rsi + 0x14]
lea rcx, [rsp + 0x60]
shl rdi, 0x20
add rdi, rax
mov eax, dword [rsi + 0x1a]
mov dword [rsp + 0x30], eax
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fopen]
mov rcx, rdi
mov r12, rax
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov rsi, rax
test rax, rax
je 0x140003b4f
mov edx, dword [rsp + 0x30]
xor r8d, r8d
mov rcx, r15
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fseek]
mov r9, r15
mov r8d, 1
mov rdx, rdi
mov rcx, rsi
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fread]
test rax, rax
je 0x140003b3c
mov r9, r12
mov r8d, 1
mov rdx, rdi
mov rcx, rsi
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
test rax, rax
je 0x140003b29
mov rcx, rsi
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rcx, r12
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
mov eax, ebx
inc ebx
cmp byte [rax + rbp], 0
jne 0x140003aa0
mov r12, qword [rsp + 0x38]
inc r14d
cmp r14d, dword [rsp + 0x54]
jb 0x1400039c0
mov rcx, rbp
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rcx, r13
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rcx, r15
call qword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fclose]
mov eax, 1
mov rsi, qword [rsp + 0x198]
mov rdi, qword [rsp + 0x190]
mov r14, qword [rsp + 0x180]
mov rbp, qword [rsp + 0x1a0]
mov rbx, qword [rsp + 0x1d0]
mov r13, qword [rsp + 0x188]
mov rcx, qword [rsp + 0x170]
xor rcx, rsp
call fcn.140004b30
add rsp, 0x1a8
pop r15
pop r12
ret
lea rcx, str.Writing_error._n
call fcn.140001010
mov eax, 0xfffffffb
jmp 0x140003add
lea rcx, str.Reading_error._n
call fcn.140001010
mov eax, 0xfffffffc
jmp 0x140003add
lea rcx, str.Memory_allocation_error._n
call fcn.140001010
mov eax, 0xfffffffd
jmp 0x140003add
lea rcx, str.PSARC_TOC_allocation_error._n
call fcn.140001010
mov eax, 0xfffffffe
jmp 0x140003b05