Function at 0x51b170
Capabilities:
Write file on windows

Disassembly:
push ebp
mov ebp, esp
sub esp, 8
push ebx
mov ebx, dword [ebp + 8]
push esi
push edi
test ebx, ebx
js 0x51b3b0
mov edi, dword [0x7f9d48]
mov dl, bl
mov esi, dword [0x7f9d48]
and esi, 7
sar edi, 3
add edi, 0x8012ac
mov ecx, esi
shl dl, cl
mov ecx, 8
sub ecx, esi
and dl, byte [esi + 0x5ed068]
mov al, byte [esi + 0x5ed074]
and al, byte [edi]
or dl, al
sar ebx, cl
mov byte [edi], dl
inc edi
mov dword [ebp - 8], edi
mov edi, dword [0x7f9d4c]
mov eax, dword [ebp - 8]
lea edx, [edi - 8]
add edx, esi
cmp edx, 8
jl 0x51b1dd
mov byte [eax], bl
inc eax
sar ebx, 8
sub edx, 8
test edx, edx
je 0x51b1e3
mov byte [eax], bl
mov ecx, dword [0x7f9d48]
lea eax, [edi*8]
mov ebx, dword [ebp + 0xc]
add ecx, edi
mov dword [0x7f9d48], ecx
cmp ecx, eax
jne 0x51b25c
add dword [0x8012a4], edi
mov esi, 0x8012ac
mov ecx, dword [0x5ed084]
mov edx, dword [0x8012c0]
mov al, byte [esi]
lea esi, [esi + 1]
inc edx
mov byte [ecx], al
inc ecx
mov dword [0x8012c0], edx
mov dword [0x5ed084], ecx
cmp edx, 0x100000
jne 0x51b249
push ebx
call dword [0x8012cc]
mov ecx, dword [0x5ed084]
add esp, 4
mov edx, dword [0x8012c0]
sub edi, 1
jne 0x51b216
mov dword [0x7f9d48], edi
xor ecx, ecx
mov edi, dword [0x7f9d4c]
mov eax, dword [0x7f9d54]
cmp eax, dword [0x7f9d50]
mov eax, dword [0x7feb84]
jg 0x51b276
test eax, eax
jle 0x51b48d
test ecx, ecx
jle 0x51b347
push ebx
call dword [0x8012cc]
mov edi, dword [ebx]
add esp, 4
test edi, edi
jne 0x51b2dc
mov ecx, dword [ebx + 8]
mov edi, dword [0x7f9d4c]
mov edx, dword [ebx + 0x14]
lea eax, [ecx + edi]
cmp eax, edx
jle 0x51b2c3
lea eax, [edx + 0x6400000]
push eax
push dword [ebx + 0x10]
mov dword [ebx + 0x14], eax
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_realloc]
mov ecx, dword [ebx + 8]
add esp, 8
mov edi, dword [0x7f9d4c]
mov dword [ebx + 0x10], eax
mov eax, dword [ebx + 0x10]
push edi
add eax, ecx
push 0x8012ac
push eax
call sub.VCRUNTIME140.dll_memcpy
add esp, 0xc
add dword [ebx + 8], edi
jmp 0x51b33c
mov eax, dword [0x7f9d4c]
lea edx, [ebp + 8]
mov dword [ebp + 8], eax
lea esi, [ebp + 0xb]
nop word [eax + eax]
mov al, byte [esi]
mov cl, byte [edx]
mov byte [edx], al
inc edx
mov byte [esi], cl
dec esi
cmp edx, esi
jb 0x51b2f0
mov esi, dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
lea eax, [ebp + 8]
push edi
push 1
push 4
push eax
call esi
push dword [ebx]
push dword [0x7f9d4c]
push 1
push 0x8012ac
call esi
mov edi, dword [0x7f9d4c]
xor edx, edx
mov ecx, dword [0x8012b8]
add esp, 0x20
cmp eax, edi
cmovne ecx, edx
mov dword [0x8012b8], ecx
add dword [0x8012a4], edi
mov eax, dword [0x7feb84]
mov dword [0x7f9d48], 0
test eax, eax
je 0x51b37a
pop edi
pop esi
mov dword [0x7f9d4c], 9
mov dword [0x7f9d50], 0x1ff
mov dword [0x7feb84], 0
pop ebx
mov esp, ebp
pop ebp
ret
lea ecx, [edi + 1]
mov dword [0x7f9d4c], ecx
cmp ecx, dword [0x5ed050]
jne 0x51b39c
mov eax, dword [0x5ed054]
pop edi
pop esi
mov dword [0x7f9d50], eax
pop ebx
mov esp, ebp
pop ebp
ret
mov eax, 1
pop edi
shl eax, cl
dec eax
pop esi
mov dword [0x7f9d50], eax
pop ebx
mov esp, ebp
pop ebp
ret
mov ecx, dword [0x7f9d48]
mov edi, dword [ebp + 0xc]
lea eax, [ecx + 7]
cdq
and edx, 7
lea ebx, [edx + eax]
sar ebx, 3
test ecx, ecx
jle 0x51b473
cmp dword [0x8012c0], 0
jle 0x51b3e1
push edi
call dword [0x8012cc]
add esp, 4
cmp dword [edi], 0
jne 0x51b428
mov ecx, dword [edi + 8]
mov edx, dword [edi + 0x14]
lea eax, [ecx + ebx]
cmp eax, edx
jle 0x51b40f
lea eax, [edx + 0x6400000]
push eax
push dword [edi + 0x10]
mov dword [edi + 0x14], eax
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_realloc]
mov ecx, dword [edi + 8]
add esp, 8
mov dword [edi + 0x10], eax
mov eax, dword [edi + 0x10]
push ebx
add eax, ecx
push 0x8012ac
push eax
call sub.VCRUNTIME140.dll_memcpy
add esp, 0xc
add dword [edi + 8], ebx
jmp 0x51b473
mov dword [ebp - 4], ebx
lea edx, [ebp - 4]
lea esi, [ebp - 1]
mov al, byte [esi]
mov cl, byte [edx]
mov byte [edx], al
inc edx
mov byte [esi], cl
dec esi
cmp edx, esi
jb 0x51b431
push dword [edi]
mov esi, dword [sym.imp.api_ms_win_crt_stdio_l1_1_0.dll_fwrite]
lea eax, [ebp - 4]
push 1
push 4
push eax
call esi
push dword [edi]
push ebx
push 1
push 0x8012ac
call esi
mov ecx, dword [0x8012b8]
xor edx, edx
add esp, 0x20
cmp eax, ebx
cmovne ecx, edx
mov dword [0x8012b8], ecx
add dword [0x8012a4], ebx
push edi
mov dword [0x7f9d48], 0
call dword [0x8012cc]
add esp, 4
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret