//
// MusicDownloadManager::deleteCustomSFXObject from 0x960d2c to 0x96107c (848 bytes)
//
// 4 xrefs:
// > MusicDownloadManager::deleteCustomSFXObject @ 0x960e64
// > MusicDownloadManager::importCustomSFXSetup @ 0x9705b0
// > SFXBrowser::executeBatchDelete @ 0xb902dc
// > ??> @ 0x52c78
//
// 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 12:57:33 +0000
//
__int64 __fastcall MusicDownloadManager::deleteCustomSFXObject(MusicDownloadManager *this, int a2)
{
__int64 CustomSFXObject; // x0
__int64 v4; // x19
__int64 CustomSFXFolderForID; // x0
cocos2d::CCArray *v6; // x0
__int64 v7; // x0
unsigned int *v8; // x1
__int64 *v9; // x19
__int64 *v10; // x20
__int64 v11; // x1
int v12; // w1
char *i; // x0
_DWORD *v14; // x1
__int64 v15; // x19
__int64 v16; // x20
char *v17; // x0
__int64 v18; // x7
unsigned __int64 v19; // x4
char *v20; // x3
int v21; // w1
__int64 v22; // x6
__int64 v23; // x5
char *v24; // x2
char *v26; // x0
__int64 v27; // x6
_BOOL4 v28; // w8
int v29; // w5
unsigned __int64 v30; // x1
unsigned __int64 v31; // x8
__int128 *v32; // x3
_OWORD *v33; // x6
unsigned __int64 v34; // x1
unsigned __int64 v35; // x5
__int128 v36; // t1
int v37; // w5
char *v38; // x0
int v39; // w5
int v40; // [xsp+4Ch] [xbp+4Ch] BYREF
void *v41; // [xsp+50h] [xbp+50h] BYREF
char *v42; // [xsp+58h] [xbp+58h]
char *v43; // [xsp+60h] [xbp+60h]
v40 = a2;
if ( a2 > 1 )
{
CustomSFXObject = MusicDownloadManager::getCustomSFXObject(this, a2);
v4 = CustomSFXObject;
if ( CustomSFXObject )
{
CustomSFXFolderForID = MusicDownloadManager::getCustomSFXFolderForID(this, *(_DWORD *)(CustomSFXObject + 60));
if ( CustomSFXFolderForID )
{
v6 = *(cocos2d::CCArray **)(CustomSFXFolderForID + 152);
if ( v6 )
cocos2d::CCArray::removeObject(v6, (cocos2d::CCObject *)v4, 1);
}
if ( *(_BYTE *)(v4 + 72) )
{
v7 = *(_QWORD *)(v4 + 152);
v41 = nullptr;
v42 = nullptr;
v43 = nullptr;
if ( v7 )
{
v8 = *(unsigned int **)(v7 + 56);
if ( *v8 )
{
v9 = *((__int64 **)v8 + 2);
v10 = &v9[*v8 - 1];
if ( v9 <= v10 )
{
v11 = *v9;
if ( *v9 )
{
LABEL_17:
std::vector::__push_back_slow_path((__int64)&v41, (_DWORD *)(v11 + 76));
++v9;
for ( i = v42; v10 >= v9; v42 = i )
{
v11 = *v9;
if ( !*v9 )
break;
if ( i == v43 )
goto LABEL_17;
v12 = *(_DWORD *)(v11 + 76);
if ( i )
{
*(_DWORD *)i = v12;
i = v42;
}
++v9;
i += 4;
}
v14 = v41;
v15 = (i - (_BYTE *)v41) >> 2;
if ( v15 )
{
v16 = 0;
while ( 1 )
{
MusicDownloadManager::deleteCustomSFXObject(this, v14[v16++]);
if ( v16 == v15 )
break;
v14 = v41;
}
v17 = (char *)v41;
}
else
{
v17 = (char *)v41;
}
if ( v17 )
{
if ( v42 != v17 )
v42 += 4 * ~((unsigned __int64)(v42 - 4 - v17) >> 2);
operator delete(v17);
}
}
}
}
}
}
std::__hash_table,std::equal_to,std::allocator>::__erase_unique(
(__int64 *)this + 81,
&v40);
v18 = *((_QWORD *)this + 91);
v19 = 0;
v20 = *((char **)this + 92);
v21 = v40;
v22 = (__int64)&v20[-v18];
while ( v19 < v22 >> 3 )
{
while ( 1 )
{
v23 = 8 * v19;
v24 = (char *)(v18 + 8 * v19);
if ( *((_DWORD *)v24 + 1) == v21 )
break;
if ( ++v19 >= v22 >> 3 )
goto LABEL_31;
}
v26 = v24 + 8;
if ( v24 + 8 != v20 )
{
v27 = v23 + 8;
v28 = __OFSUB__(v23 + 8, v23 + 32);
v29 = v28 || v23 >= v23 + 40;
v30 = (unsigned __int64)(v20 - (v24 + 16)) >> 3;
v31 = v30 + 1;
if ( v29 && v31 > 5 )
{
v32 = (__int128 *)(v18 + v27);
v33 = (_OWORD *)(v18 + 8 * v19);
v34 = ((v30 - 1) >> 1) + 1;
v35 = 0;
do
{
v36 = *v32++;
++v35;
*v33++ = v36;
}
while ( v35 < v34 );
if ( v31 != 2 * v34 )
{
*(_DWORD *)&v24[16 * v34] = *(_DWORD *)&v26[16 * v34];
*(_DWORD *)&v24[16 * v34 + 4] = *(_DWORD *)&v26[16 * v34 + 4];
}
}
else
{
do
{
v37 = *(_DWORD *)v26;
v38 = v26 + 8;
*((_DWORD *)v38 - 4) = v37;
*((_DWORD *)v38 - 3) = *((_DWORD *)v38 - 1);
if ( v38 == v20 )
break;
v39 = *(_DWORD *)v38;
v26 = v38 + 8;
*((_DWORD *)v26 - 4) = v39;
*((_DWORD *)v26 - 3) = *((_DWORD *)v26 - 1);
}
while ( v26 != v20 );
}
v20 = *((char **)this + 92);
v24 += 8 * v31;
v18 = *((_QWORD *)this + 91);
v21 = v40;
}
if ( v24 == v20 )
{
v20 = v24;
v22 = (__int64)&v24[-v18];
}
else
{
v20 += 8 * ~((unsigned __int64)(v20 - 8 - v24) >> 3);
*((_QWORD *)this + 92) = v20;
v22 = (__int64)&v20[-v18];
}
}
LABEL_31:
cocos2d::CCDictionary::removeObjectForKey(*((cocos2d::CCDictionary **)this + 103), v21);
}
}
return _stack_chk_guard;
}