Function at 0x40d586
Capabilities:
Write file on windows

Disassembly:
mov edi, edi
push ebp
mov ebp, esp
sub esp, 0x30
mov ecx, dword [ebp + 0x10]
mov eax, dword [ebp + 0xc]
mov dword [ebp - 8], eax
mov dword [ebp - 0xc], ecx
push ebx
mov ebx, dword [ebp + 0x14]
push esi
push edi
mov edi, dword [ebp + 8]
test ecx, ecx
je 0x40d77f
test eax, eax
jne 0x40d5d9
xor eax, eax
mov byte [ebx + 0x24], 1
push ebx
push eax
push eax
push eax
mov dword [ebx + 0x20], eax
push eax
mov byte [ebx + 0x1c], 1
push eax
mov dword [ebx + 0x18], 0x16
call fcn.004076fa
add esp, 0x18
or eax, 0xffffffff
jmp 0x40d781
mov eax, edi
mov esi, edi
and eax, 0x3f
sar esi, 6
imul edx, eax, 0x38
mov dword [ebp - 0x10], esi
mov eax, dword [esi*4 + 0x41bfb8]
mov dword [ebp - 0x30], eax
mov dword [ebp - 0x14], edx
mov al, byte [edx + eax + 0x29]
mov byte [ebp - 1], al
cmp al, 2
je 0x40d605
cmp al, 1
jne 0x40d60d
mov eax, ecx
not eax
test al, 1
je 0x40d5af
mov eax, dword [ebp - 0x30]
xor esi, esi
test byte [edx + eax + 0x28], 0x20
je 0x40d627
push ebx
push 2
push esi
push esi
push edi
call fcn.00410817
add esp, 0x14
push ebx
push edi
call fcn.0040d10a
pop ecx
pop ecx
test al, al
je 0x40d674
mov al, byte [ebp - 1]
test al, al
je 0x40d65e
dec al
cmp al, 1
ja 0x40d747
push dword [ebp - 0xc]
lea eax, [ebp - 0x2c]
push dword [ebp - 8]
push eax
call fcn.0040d0a2
add esp, 0xc
mov esi, eax
jmp 0x40d705
push ebx
push dword [ebp - 0xc]
lea eax, [ebp - 0x2c]
push dword [ebp - 8]
push edi
push eax
call fcn.0040ccd0
add esp, 0x14
jmp 0x40d657
mov eax, dword [ebp - 0x10]
mov ecx, dword [eax*4 + 0x41bfb8]
mov eax, dword [ebp - 0x14]
cmp byte [eax + ecx + 0x28], 0
jge 0x40d6d7
movsx eax, byte [ebp - 1]
sub eax, esi
je 0x40d6c5
sub eax, 1
je 0x40d6b3
sub eax, 1
jne 0x40d747
push dword [ebp - 0xc]
lea eax, [ebp - 0x2c]
push dword [ebp - 8]
push edi
push eax
call fcn.0040d263
add esp, 0x10
jmp 0x40d657
push dword [ebp - 0xc]
lea eax, [ebp - 0x2c]
push dword [ebp - 8]
push edi
push eax
call fcn.0040d34c
jmp 0x40d6ae
push dword [ebp - 0xc]
lea eax, [ebp - 0x2c]
push dword [ebp - 8]
push edi
push eax
call fcn.0040d188
jmp 0x40d6ae
mov ecx, dword [eax + ecx + 0x18]
lea edi, [ebp - 0x2c]
xor eax, eax
stosd dword es:[edi], eax
push esi
stosd dword es:[edi], eax
stosd dword es:[edi], eax
lea eax, [ebp - 0x28]
push eax
push dword [ebp - 0xc]
push dword [ebp - 8]
push ecx
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
jne 0x40d702
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov dword [ebp - 0x2c], eax
lea esi, [ebp - 0x2c]
lea edi, [ebp - 0x20]
movsd dword es:[edi], dword [esi]
movsd dword es:[edi], dword [esi]
movsd dword es:[edi], dword [esi]
mov eax, dword [ebp - 0x1c]
test eax, eax
jne 0x40d77a
mov eax, dword [ebp - 0x20]
test eax, eax
je 0x40d745
push 5
pop ecx
cmp eax, ecx
jne 0x40d737
mov byte [ebx + 0x1c], 1
mov dword [ebx + 0x18], 9
mov byte [ebx + 0x24], 1
mov dword [ebx + 0x20], ecx
jmp 0x40d5d1
push ebx
push eax
call fcn.00407821
pop ecx
pop ecx
jmp 0x40d5d1
xor esi, esi
mov eax, dword [ebp - 0x10]
mov ecx, dword [ebp - 0x14]
mov eax, dword [eax*4 + 0x41bfb8]
test byte [ecx + eax + 0x28], 0x40
je 0x40d763
mov eax, dword [ebp - 8]
cmp byte [eax], 0x1a
je 0x40d77f
mov byte [ebx + 0x1c], 1
mov dword [ebx + 0x18], 0x1c
mov byte [ebx + 0x24], 1
mov dword [ebx + 0x20], esi
jmp 0x40d5d1
sub eax, dword [ebp - 0x18]
jmp 0x40d781
xor eax, eax
pop edi
pop esi
pop ebx
leave
ret