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

Disassembly:
push ebp
mov ebp, esp
push edi
push esi
push ebx
and esp, 0xfffffff0
sub esp, 0x50
mov edi, dword [ebp + 8]
call dbg.__main
mov dword [esp], str.ZX0_v1.5:_Optimal_data_compressor_by_Einar_Saukas
call sym._puts
cmp edi, 1
jle 0x4036d5
mov eax, dword [ebp + 0xc]
mov ebx, 1
xor edx, edx
mov dword [esp + 0x30], 0
mov dword [esp + 0x34], 0
mov dword [esp + 0x38], 0
lea esi, [eax + 4]
jmp 0x40329a
mov dword [esp], eax
mov dword [esp + 0x3c], edx
call sym._atoi
mov edx, dword [esp + 0x3c]
test eax, eax
mov dword [esp + 0x38], eax
jle 0x40372e
lea esi, [esi]
add ebx, 1
add esi, 4
cmp edi, ebx
je 0x4032f0
mov eax, dword [esi]
movzx ecx, byte [eax]
sub ecx, 0x2b
and ecx, 0xfd
jne 0x4032f0
movzx ecx, byte [eax]
cmp ecx, 0x2d
jne 0x403270
cmp byte [eax + 1], 0x66
je 0x4034f0
cmp ecx, 0x2d
jne 0x403270
cmp byte [eax + 1], 0x71
je 0x403508
cmp ecx, 0x2d
jne 0x403270
cmp byte [eax + 1], 0x62
jne 0x403270
cmp byte [eax + 2], 0
jne 0x403270
add ebx, 1
mov dword [esp + 0x30], 1
add esi, 4
cmp edi, ebx
jne 0x40329a
nop
lea eax, [ebx + 1]
mov dword [esp + 0x28], edx
cmp eax, edi
je 0x403687
lea eax, [ebx + 2]
cmp eax, edi
mov eax, dword [ebp + 0xc]
jne 0x4036ff
mov eax, dword [eax + ebx*4 + 4]
mov dword [esp + 0x2c], eax
mov eax, dword [ebp + 0xc]
mov dword [esp + 4], 0x40513f
lea eax, [eax + ebx*4]
mov dword [esp + 0x24], eax
mov eax, dword [eax]
mov dword [esp], eax
call sym._fopen
mov ebx, eax
test eax, eax
je 0x403860
mov dword [esp + 8], 2
mov dword [esp + 4], 0
mov dword [esp], eax
call sym._fseek
mov dword [esp], ebx
call sym._ftell
mov dword [esp + 8], 0
mov dword [esp + 4], 0
mov esi, eax
mov dword [esp], ebx
call sym._fseek
test esi, esi
je 0x40382d
cmp esi, dword [esp + 0x38]
jle 0x4037fa
mov dword [esp], esi
call sym._malloc
mov dword [esp + 0x3c], eax
test eax, eax
je 0x4037c1
xor edi, edi
lea esi, [esi]
mov eax, esi
mov dword [esp + 0xc], ebx
sub eax, edi
mov dword [esp + 4], 1
mov dword [esp + 8], eax
mov eax, dword [esp + 0x3c]
add eax, edi
mov dword [esp], eax
call sym._fread
add edi, eax
test eax, eax
jg 0x4033a0
cmp esi, edi
jne 0x40375d
mov dword [esp], ebx
call sym._fclose
mov ecx, dword [esp + 0x28]
test ecx, ecx
je 0x403620
mov eax, dword [esp + 0x2c]
mov dword [esp + 4], 0x405214
mov dword [esp], eax
call sym._fopen
mov ebx, eax
test eax, eax
je 0x403790
mov edx, dword [esp + 0x30]
test edx, edx
jne 0x40351f
cmp dword [esp + 0x34], 0
jne 0x40367a
mov dword [esp + 0xc], 0x7f80
mov esi, dword [esp + 0x38]
mov eax, dword [esp + 0x3c]
mov dword [esp + 4], edi
mov dword [esp + 8], esi
mov dword [esp], eax
call dbg.optimize
mov edx, dword [esp + 0x3c]
lea ecx, [esp + 0x4c]
mov dword [esp + 0x10], 0
mov dword [esp + 0x18], ecx
lea ecx, [esp + 0x48]
mov dword [esp + 0x14], ecx
mov dword [esp + 0xc], esi
mov dword [esp + 8], edi
mov dword [esp + 4], edx
mov dword [esp], eax
call dbg.compress
mov ecx, dword [esp + 0x48]
mov dword [esp + 0xc], ebx
mov dword [esp + 4], 1
mov dword [esp + 8], ecx
mov dword [esp], eax
call sym._fwrite
cmp eax, dword [esp + 0x48]
jne 0x403893
mov dword [esp], ebx
call sym._fclose
mov esi, dword [esp + 0x4c]
mov ebx, dword [esp + 0x48]
mov edx, edi
mov ecx, 0x405047
sub edx, dword [esp + 0x38]
mov eax, dword [esp + 0x38]
mov edi, 0x405047
mov dword [esp + 0x14], esi
mov dword [esp + 0x10], ebx
test eax, eax
mov eax, str._partially
mov dword [esp + 0xc], edx
cmove eax, edi
mov dword [esp + 8], ecx
mov dword [esp], str.File_s_compressed_s_from__d_to__d_bytes___delta__d__n
mov dword [esp + 4], eax
call sym._printf
lea esp, [ebp - 0xc]
xor eax, eax
pop ebx
pop esi
pop edi
pop ebp
ret
cmp byte [eax + 2], 0
jne 0x4032bc
mov edx, 1
jmp 0x403290
cmp byte [eax + 2], 0
jne 0x4032cb
mov dword [esp + 0x34], 1
jmp 0x403290
mov edx, dword [esp + 0x3c]
lea eax, [edx + esi - 1]
cmp eax, edx
jbe 0x403548
mov ecx, edx
mov esi, ebx
nop
movzx edx, byte [ecx]
movzx ebx, byte [eax]
add ecx, 1
sub eax, 1
mov byte [ecx - 1], bl
mov byte [eax + 1], dl
cmp ecx, eax
jb 0x403530
mov ebx, esi
cmp dword [esp + 0x34], 0
je 0x40366d
mov dword [esp + 0xc], 0x880
mov esi, dword [esp + 0x38]
mov eax, dword [esp + 0x3c]
mov dword [esp + 4], edi
mov dword [esp + 8], esi
mov dword [esp], eax
call dbg.optimize
mov edx, dword [esp + 0x3c]
lea ecx, [esp + 0x4c]
mov dword [esp + 0x10], 1
mov dword [esp + 0x18], ecx
lea ecx, [esp + 0x48]
mov dword [esp + 0x14], ecx
mov dword [esp + 4], edx
mov dword [esp + 0xc], esi
mov dword [esp + 8], edi
mov dword [esp], eax
call dbg.compress
mov edx, eax
mov eax, dword [esp + 0x48]
lea ecx, [edx + eax - 1]
cmp ecx, edx
jbe 0x4035de
mov dword [esp + 0x3c], edx
mov esi, edx
lea esi, [esi]
nop
movzx eax, byte [esi]
movzx edx, byte [ecx]
add esi, 1
sub ecx, 1
mov byte [esi - 1], dl
mov byte [ecx + 1], al
cmp esi, ecx
jb 0x4035c0
mov edx, dword [esp + 0x3c]
mov eax, dword [esp + 0x48]
mov dword [esp + 0xc], ebx
mov dword [esp + 8], eax
mov dword [esp + 4], 1
mov dword [esp], edx
call sym._fwrite
cmp eax, dword [esp + 0x48]
jne 0x403893
mov dword [esp], ebx
call sym._fclose
mov edx, edi
mov esi, dword [esp + 0x4c]
mov ebx, dword [esp + 0x48]
sub edx, dword [esp + 0x38]
mov ecx, str._backwards
jmp 0x4034aa
mov eax, dword [esp + 0x2c]
mov dword [esp + 4], 0x40513f
mov dword [esp], eax
call sym._fopen
test eax, eax
je 0x4033e4
mov dword [esp], 2
call dword [0x40401c]
mov edx, dword [esp + 0x2c]
mov dword [esp + 4], str.Error:_Already_existing_output_file__s_n
mov dword [esp], eax
mov dword [esp + 8], edx
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov dword [esp + 0xc], 0x7f80
jmp 0x40355b
mov dword [esp + 0xc], 0x880
jmp 0x403421
mov eax, dword [ebp + 0xc]
or ecx, 0xffffffff
mov edx, dword [eax + ebx*4]
xor eax, eax
mov dword [esp + 0x3c], edx
mov edi, edx
repne scasb al, byte es:[edi]
not ecx
lea esi, [ecx - 1]
add ecx, 4
mov dword [esp], ecx
call sym._malloc
mov edx, dword [esp + 0x3c]
mov dword [esp + 8], esi
mov dword [esp], eax
mov edi, eax
mov dword [esp + 4], edx
add esi, edi
mov dword [esp + 0x2c], eax
call sym._memcpy
mov dword [esi], 0x30787a2e
mov byte [esi + 4], 0
jmp 0x403315
mov dword [esp + 0x28], 0
mov ebx, 1
mov dword [esp + 0x34], 0
mov dword [esp + 0x38], 0
mov dword [esp + 0x30], 0
jmp 0x4032ff
mov ebx, dword [eax]
mov dword [esp], 2
call dword [0x40401c]
mov dword [esp + 4], str.Usage:__s___f____b____q__input__output.zx0__n___f______Force_overwrite_of_output_file_n___b______Compress_backwards_n___q______Quick_non_optimal_compression_n
mov dword [esp + 8], ebx
mov dword [esp], eax
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov ebx, dword [esi]
mov dword [esp], 2
call dword [0x40401c]
mov dword [esp + 4], str.Error:_Invalid_parameter__s_n
mov dword [esp + 8], ebx
mov dword [esp], eax
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov eax, dword [esp + 0x24]
mov ebx, dword [eax]
mov dword [esp], 2
call dword [0x40401c]
mov dword [esp + 4], str.Error:_Cannot_read_input_file__s_n
mov dword [esp + 8], ebx
mov dword [esp], eax
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov dword [esp], 2
call dword [0x40401c]
mov edx, dword [esp + 0x2c]
mov dword [esp + 4], str.Error:_Cannot_create_output_file__s_n
mov dword [esp], eax
mov dword [esp + 8], edx
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov dword [esp], 2
call dword [0x40401c]
mov dword [esp + 8], 0x1b
mov dword [esp + 0xc], eax
mov dword [esp + 4], 1
mov dword [esp], 0x4051aa
call sym._fwrite
mov dword [esp], 1
call sym._exit
mov eax, dword [esp + 0x24]
mov ebx, dword [eax]
mov dword [esp], 2
call dword [0x40401c]
mov dword [esp + 4], str.Error:_Skipping_entire_input_file__s_n
mov dword [esp + 8], ebx
mov dword [esp], eax
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov eax, dword [esp + 0x24]
mov ebx, dword [eax]
mov dword [esp], 2
call dword [0x40401c]
mov dword [esp + 4], str.Error:_Empty_input_file__s_n
mov dword [esp + 8], ebx
mov dword [esp], eax
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov eax, dword [esp + 0x24]
mov ebx, dword [eax]
mov dword [esp], 2
call dword [0x40401c]
mov dword [esp + 4], str.Error:_Cannot_access_input_file__s_n
mov dword [esp + 8], ebx
mov dword [esp], eax
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov dword [esp], 2
call dword [0x40401c]
mov edx, dword [esp + 0x2c]
mov dword [esp + 4], str.Error:_Cannot_write_output_file__s_n
mov dword [esp], eax
mov dword [esp + 8], edx
call sym._fprintf
mov dword [esp], 1
call sym._exit
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop