//
// gzsetparams from 0x741e20 to 0x741fb8 (408 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 gzsetparams(_DWORD *a1, unsigned int a2, unsigned int a3)
{
int v3; // r5
int v4; // r9
int v5; // r4
unsigned int v6; // r10
unsigned int v7; // r8
int v9; // r3
signed int v10; // r7
int v11; // r2
signed int v12; // r3
int v13; // r6
size_t v14; // r6
int v15; // r1
int v16; // r2
int v17; // r3
_BYTE *v18; // r1
_BYTE *v19; // r2
int v20; // r11
int v21; // r11
int v22; // r3
ssize_t v23; // r0
ssize_t v24; // r0
int *v25; // r0
char *v26; // r0
if ( !a1 )
return -2;
v3 = (int)(a1 + 21);
if ( a1[3] != 31153 )
return -2;
v4 = a1[19];
if ( v4 )
return -2;
if ( a1[15] == a2 )
{
if ( a1[16] == a3 )
return v4;
v5 = (int)a1;
v6 = a3;
v7 = a2;
if ( !a1[18] )
goto LABEL_6;
}
else
{
v5 = (int)a1;
v6 = a3;
v7 = a2;
if ( !a1[18] )
goto LABEL_6;
}
v9 = a1[22];
v10 = a1[17];
a1[18] = 0;
if ( v9 && sub_741674((int)a1) == -1 )
return -1;
v11 = 1;
if ( !v10 )
goto LABEL_6;
while ( 1 )
{
LABEL_17:
v12 = *(_DWORD *)(v5 + 24);
v13 = (unsigned int)v12 >> 31;
if ( v12 > v10 )
v13 = 1;
if ( v13 )
v14 = v10;
else
v14 = *(_DWORD *)(v5 + 24);
if ( v11 )
{
memset(*(void **)(v5 + 32), 0, v14);
v12 = *(_DWORD *)(v5 + 24);
}
v15 = *(_DWORD *)(v5 + 32);
v16 = *(_DWORD *)(v5 + 8);
*(_DWORD *)(v5 + 88) = v14;
*(_DWORD *)(v5 + 84) = v15;
*(_DWORD *)(v5 + 8) = v16 + v14;
if ( v12 )
{
if ( !*(_DWORD *)(v5 + 40) )
break;
goto LABEL_44;
}
if ( sub_741450(v5) == -1 )
return -1;
if ( !*(_DWORD *)(v5 + 40) )
break;
LABEL_44:
v24 = write(*(_DWORD *)(v5 + 16), *(const void **)(v5 + 84), *(_DWORD *)(v5 + 88));
if ( v24 < 0 || v24 != *(_DWORD *)(v5 + 88) )
{
LABEL_48:
v25 = (int *)_errno();
v26 = strerror(*v25);
sub_740B68((_DWORD *)v5, -1, v26);
return -1;
}
v10 -= v14;
v11 = 0;
*(_DWORD *)(v5 + 88) = 0;
if ( !v10 )
goto LABEL_6;
}
v17 = *(_DWORD *)(v5 + 100);
do
{
if ( v17 )
{
v21 = v17;
}
else
{
v18 = *(_BYTE **)(v5 + 4);
v19 = *(_BYTE **)(v5 + 96);
v20 = v19 - v18;
if ( v19 == v18 )
goto LABEL_29;
v23 = write(*(_DWORD *)(v5 + 16), v18, v19 - v18);
if ( v23 < 0 || v20 != v23 )
goto LABEL_48;
v21 = *(_DWORD *)(v5 + 100);
if ( !v21 )
{
LABEL_29:
v21 = *(_DWORD *)(v5 + 24);
v22 = *(_DWORD *)(v5 + 36);
*(_DWORD *)(v5 + 100) = v21;
*(_DWORD *)(v5 + 96) = v22;
}
else
{
v22 = *(_DWORD *)(v5 + 96);
}
*(_DWORD *)(v5 + 4) = v22;
}
if ( deflate(v3, 0) == -2 )
{
sub_740B68((_DWORD *)v5, -2, "internal error: deflate stream corrupt");
return -1;
}
v17 = *(_DWORD *)(v5 + 100);
}
while ( v17 != v21 );
v10 -= v14;
v11 = 0;
if ( v10 )
goto LABEL_17;
LABEL_6:
if ( !*(_DWORD *)(v5 + 24) )
{
LABEL_11:
*(_DWORD *)(v5 + 60) = v7;
*(_DWORD *)(v5 + 64) = v6;
return v4;
}
if ( !*(_DWORD *)(v5 + 88) || sub_741524((_DWORD *)v5, 1u) != -1 )
{
deflateParams(v3, v7, v6);
goto LABEL_11;
}
return *(_DWORD *)(v5 + 76);
}