//
// sub_100178BC0 from 0x100178bc0 to 0x100178e5c (668 bytes)
//
// 1 xrefs:
// > cocos2d::CCFileUtils::getFileDataFromZip @ 0x100150d74
//
// 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_100178BC0(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v3; // x23
unsigned __int64 v4; // x8
unsigned __int64 v5; // x9
__int64 v6; // x9
__int64 v7; // x10
__int64 v8; // x19
__int64 v9; // x20
unsigned __int64 v10; // x8
__int64 v11; // x8
unsigned int v12; // w8
__int64 i; // x8
__int64 v14; // x21
uLong v15; // x0
__int64 v16; // x22
const Bytef *v17; // x21
__int64 v18; // x0
__int64 v19; // x20
__int64 v20; // x22
uLong v21; // x0
__int64 v22; // x8
if ( !a1 )
return 4294967194LL;
v3 = *(_QWORD *)(a1 + 320);
if ( !v3 )
return 4294967194LL;
if ( !*(_QWORD *)v3 )
return 4294967196LL;
if ( !a3 )
return 0;
*(_QWORD *)(v3 + 32) = a2;
*(_DWORD *)(v3 + 40) = a3;
v4 = a3;
v5 = *(_QWORD *)(v3 + 192);
if ( v5 < a3 && !*(_DWORD *)(v3 + 312) )
{
*(_DWORD *)(v3 + 40) = v5;
a3 = v5;
}
v6 = *(_QWORD *)(v3 + 184);
v7 = *(unsigned int *)(v3 + 16);
if ( v6 + v7 < v4 && *(_DWORD *)(v3 + 312) )
{
a3 = v7 + v6;
*(_DWORD *)(v3 + 40) = v7 + v6;
}
if ( !a3 )
return 0;
v8 = 0;
while ( 1 )
{
LODWORD(v9) = *(_DWORD *)(v3 + 16);
if ( !(_DWORD)v9 )
{
v10 = *(_QWORD *)(v3 + 184);
if ( v10 )
{
if ( v10 >= 0x4000 )
v9 = 0x4000;
else
v9 = *(_QWORD *)(v3 + 184);
if ( sub_1001360A4((_QWORD *)(v3 + 200))
|| (*(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, __int64))(v3 + 208))(
*(_QWORD *)(v3 + 256),
*(_QWORD *)(v3 + 288),
*(_QWORD *)v3,
v9) != v9 )
{
return 0xFFFFFFFFLL;
}
*(_QWORD *)(v3 + 120) += v9;
*(_QWORD *)(v3 + 184) -= v9;
*(_QWORD *)(v3 + 8) = *(_QWORD *)v3;
*(_DWORD *)(v3 + 16) = v9;
}
else
{
LODWORD(v9) = 0;
}
}
v11 = *(_QWORD *)(v3 + 296);
if ( v11 )
{
if ( !*(_DWORD *)(v3 + 312) )
break;
}
if ( !(_DWORD)v9 && !*(_QWORD *)(v3 + 184) )
return v8;
v12 = *(_DWORD *)(v3 + 40);
if ( v12 >= (unsigned int)v9 )
v9 = (unsigned int)v9;
else
v9 = v12;
if ( (_DWORD)v9 )
{
for ( i = 0; i != v9; ++i )
*(_BYTE *)(*(_QWORD *)(v3 + 32) + i) = *(_BYTE *)(*(_QWORD *)(v3 + 8) + i);
v14 = v9;
}
else
{
v14 = 0;
}
v15 = *(_QWORD *)(v3 + 168);
*(_QWORD *)(v3 + 160) += v14;
*(_QWORD *)(v3 + 168) = crc32(v15, *(const Bytef **)(v3 + 32), v9);
*(_QWORD *)(v3 + 192) -= v14;
*(_DWORD *)(v3 + 16) -= v9;
*(_DWORD *)(v3 + 40) -= v9;
*(_QWORD *)(v3 + 32) += v14;
*(_QWORD *)(v3 + 8) += v14;
v8 = (unsigned int)(v9 + v8);
*(_QWORD *)(v3 + 48) += v14;
LABEL_35:
if ( !*(_DWORD *)(v3 + 40) )
return v8;
}
if ( v11 == 12 )
goto LABEL_35;
v16 = *(_QWORD *)(v3 + 48);
v17 = *(const Bytef **)(v3 + 32);
v18 = inflate((z_streamp)(v3 + 8), 2);
v19 = v18;
if ( (v18 & 0x80000000) == 0 )
{
if ( *(_QWORD *)(v3 + 56) )
v19 = 4294967293LL;
else
v19 = (unsigned int)v18;
}
v20 = *(_QWORD *)(v3 + 48) - v16;
v21 = *(_QWORD *)(v3 + 168);
*(_QWORD *)(v3 + 160) += v20;
*(_QWORD *)(v3 + 168) = crc32(v21, v17, v20);
*(_QWORD *)(v3 + 192) -= v20;
v8 = (unsigned int)(v8 + v20);
if ( !(_DWORD)v19 )
goto LABEL_35;
v22 = v8;
v8 = v19;
if ( (_DWORD)v19 != 1 )
return v8;
return v22;
}