//
// sub_9510E4 from 0x9510e4 to 0x95122e (330 bytes)
//
// 2 xrefs:
// > gzflush @ 0x951926
// > gzsetparams @ 0x951a22
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:05:24 +0000
//
int __fastcall sub_9510E4(_DWORD *a1, unsigned int a2)
{
int v4; // r7
int v5; // r3
_BYTE *v6; // r1
_BYTE *v7; // r2
int v8; // r5
int v9; // r5
int v10; // r3
ssize_t v12; // r0
int v13; // r0
int v14; // r5
_BOOL4 v15; // r2
_BYTE *v16; // r0
_BYTE *v17; // r1
size_t v18; // r5
_BYTE *v19; // r2
ssize_t v20; // r0
ssize_t v21; // r0
int *v22; // r0
char *v23; // r0
if ( a1[6] )
{
v4 = a1[10];
if ( !v4 )
{
LABEL_3:
v5 = a1[25];
if ( !a2 )
{
while ( 1 )
{
if ( v5 )
{
v9 = v5;
if ( deflate((int)(a1 + 21), 0) == -2 )
goto LABEL_11;
}
else
{
v6 = (_BYTE *)a1[1];
v7 = (_BYTE *)a1[24];
v8 = v7 - v6;
if ( v7 == v6 )
goto LABEL_6;
v12 = write(a1[4], v6, v7 - v6);
if ( v12 < 0 || v8 != v12 )
goto LABEL_40;
v9 = a1[25];
if ( !v9 )
{
LABEL_6:
v9 = a1[6];
v10 = a1[9];
a1[25] = v9;
a1[24] = v10;
}
else
{
v10 = a1[24];
}
a1[1] = v10;
if ( deflate((int)(a1 + 21), 0) == -2 )
goto LABEL_11;
}
v5 = a1[25];
if ( v5 == v9 )
return v4;
}
}
v13 = v4;
while ( v5 )
{
v14 = v5;
v15 = v13 == 1;
if ( a2 != 4 )
v15 = 1;
if ( !v15 )
goto LABEL_25;
v16 = (_BYTE *)a1[24];
v17 = (_BYTE *)a1[1];
v18 = v16 - v17;
if ( v16 != v17 )
goto LABEL_31;
v14 = v5;
LABEL_24:
a1[1] = v16;
LABEL_25:
v13 = deflate((int)(a1 + 21), a2);
if ( v13 == -2 )
{
LABEL_11:
sub_950728(a1, -2, "internal error: deflate stream corrupt");
return -1;
}
v5 = a1[25];
if ( v5 == v14 )
{
if ( a2 == 4 )
deflateReset(a1 + 21);
return v4;
}
}
v17 = (_BYTE *)a1[1];
v19 = (_BYTE *)a1[24];
v18 = v19 - v17;
if ( v19 != v17 )
{
LABEL_31:
v20 = write(a1[4], v17, v18);
if ( v20 < 0 || v20 != v18 )
goto LABEL_40;
v14 = a1[25];
if ( v14 )
{
v16 = (_BYTE *)a1[24];
goto LABEL_24;
}
}
v14 = a1[6];
v16 = (_BYTE *)a1[9];
a1[25] = v14;
a1[24] = v16;
goto LABEL_24;
}
}
else
{
v4 = sub_951010((int)a1);
if ( v4 == -1 )
return v4;
v4 = a1[10];
if ( !v4 )
goto LABEL_3;
}
v21 = write(a1[4], (const void *)a1[21], a1[22]);
if ( v21 >= 0 && v21 == a1[22] )
{
v4 = 0;
a1[22] = 0;
return v4;
}
LABEL_40:
v22 = (int *)_errno();
v23 = strerror(*v22);
sub_950728(a1, -1, v23);
return -1;
}