//
// sub_1002DB978 from 0x1002db978 to 0x1002dbac8 (336 bytes)
//
// 1 xrefs:
// > sub_1002DBAC8 @ 0x1002dbae8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 11:02:45 +0000
//
__int64 __fastcall sub_1002DB978(Bytef *a1, uInt a2, void **a3, _DWORD *a4, int a5)
{
signed int v5; // w20
int v10; // w8
Bytef *v11; // x0
__int64 v12; // x22
char *v13; // x0
__int64 v14; // x0
z_stream v16; // [xsp+0h] [xbp-A0h] BYREF
v5 = a5;
if ( a5 < 0 )
v10 = -1;
else
v10 = a5;
v11 = (Bytef *)operator new[](v10);
*a3 = v11;
memset(&v16.zalloc, 0, 24);
v16.next_in = a1;
v16.avail_in = a2;
v16.next_out = v11;
v16.avail_out = v5;
v12 = inflateInit2_(&v16, 47, "1.2.12", 112);
if ( !(_DWORD)v12 )
{
while ( 1 )
{
v14 = inflate(&v16, 0);
if ( (int)v14 > -5 )
{
v12 = v14;
if ( (unsigned int)(v14 + 4) < 2 )
goto LABEL_18;
if ( (_DWORD)v14 == 1 )
{
*a4 = v5 - v16.avail_out;
return inflateEnd(&v16);
}
if ( (_DWORD)v14 == 2 )
{
v12 = 4294967293LL;
LABEL_18:
inflateEnd(&v16);
return v12;
}
}
else if ( (_DWORD)v14 == -5 && !v16.avail_in )
{
inflateEnd(&v16);
return 4294967293LL;
}
v13 = (char *)realloc(*a3, 2 * v5);
*a3 = v13;
if ( !v13 )
{
inflateEnd(&v16);
return 4294967292LL;
}
v16.next_out = (Bytef *)&v13[v5];
v16.avail_out = v5;
v5 *= 2;
}
}
return v12;
}