//
// sub_DA76B4 from 0xda76b4 to 0xda7d00 (1612 bytes)
//
// 2 xrefs:
// > cocos2d::CCTextureCache::addImageAsync @ 0xda9540
// > cocos2d::CCTextureCache::addImageAsync @ 0xda954c
//
// 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:33 +0000
//
__int64 sub_DA76B4()
{
_QWORD *v0; // x23
__int64 v1; // x0
unsigned __int64 v2; // x1
void **v3; // x2
unsigned __int64 v4; // x3
char *v5; // x22
__int64 v6; // x0
unsigned __int8 v7; // w0
int v8; // w1
unsigned __int64 v9; // x2
char *v10; // x24
char *v11; // x23
__int64 v12; // x0
int v13; // w25
cocos2d::CCImage *v14; // x23
__int64 v15; // x25
unsigned __int64 v16; // x2
unsigned __int64 v17; // x23
__int64 v18; // x0
unsigned __int64 v19; // x2
__int64 v20; // x25
unsigned __int64 v21; // x23
__int64 v22; // x0
__int64 v23; // x24
_QWORD *v24; // x22
__int64 v25; // x1
__int64 v26; // x3
__int64 v27; // x0
__int64 v28; // x4
unsigned __int64 v29; // x2
unsigned __int64 v30; // x0
__int64 v31; // x2
__int64 v32; // x0
__int64 v33; // x25
unsigned __int64 v34; // x2
unsigned __int64 v35; // x23
__int64 v36; // x0
unsigned __int64 v37; // x2
__int64 v38; // x25
unsigned __int64 v39; // x23
__int64 v40; // x0
void *v41; // x20
void *v42; // x20
__int64 v44; // x25
unsigned __int64 v45; // x2
unsigned __int64 v46; // x23
__int64 v47; // x0
unsigned __int64 v48; // x2
__int64 v49; // x25
unsigned __int64 v50; // x23
__int64 v51; // x0
__int64 v52; // x25
unsigned __int64 v53; // x0
unsigned __int64 v54; // x23
__int64 v55; // x0
__int64 v56; // [xsp+70h] [xbp+70h] BYREF
while ( 1 )
{
v56 = 0;
cocos2d::CCThread::createAutoreleasePool((cocos2d::CCThread *)&v56);
v0 = (_QWORD *)qword_15622B0;
pthread_mutex_lock(stru_15622B8);
v1 = v0[5];
if ( !v1 )
break;
LABEL_4:
v2 = v0[4];
v3 = (void **)v0[1];
v4 = v2++ >> 9;
v5 = *((char **)v3[v4] + (v0[4] & 0x1FFLL));
v0[5] = v1 - 1;
v0[4] = v2;
if ( v2 > 0x3FF )
{
operator delete(*v3);
v6 = v0[4];
v0[1] += 8LL;
v0[4] = v6 - 512;
}
pthread_mutex_unlock(stru_15622B8);
v7 = *v5;
v8 = *v5 & 1;
if ( (*v5 & 1) != 0 )
{
v9 = *((_QWORD *)v5 + 1);
v10 = *((char **)v5 + 2);
if ( v9 <= 3 )
goto LABEL_15;
}
else
{
v9 = v7 >> 1;
v10 = v5 + 1;
if ( v9 <= 3 )
goto LABEL_15;
}
v11 = &v10[v9];
v12 = std::__search(
(__int64)v10,
(__int64)&v10[v9],
".jpg",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v11 != (char *)v12 && v12 - (_QWORD)v10 != -1 )
{
LABEL_10:
v13 = 0;
goto LABEL_11;
}
v7 = *v5;
v8 = *v5 & 1;
LABEL_15:
if ( v8 )
{
v15 = *((_QWORD *)v5 + 2);
v16 = *((_QWORD *)v5 + 1);
}
else
{
v15 = (__int64)(v5 + 1);
v16 = v7 >> 1;
}
if ( v16 > 4 )
{
v17 = v15 + v16;
v18 = std::__search(
v15,
v15 + v16,
".jpeg",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v17 != v18 && v18 - v15 != -1 )
goto LABEL_10;
v7 = *v5;
v8 = *v5 & 1;
}
if ( v8 )
{
v19 = *((_QWORD *)v5 + 1);
v20 = *((_QWORD *)v5 + 2);
if ( v19 <= 3 )
goto LABEL_35;
}
else
{
v19 = v7 >> 1;
v20 = (__int64)(v5 + 1);
if ( v19 <= 3 )
{
LABEL_35:
if ( !v8 )
goto LABEL_36;
goto LABEL_52;
}
}
v21 = v20 + v19;
v22 = std::__search(
v20,
v20 + v19,
(unsigned __int8 *)".png",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v21 != v22 && v22 - v20 != -1 )
{
LABEL_25:
v13 = 1;
goto LABEL_11;
}
v7 = *v5;
v8 = *v5 & 1;
if ( (*v5 & 1) == 0 )
{
LABEL_36:
v33 = (__int64)(v5 + 1);
v34 = v7 >> 1;
goto LABEL_37;
}
LABEL_52:
v33 = *((_QWORD *)v5 + 2);
v34 = *((_QWORD *)v5 + 1);
LABEL_37:
if ( v34 > 3 )
{
v35 = v33 + v34;
v36 = std::__search(
v33,
v33 + v34,
".PNG",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v35 != v36 && v36 - v33 != -1 )
goto LABEL_25;
v7 = *v5;
v8 = *v5 & 1;
}
if ( v8 )
{
v37 = *((_QWORD *)v5 + 1);
v38 = *((_QWORD *)v5 + 2);
if ( v37 <= 4 )
goto LABEL_54;
}
else
{
v37 = v7 >> 1;
v38 = (__int64)(v5 + 1);
if ( v37 <= 4 )
goto LABEL_54;
}
v39 = v38 + v37;
v40 = std::__search(
v38,
v38 + v37,
".tiff",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v39 != v40 && v40 - v38 != -1 )
{
LABEL_45:
v13 = 2;
goto LABEL_11;
}
v7 = *v5;
v8 = *v5 & 1;
LABEL_54:
if ( v8 )
{
v44 = *((_QWORD *)v5 + 2);
v45 = *((_QWORD *)v5 + 1);
}
else
{
v44 = (__int64)(v5 + 1);
v45 = v7 >> 1;
}
if ( v45 > 4 )
{
v46 = v44 + v45;
v47 = std::__search(
v44,
v44 + v45,
".TIFF",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v46 != v47 && v47 - v44 != -1 )
goto LABEL_45;
v7 = *v5;
v8 = *v5 & 1;
}
if ( v8 )
{
v48 = *((_QWORD *)v5 + 1);
v49 = *((_QWORD *)v5 + 2);
if ( v48 <= 4 )
goto LABEL_66;
}
else
{
v48 = v7 >> 1;
v49 = (__int64)(v5 + 1);
if ( v48 <= 4 )
goto LABEL_66;
}
v50 = v49 + v48;
v51 = std::__search(
v49,
v49 + v48,
".webp",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v50 != v51 && v51 - v49 != -1 )
{
LABEL_64:
v13 = 3;
LABEL_11:
v14 = (cocos2d::CCImage *)operator new(0x50u);
cocos2d::CCImage::CCImage(v14);
if ( (unsigned __int8)cocos2d::CCImage::initWithImageFileThreadSafe(v14, v10, v13) )
{
v23 = operator new(0x18u);
*(_QWORD *)v23 = v5;
*(_QWORD *)(v23 + 8) = v14;
*(_DWORD *)(v23 + 16) = v13;
pthread_mutex_lock(&stru_1562280);
v24 = (_QWORD *)qword_1562278;
v25 = *(_QWORD *)(qword_1562278 + 8);
v26 = *(_QWORD *)(qword_1562278 + 16);
v27 = (v26 - v25) >> 3;
if ( v27 )
v27 = (v27 << 9) - 1;
v28 = *(_QWORD *)(qword_1562278 + 40);
v29 = v28 + *(_QWORD *)(qword_1562278 + 32);
if ( v29 == v27 )
{
std::deque::__add_back_capacity((char **)qword_1562278);
v28 = v24[5];
v25 = v24[1];
v26 = v24[2];
v29 = v28 + v24[4];
}
v30 = v29 >> 9;
if ( v26 != v25 )
{
v31 = v29 & 0x1FF;
v32 = *(_QWORD *)(v25 + 8 * v30);
if ( v32 + 8 * v31 )
{
*(_QWORD *)(v32 + 8 * v31) = v23;
v28 = v24[5];
}
}
v24[5] = v28 + 1;
pthread_mutex_unlock(&stru_1562280);
}
else
{
cocos2d::CCObject::release(v14);
}
goto LABEL_13;
}
v7 = *v5;
v8 = *v5 & 1;
LABEL_66:
if ( v8 )
{
v52 = *((_QWORD *)v5 + 2);
v53 = *((_QWORD *)v5 + 1);
}
else
{
v52 = (__int64)(v5 + 1);
v53 = v7 >> 1;
}
if ( v53 > 4 )
{
v54 = v52 + v53;
v55 = std::__search(
v52,
v52 + v53,
".WEBP",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v54 != v55 && v55 - v52 != -1 )
goto LABEL_64;
v8 = *v5 & 1;
}
if ( v8 )
operator delete(*((void **)v5 + 2));
operator delete(v5);
LABEL_13:
cocos2d::CCThread::~CCThread((cocos2d::CCThread *)&v56);
}
while ( 1 )
{
pthread_mutex_unlock(stru_15622B8);
if ( byte_1562238 )
break;
pthread_cond_wait(&stru_1562240, &stru_15622E0);
cocos2d::CCThread::~CCThread((cocos2d::CCThread *)&v56);
v56 = 0;
cocos2d::CCThread::createAutoreleasePool((cocos2d::CCThread *)&v56);
v0 = (_QWORD *)qword_15622B0;
pthread_mutex_lock(stru_15622B8);
v1 = v0[5];
if ( v1 )
goto LABEL_4;
}
cocos2d::CCThread::~CCThread((cocos2d::CCThread *)&v56);
v41 = (void *)qword_15622B0;
if ( qword_15622B0 )
{
std::__deque_base::~__deque_base(qword_15622B0);
operator delete(v41);
v42 = (void *)qword_1562278;
qword_15622B0 = 0;
if ( qword_1562278 )
{
std::__deque_base::~__deque_base(qword_1562278);
operator delete(v42);
}
qword_1562278 = 0;
pthread_mutex_destroy(stru_15622B8);
pthread_mutex_destroy(&stru_1562280);
pthread_mutex_destroy(&stru_15622E0);
pthread_cond_destroy(&stru_1562240);
}
return 0;
}