Function at 0x406e40
Capabilities:
Write file on windows

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x58
mov eax, dword [0x58fa50]
xor eax, ebp
mov dword [ebp - 8], eax
push ebx
push esi
mov esi, dword [ebp + 0xc]
mov ebx, edx
push edi
mov edi, dword [ebp + 0x10]
mov dword [ebp - 0x48], 0
cmp ebx, 8
jne 0x406e6e
mov dword [ebp - 0x48], 0x400
mov eax, esi
imul eax, ebx
cdq
and edx, 7
add eax, edx
sar eax, 3
add eax, 3
cdq
and edx, 3
add eax, edx
sar eax, 2
add eax, eax
add eax, eax
push 0x567f58
push ecx
mov dword [ebp - 0x50], eax
call fcn.00514e5a
add esp, 8
mov dword [ebp - 0x58], eax
test eax, eax
jne 0x406eb9
xor al, al
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 8]
xor ecx, ebp
call fcn.005149e7
mov esp, ebp
pop ebp
ret 0xc
mov edx, dword [ebp - 0x48]
mov ecx, 0x4d42
mov word [ebp - 0x18], cx
mov ecx, edi
imul ecx, dword [ebp - 0x50]
mov dword [ebp - 0x50], ecx
lea ecx, [ecx + edx + 0x36]
push eax
add edx, 0x36
push 1
mov dword [ebp - 0xe], edx
mov dword [ebp - 0x16], ecx
xor ecx, ecx
lea edx, [ebp - 0x18]
push 0xe
push edx
mov word [ebp - 0x12], cx
mov word [ebp - 0x10], cx
call fcn.00514fc8
mov edx, dword [ebp - 0x50]
xor eax, eax
mov dword [ebp - 0x1c], eax
mov dword [ebp - 0x20], eax
mov dword [ebp - 0x30], eax
mov dword [ebp - 0x28], eax
mov dword [ebp - 0x24], eax
mov eax, dword [ebp - 0x58]
push eax
mov ecx, 1
push ecx
mov word [ebp - 0x34], cx
lea ecx, [ebp - 0x40]
push 0x28
push ecx
mov word [ebp - 0x32], bx
mov dword [ebp - 0x38], edi
mov dword [ebp - 0x40], 0x28
mov dword [ebp - 0x2c], edx
mov dword [ebp - 0x3c], esi
call fcn.00514fc8
push 0x400
call fcn.00515042
add esp, 0x24
mov edx, eax
mov dword [ebp - 0x44], edx
cmp ebx, 8
jne 0x406f7e
xor eax, eax
lea ecx, [edx + 2]
mov byte [ecx - 2], al
mov byte [ecx - 1], al
mov byte [ecx], al
mov byte [ecx + 1], 0
inc eax
add ecx, 4
cmp eax, 0x100
jl 0x406f50
mov eax, dword [ebp - 0x58]
push eax
push pe_nt_image_headers32
push 4
push edx
call fcn.00514fc8
mov edx, dword [ebp - 0x44]
add esp, 0x10
push edx
call fcn.005150d6
mov eax, edi
imul eax, esi
lea eax, [eax + eax*2]
push eax
mov dword [ebp - 0x44], eax
call fcn.00515042
mov ecx, dword [ebp - 0x44]
push ecx
push 0
push eax
mov dword [ebp - 0x48], eax
call fcn.00516de0
add esp, 0x14
cmp ebx, 0x18
jne 0x406ffe
test edi, edi
jle 0x407047
mov edx, dword [ebp - 0x48]
lea ecx, [edi + edi*2 - 3]
imul ecx, esi
lea eax, [esi*4]
sub eax, esi
neg eax
add ecx, dword [ebp + 8]
lea ebx, [esi + esi*2]
mov dword [ebp - 0x54], ebx
mov dword [ebp - 0x44], eax
mov dword [ebp - 0x4c], edi
test ebx, ebx
jle 0x406ff3
mov esi, ecx
mov eax, edx
sub esi, edx
mov edi, ebx
mov bl, byte [esi + eax]
mov byte [eax], bl
inc eax
dec edi
jne 0x406fe4
mov eax, dword [ebp - 0x44]
mov ebx, dword [ebp - 0x54]
add edx, ebx
add ecx, eax
dec dword [ebp - 0x4c]
jne 0x406fd8
jmp 0x407047
cmp ebx, 8
jne 0x407047
test edi, edi
jle 0x407047
mov edx, dword [ebp - 0x48]
lea ecx, [edi - 1]
imul ecx, esi
mov eax, esi
neg eax
add ecx, dword [ebp + 8]
mov dword [ebp - 0x54], eax
mov dword [ebp - 0x44], edi
test esi, esi
jle 0x40703e
mov edi, ecx
mov eax, edx
sub edi, edx
mov dword [ebp - 0x4c], esi
lea ebx, [ebx]
mov bl, byte [edi + eax]
mov byte [eax], bl
inc eax
dec dword [ebp - 0x4c]
jne 0x407030
mov eax, dword [ebp - 0x54]
add edx, esi
add ecx, eax
dec dword [ebp - 0x44]
jne 0x40701d
mov edi, dword [ebp - 0x58]
mov edx, dword [ebp - 0x50]
mov esi, dword [ebp - 0x48]
push edi
push 1
push edx
push esi
call fcn.00514fc8
push edi
call fcn.0051517d
push esi
call fcn.005150d6
mov ecx, dword [ebp - 8]
add esp, 0x18
pop edi
pop esi
xor ecx, ebp
mov al, 1
pop ebx
call fcn.005149e7
mov esp, ebp
pop ebp
ret 0xc