//
// cocos2d::CCSpriteFrameCache::removeSpriteFrameByName from 0xb1b2b8 to 0xb1b5a4 (748 bytes)
//
// 1 xrefs:
// > ??> @ 0x353b8
//
// 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
//
void cocos2d::CCSpriteFrameCache::removeSpriteFrameByName(cocos2d::CCSpriteFrameCache *a1, const char *a2)
{
__int64 v4; // x21
cocos2d::CCString *v5; // x21
char *v6; // x0
cocos2d::CCSpriteFrameCache_vtbl *v7; // x25
char *CString; // x0
char *v9; // x0
cocos2d::CCString *v10; // x0
__int64 v11; // x21
char *v12; // x0
const char *v13; // x1
char *v14; // x0
_QWORD *v15; // x21
__int64 v16; // x19
void *v17; // x0
__int64 v18; // x20
__int64 v19; // x1
void *v20; // x0
unsigned int *v21; // x1
int v22; // w2
void *v23; // x0
unsigned int *v24; // x1
int v25; // w2
cocos2d::CCSpriteFrameCache_vtbl *v26; // x21
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x1
unsigned int *v30; // x1
int v31; // w2
_QWORD v32[2]; // [xsp+0h] [xbp+0h] BYREF
const char *v33; // [xsp+60h] [xbp+60h] BYREF
if ( !a2 )
return;
v4 = *(_QWORD *)&a1[1].m_uID;
sub_D153B8((int)&v33, (char *)a2);
v5 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v4, &v33);
v6 = (char *)(v33 - 24);
if ( v33 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_3;
if ( &pthread_create )
{
v24 = (unsigned int *)(v33 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v33 - 2);
*((_DWORD *)v33 - 2) = v25 - 1;
}
if ( v25 > 0 )
{
LABEL_3:
if ( !v5 )
goto LABEL_23;
LABEL_4:
v7 = a1[1].__vftable;
CString = (char *)cocos2d::CCString::getCString(v5);
sub_D153B8((unsigned int)v32 + 96, CString);
cocos2d::CCDictionary::removeObjectForKey((__int64)v7, &v33);
v9 = (char *)(v33 - 24);
if ( v33 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v30 = (unsigned int *)(v33 - 8);
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *((_DWORD *)v33 - 2);
*((_DWORD *)v33 - 2) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v9);
}
v10 = v5;
v11 = *(_QWORD *)&a1[1].m_uID;
v12 = (char *)cocos2d::CCString::getCString(v10);
sub_D153B8((unsigned int)v32 + 96, v12);
cocos2d::CCDictionary::removeObjectForKey(v11, &v33);
v13 = v33;
v14 = (char *)(v33 - 24);
if ( v33 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_6;
if ( &pthread_create )
{
v29 = (unsigned int *)(v33 - 8);
do
v28 = __ldaxr(v29);
while ( __stlxr(v28 - 1, v29) );
goto LABEL_31;
}
LABEL_38:
v28 = *((_DWORD *)v13 - 2);
*((_DWORD *)v13 - 2) = v28 - 1;
goto LABEL_31;
}
operator delete(v6);
if ( v5 )
goto LABEL_4;
LABEL_23:
v26 = a1[1].__vftable;
sub_D153B8((unsigned int)v32 + 96, (char *)a2);
cocos2d::CCDictionary::removeObjectForKey((__int64)v26, &v33);
v13 = v33;
v14 = (char *)(v33 - 24);
if ( v33 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v33 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
LABEL_31:
if ( v28 <= 0 )
operator delete(v14);
goto LABEL_6;
}
goto LABEL_38;
}
LABEL_6:
v15 = *(_QWORD **)&a1[1].m_nTag;
v16 = v15[2];
if ( v16 )
{
do
{
while ( 1 )
{
std::_Rb_tree,std::less,std::allocator>::_M_erase(
(__int64)v15,
*(_QWORD **)(v16 + 24));
v18 = *(_QWORD *)(v16 + 16);
v19 = *(_QWORD *)(v16 + 32);
v20 = (void *)(v19 - 24);
if ( (__int64 *)(v19 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v19 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *(_DWORD *)(v19 - 8);
*(_DWORD *)(v19 - 8) = v22 - 1;
}
if ( v22 <= 0 )
break;
}
v17 = (void *)v16;
v16 = v18;
operator delete(v17);
if ( !v18 )
goto LABEL_15;
}
operator delete(v20);
v23 = (void *)v16;
v16 = v18;
operator delete(v23);
}
while ( v18 );
}
LABEL_15:
v15[2] = 0;
v15[3] = v15 + 1;
v15[4] = v15 + 1;
v15[5] = 0;
}