//
// sub_1002065E0 from 0x1002065e0 to 0x10020670c (300 bytes)
//
// 4 xrefs:
// > cocos2d::ZipUtils::decompressString2 @ 0x100205446
// > sub_1002055A0 @ 0x1002055ba
// > cocos2d::ZipUtils::decompressString @ 0x10020576f
// > sub_100206710 @ 0x100206727
//
// 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
//
__int64 __fastcall sub_1002065E0(Bytef *a1, uInt a2, void **a3, _DWORD *a4, int a5)
{
signed int v5; // r14d
int v8; // eax
Bytef *v9; // rax
unsigned int v10; // r13d
char *v11; // rax
z_stream strm; // [rsp+8h] [rbp-98h] BYREF
v5 = a5;
v8 = -1;
if ( a5 >= 0 )
v8 = a5;
v9 = (Bytef *)operator new[](v8);
*a3 = v9;
memset(&strm.zalloc, 0, 24);
strm.next_in = a1;
strm.avail_in = a2;
strm.next_out = v9;
strm.avail_out = v5;
v10 = inflateInit2_(&strm, 47, "1.2.12", 112);
if ( !v10 )
{
while ( 1 )
{
v10 = inflate(&strm, 0);
if ( v10 + 4 < 2 )
goto LABEL_10;
if ( v10 == 1 )
{
*a4 = v5 - strm.avail_out;
return (unsigned int)inflateEnd(&strm);
}
if ( v10 == 2 )
{
v10 = -3;
LABEL_10:
inflateEnd(&strm);
return v10;
}
v11 = (char *)realloc(*a3, 2 * v5);
*a3 = v11;
if ( !v11 )
break;
strm.next_out = (Bytef *)&v11[v5];
strm.avail_out = v5;
v5 *= 2;
}
inflateEnd(&strm);
return (unsigned int)-4;
}
return v10;
}