//
// sub_801A04 from 0x801a04 to 0x801e4e (1098 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:01:20 +0000
//
int sub_801A04()
{
_DWORD *v0; // r9
int v1; // r6
unsigned int v2; // r3
void **v3; // r2
unsigned int v4; // r1
_DWORD *v5; // r4
int v6; // r6
unsigned int v7; // r6
unsigned __int8 *v8; // r9
unsigned __int8 *v9; // r6
int v10; // r6
unsigned int v11; // r6
unsigned __int8 *v12; // r10
unsigned __int8 *v13; // r6
int v14; // r6
unsigned int v15; // r6
unsigned __int8 *v16; // r10
unsigned __int8 *v17; // r6
int v18; // r6
unsigned int v19; // r6
unsigned __int8 *v20; // r10
unsigned __int8 *v21; // r6
int v22; // r6
unsigned int v23; // r6
unsigned __int8 *v24; // r10
unsigned __int8 *v25; // r6
int v26; // r6
unsigned int v27; // r6
unsigned __int8 *v28; // r10
unsigned __int8 *v29; // r6
int v30; // r6
unsigned int v31; // r6
unsigned __int8 *v32; // r10
unsigned __int8 *v33; // r6
int v34; // r6
unsigned int v35; // r6
unsigned __int8 *v36; // r10
unsigned __int8 *v37; // r6
_DWORD *v38; // r0
_DWORD *v39; // r9
_DWORD *v40; // r4
int v41; // r1
int v42; // r2
unsigned int v43; // r3
unsigned int v44; // r0
int v45; // r1
int v46; // r2
int v47; // r3
void *v48; // r4
int v49; // r1
int v50; // r2
int v51; // r3
void *v52; // r4
int v54; // r10
cocos2d::CCImage *v55; // r6
int v56; // r3
int v57; // r2
int v58; // [sp+28h] [bp-14h] BYREF
unsigned __int8 *v59[2]; // [sp+2Ch] [bp-10h] BYREF
while ( 1 )
{
v58 = 0;
cocos2d::CCThread::createAutoreleasePool((cocos2d::CCThread *)&v58);
v0 = (_DWORD *)dword_D31198;
pthread_mutex_lock((pthread_mutex_t *)&unk_D3119C);
v1 = v0[5];
if ( !v1 )
break;
v2 = v0[4];
v3 = (void **)v0[1];
v4 = v2++ >> 10;
v5 = *((_DWORD **)v3[v4] + (v0[4] & 0x3FF));
v0[5] = v1 - 1;
v0[4] = v2;
if ( v2 >= 0x800 )
{
operator delete(*v3);
v0[1] += 4;
v0[4] -= 1024;
}
pthread_mutex_unlock((pthread_mutex_t *)&unk_D3119C);
v6 = *(unsigned __int8 *)v5;
if ( (v6 & 1) != 0 )
{
v7 = v5[1];
v8 = (unsigned __int8 *)v5[2];
}
else
{
v7 = v6 >> 1;
v8 = (unsigned __int8 *)v5 + 1;
}
if ( v7 > 3 )
{
v9 = &v8[v7];
std::__search(
v59,
v8,
v9,
".jpg",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v59[0] != v9 && v59[0] - v8 != -1 )
goto LABEL_67;
}
v10 = *(unsigned __int8 *)v5;
if ( (v10 & 1) != 0 )
{
v11 = v5[1];
v12 = (unsigned __int8 *)v5[2];
}
else
{
v11 = v10 >> 1;
v12 = (unsigned __int8 *)v5 + 1;
}
if ( v11 <= 4
|| (v13 = &v12[v11],
std::__search(
v59,
v12,
v13,
".jpeg",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq),
v59[0] == v13)
|| v59[0] - v12 == -1 )
{
v14 = *(unsigned __int8 *)v5;
if ( (v14 & 1) != 0 )
{
v15 = v5[1];
v16 = (unsigned __int8 *)v5[2];
}
else
{
v15 = v14 >> 1;
v16 = (unsigned __int8 *)v5 + 1;
}
if ( v15 > 3 )
{
v17 = &v16[v15];
std::__search(
v59,
v16,
v17,
".png",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v59[0] != v17 && v59[0] - v16 != -1 )
goto LABEL_68;
}
v18 = *(unsigned __int8 *)v5;
if ( (v18 & 1) != 0 )
{
v19 = v5[1];
v20 = (unsigned __int8 *)v5[2];
}
else
{
v19 = v18 >> 1;
v20 = (unsigned __int8 *)v5 + 1;
}
if ( v19 <= 3
|| (v21 = &v20[v19],
std::__search(
v59,
v20,
v21,
".PNG",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq),
v59[0] == v21)
|| v59[0] - v20 == -1 )
{
v22 = *(unsigned __int8 *)v5;
if ( (v22 & 1) != 0 )
{
v23 = v5[1];
v24 = (unsigned __int8 *)v5[2];
}
else
{
v23 = v22 >> 1;
v24 = (unsigned __int8 *)v5 + 1;
}
if ( v23 > 4 )
{
v25 = &v24[v23];
std::__search(
v59,
v24,
v25,
".tiff",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v59[0] != v25 && v59[0] - v24 != -1 )
goto LABEL_69;
}
v26 = *(unsigned __int8 *)v5;
if ( (v26 & 1) != 0 )
{
v27 = v5[1];
v28 = (unsigned __int8 *)v5[2];
}
else
{
v27 = v26 >> 1;
v28 = (unsigned __int8 *)v5 + 1;
}
if ( v27 <= 4
|| (v29 = &v28[v27],
std::__search(
v59,
v28,
v29,
".TIFF",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq),
v59[0] == v29)
|| v59[0] - v28 == -1 )
{
v30 = *(unsigned __int8 *)v5;
if ( (v30 & 1) != 0 )
{
v31 = v5[1];
v32 = (unsigned __int8 *)v5[2];
}
else
{
v31 = v30 >> 1;
v32 = (unsigned __int8 *)v5 + 1;
}
if ( v31 <= 4
|| (v33 = &v32[v31],
std::__search(
v59,
v32,
v33,
".webp",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq),
v59[0] == v33)
|| v59[0] - v32 == -1 )
{
v34 = *(unsigned __int8 *)v5;
if ( (v34 & 1) != 0 )
{
v35 = v5[1];
v36 = (unsigned __int8 *)v5[2];
}
else
{
v35 = v34 >> 1;
v36 = (unsigned __int8 *)v5 + 1;
}
if ( v35 <= 4
|| (v37 = &v36[v35],
std::__search(
v59,
v36,
v37,
".WEBP",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq),
v59[0] == v37)
|| v59[0] - v36 == -1 )
{
std::string::~string((int)v5);
operator delete(v5);
goto LABEL_61;
}
}
v54 = 3;
}
else
{
LABEL_69:
v54 = 2;
}
}
else
{
LABEL_68:
v54 = 1;
}
}
else
{
LABEL_67:
v54 = 0;
}
v55 = (cocos2d::CCImage *)operator new(0x48u);
cocos2d::CCImage::CCImage(v55);
if ( cocos2d::CCImage::initWithImageFileThreadSafe(v55, (char *)v8, v54) )
{
v38 = (_DWORD *)operator new(0xCu);
*v38 = v5;
v38[1] = v55;
v38[2] = v54;
v39 = v38;
pthread_mutex_lock((pthread_mutex_t *)&unk_D31190);
v40 = (_DWORD *)dword_D3118C;
v41 = (v40[2] - v40[1]) >> 2;
if ( v41 )
v41 = (v41 << 10) - 1;
if ( v41 == *(_DWORD *)(dword_D3118C + 16) + *(_DWORD *)(dword_D3118C + 20) )
std::deque::__add_back_capacity(dword_D3118C);
v42 = v40[1];
v43 = v40[4] + v40[5];
v44 = v43 >> 10;
if ( v40[2] != v42 )
{
v56 = v43 & 0x3FF;
v57 = *(_DWORD *)(v42 + 4 * v44);
if ( v57 + 4 * v56 )
*(_DWORD *)(v57 + 4 * v56) = v39;
}
++v40[5];
pthread_mutex_unlock((pthread_mutex_t *)&unk_D31190);
}
else
{
cocos2d::CCObject::release(v55);
}
LABEL_61:
cocos2d::CCThread::~CCThread((cocos2d::CCThread *)&v58);
}
pthread_mutex_unlock((pthread_mutex_t *)&unk_D3119C);
if ( !byte_D31180 )
{
pthread_cond_wait((pthread_cond_t *)&unk_D31184, (pthread_mutex_t *)&unk_D311A0);
goto LABEL_61;
}
cocos2d::CCThread::~CCThread((cocos2d::CCThread *)&v58);
v48 = (void *)dword_D31198;
if ( dword_D31198 )
{
std::__deque_base::~__deque_base(dword_D31198, v45, v46, v47);
operator delete(v48);
v52 = (void *)dword_D3118C;
dword_D31198 = 0;
if ( dword_D3118C )
{
std::__deque_base::~__deque_base(dword_D3118C, v49, v50, v51);
operator delete(v52);
}
dword_D3118C = 0;
pthread_mutex_destroy((pthread_mutex_t *)&unk_D3119C);
pthread_mutex_destroy((pthread_mutex_t *)&unk_D31190);
pthread_mutex_destroy((pthread_mutex_t *)&unk_D311A0);
pthread_cond_destroy((pthread_cond_t *)&unk_D31184);
}
return 0;
}