//
// cocos2d::extension::AssetsManager::update from 0xa97634 to 0xa977ac (376 bytes)
//
// 2 xrefs:
// > ??> @ 0x71310
// > ??> @ 0x11f44d8
//
// 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 cocos2d::extension::AssetsManager::update(cocos2d::extension::AssetsManager *this)
{
cocos2d::CCUserDefault *v3; // x0
void *v4; // x0
pthread_t *v5; // x0
unsigned int *v6; // x2
int v7; // w1
__int64 v8; // [xsp+40h] [xbp+40h] BYREF
if ( !*((_QWORD *)this + 8)
&& *(_QWORD *)(*((_QWORD *)this + 4) - 24LL)
&& *(_QWORD *)(*((_QWORD *)this + 3) - 24LL)
&& sub_D1641C((int)this + 24, ".zip") != -1
&& (*(unsigned __int8 (__fastcall **)(cocos2d::extension::AssetsManager *))(*(_QWORD *)this + 16LL))(this) )
{
v3 = cocos2d::CCUserDefault::sharedUserDefault();
cocos2d::CCUserDefault::getStringForKey(&v8, v3, "downloaded-version-code");
sub_D163D4((char *)this + 40, &v8);
v4 = (void *)(v8 - 24);
if ( (__int64 *)(v8 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v6 = (unsigned int *)(v8 - 8);
do
v7 = __ldaxr(v6);
while ( __stlxr(v7 - 1, v6) );
}
else
{
v7 = *(_DWORD *)(v8 - 8);
*(_DWORD *)(v8 - 8) = v7 - 1;
}
if ( v7 <= 0 )
operator delete(v4);
}
v5 = (pthread_t *)operator new(8u);
*v5 = 0;
*((_QWORD *)this + 8) = v5;
pthread_create(v5, nullptr, (void *(*)(void *))cocos2d::extension::assetsManagerDownloadAndUncompress, this);
}
return _stack_chk_guard;
}