//
// GJMapPack::parsePackLevels from 0x70c118 to 0x70c23c (292 bytes)
//
// 2 xrefs:
// > GJMapPack::create @ 0x70c7d0
// > ??> @ 0x89580
//
// 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 GJMapPack::parsePackLevels(__int64 a1, char **a2)
{
cocos2d::CCObject *v3; // x0
cocos2d::CCArray *v4; // x0
void *v5; // x3
unsigned int *v7; // x2
int v8; // w0
char **v9; // [xsp+38h] [xbp+38h]
__int64 v10; // [xsp+50h] [xbp+50h] BYREF
v3 = *(cocos2d::CCObject **)(a1 + 320);
if ( v3 )
{
v9 = a2;
cocos2d::CCObject::release(v3);
a2 = v9;
}
sub_D153B8((int)&v10, *a2);
v4 = sub_6F004C(&v10, &byte_F804F8);
*(_QWORD *)(a1 + 320) = v4;
v5 = (void *)(v10 - 24);
if ( (__int64 *)(v10 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v7 = (unsigned int *)(v10 - 8);
do
v8 = __ldaxr(v7);
while ( __stlxr(v8 - 1, v7) );
}
else
{
v8 = *(_DWORD *)(v10 - 8);
*(_DWORD *)(v10 - 8) = v8 - 1;
}
if ( v8 <= 0 )
operator delete(v5);
v4 = *(cocos2d::CCArray **)(a1 + 320);
}
cocos2d::CCObject::retain(v4);
return _stack_chk_guard;
}