//
// cocos2d::CCTextureCache::addImageAsyncCallBack from 0xda638c to 0xda6638 (684 bytes)
//
// 4 xrefs:
// > ??> @ 0xdbbc8
// > cocos2d::CCTextureCache::addImageAsyncCallBack @ 0xda65e0
// > cocos2d::CCTextureCache::addImageAsync @ 0xda9490
// > ??> @ 0x1546970
//
// 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 13:08:32 +0000
//
__int64 __fastcall cocos2d::CCTextureCache::addImageAsyncCallBack(cocos2d::CCTextureCache *this, float a2)
{
_QWORD *v2; // x20
cocos2d::CCDirector *v3; // x0
__int64 v4; // x1
void **v5; // x2
unsigned __int64 v6; // x0
void *v7; // x22
__int64 v8; // x0
unsigned int *v9; // x28
cocos2d::CCImage *v10; // x24
cocos2d::CCTexture2D *v11; // x26
char *v12; // x25
void (__fastcall *v13)(char *, cocos2d::CCTexture2D *); // x23
cocos2d::CCTexture2D *v14; // x19
size_t v15; // x0
__int64 v16; // x0
__int64 v17; // x0
__int64 v20; // [xsp+68h] [xbp+68h]
__int64 v21; // [xsp+78h] [xbp+78h]
__int64 v22[2]; // [xsp+80h] [xbp+80h] BYREF
void *v23; // [xsp+90h] [xbp+90h]
v2 = (_QWORD *)qword_1562278;
if ( qword_1562278 )
{
LABEL_10:
pthread_mutex_lock(&stru_1562280);
v4 = v2[5];
if ( v4 )
{
while ( 1 )
{
v5 = (void **)v2[1];
v6 = v2[4] + 1LL;
v7 = *((void **)v5[v2[4] >> 9] + (v2[4] & 0x1FFLL));
v2[5] = v4 - 1;
v2[4] = v6;
if ( v6 > 0x3FF )
{
operator delete(*v5);
v8 = v2[4];
v2[1] += 8LL;
v2[4] = v8 - 512;
}
pthread_mutex_unlock(&stru_1562280);
v9 = *(unsigned int **)v7;
v10 = *((cocos2d::CCImage **)v7 + 1);
*((_DWORD *)v10 + 19) = *(_DWORD *)(*(_QWORD *)v7 + 52LL);
v11 = (cocos2d::CCTexture2D *)((char *)v9 + 1);
v21 = *((_QWORD *)v9 + 5);
v12 = *((char **)v9 + 3);
v13 = *((void (__fastcall **)(char *, cocos2d::CCTexture2D *))v9 + 4);
if ( (*(_BYTE *)v9 & 1) != 0 )
v11 = *((cocos2d::CCTexture2D **)v9 + 2);
v14 = (cocos2d::CCTexture2D *)operator new(0x68u);
cocos2d::CCTexture2D::CCTexture2D(v14);
cocos2d::CCTexture2D::initWithImage(v14, v10);
cocos2d::VolatileTexture::addImageTexture(v14, v11, *((_DWORD *)v7 + 4));
v22[0] = 0;
v22[1] = 0;
v23 = nullptr;
v20 = *((_QWORD *)this + 7);
v15 = strlen((const char *)v11);
std::string::__init(v22, v11, v15);
cocos2d::CCDictionary::setObject(v20, v14, (__int64)v22);
if ( (v22[0] & 1) != 0 )
operator delete(v23);
cocos2d::CCObject::autorelease(v14);
if ( !v12 )
goto LABEL_8;
if ( !v13 )
break;
(*(void (__fastcall **)(cocos2d::CCTexture2D *, _QWORD))(*(_QWORD *)v14 + 72LL))(v14, v9[12]);
if ( (v21 & 1) != 0 )
goto LABEL_19;
v13(&v12[v21 >> 1], v14);
LABEL_7:
cocos2d::CCObject::release(v12);
LABEL_8:
cocos2d::CCObject::release(v10);
if ( (*(_BYTE *)v9 & 1) != 0 )
{
operator delete(*((void **)v9 + 2));
operator delete(v9);
operator delete(v7);
v3 = (cocos2d::CCDirector *)(qword_15622A8 - 1);
qword_15622A8 = (__int64)v3;
if ( v3 )
goto LABEL_10;
}
else
{
operator delete(v9);
operator delete(v7);
v3 = (cocos2d::CCDirector *)(qword_15622A8 - 1);
qword_15622A8 = (__int64)v3;
if ( v3 )
goto LABEL_10;
}
v16 = cocos2d::CCDirector::sharedDirector(v3);
v17 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v16 + 128LL))(v16);
cocos2d::CCScheduler::unscheduleSelector(
v17,
(__int64)cocos2d::CCTextureCache::addImageAsyncCallBack,
0,
(__int64)this);
pthread_mutex_lock(&stru_1562280);
v4 = v2[5];
if ( !v4 )
goto LABEL_22;
}
if ( (v21 & 1) == 0 )
goto LABEL_8;
(*(void (__fastcall **)(cocos2d::CCTexture2D *, _QWORD))(*(_QWORD *)v14 + 72LL))(v14, v9[12]);
LABEL_19:
(*(void (__fastcall **)(char *, cocos2d::CCTexture2D *))((char *)v13 + *(_QWORD *)&v12[v21 >> 1]))(
&v12[v21 >> 1],
v14);
goto LABEL_7;
}
LABEL_22:
pthread_mutex_unlock(&stru_1562280);
}
return _stack_chk_guard;
}