//
// gzflush from 0x741cb4 to 0x741e1a (358 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall gzflush(int a1, unsigned int a2)
{
int v4; // r2
int v5; // r8
int v6; // r2
unsigned int v7; // r3
int v8; // r7
size_t v9; // r7
int v10; // r1
int v11; // r2
int v12; // r3
_BYTE *v13; // r1
_BYTE *v14; // r2
int v15; // r5
int v16; // r5
int v17; // r3
ssize_t v19; // r0
ssize_t v20; // r0
int *v21; // r0
char *v22; // r0
if ( !a1 )
return -1;
if ( *(_DWORD *)(a1 + 12) != 31153 || *(_DWORD *)(a1 + 76) || a2 > 4 )
return -2;
if ( !*(_DWORD *)(a1 + 72) )
goto LABEL_25;
v4 = *(_DWORD *)(a1 + 88);
*(_DWORD *)(a1 + 72) = 0;
v5 = *(_DWORD *)(a1 + 68);
if ( v4 && sub_741674(a1) == -1 )
return -1;
v6 = 1;
if ( !v5 )
goto LABEL_25;
while ( 1 )
{
LABEL_8:
v7 = *(_DWORD *)(a1 + 24);
v8 = v7 >> 31;
if ( (int)v7 > v5 )
v8 = 1;
v9 = v8 ? v5 : *(_DWORD *)(a1 + 24);
if ( v6 )
{
memset(*(void **)(a1 + 32), 0, v9);
v7 = *(_DWORD *)(a1 + 24);
}
v10 = *(_DWORD *)(a1 + 32);
v11 = *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 88) = v9;
*(_DWORD *)(a1 + 84) = v10;
*(_DWORD *)(a1 + 8) = v11 + v9;
if ( !v7 )
break;
if ( !*(_DWORD *)(a1 + 40) )
goto LABEL_17;
LABEL_35:
v20 = write(*(_DWORD *)(a1 + 16), *(const void **)(a1 + 84), *(_DWORD *)(a1 + 88));
if ( v20 < 0 || v20 != *(_DWORD *)(a1 + 88) )
{
LABEL_39:
v21 = (int *)_errno();
v22 = strerror(*v21);
sub_740B68((_DWORD *)a1, -1, v22);
return -1;
}
v5 -= v9;
*(_DWORD *)(a1 + 88) = 0;
v6 = 0;
if ( !v5 )
goto LABEL_25;
}
if ( sub_741450(a1) == -1 )
return -1;
if ( *(_DWORD *)(a1 + 40) )
goto LABEL_35;
LABEL_17:
v12 = *(_DWORD *)(a1 + 100);
do
{
if ( v12 )
{
v16 = v12;
}
else
{
v13 = *(_BYTE **)(a1 + 4);
v14 = *(_BYTE **)(a1 + 96);
v15 = v14 - v13;
if ( v14 == v13 )
goto LABEL_20;
v19 = write(*(_DWORD *)(a1 + 16), v13, v14 - v13);
if ( v19 < 0 || v15 != v19 )
goto LABEL_39;
v16 = *(_DWORD *)(a1 + 100);
if ( !v16 )
{
LABEL_20:
v16 = *(_DWORD *)(a1 + 24);
v17 = *(_DWORD *)(a1 + 36);
*(_DWORD *)(a1 + 100) = v16;
*(_DWORD *)(a1 + 96) = v17;
}
else
{
v17 = *(_DWORD *)(a1 + 96);
}
*(_DWORD *)(a1 + 4) = v17;
}
if ( deflate(a1 + 84, 0) == -2 )
{
sub_740B68((_DWORD *)a1, -2, "internal error: deflate stream corrupt");
return -1;
}
v12 = *(_DWORD *)(a1 + 100);
}
while ( v12 != v16 );
v5 -= v9;
v6 = 0;
if ( v5 )
goto LABEL_8;
LABEL_25:
sub_741524((_DWORD *)a1, a2);
return *(_DWORD *)(a1 + 76);
}