//
// SpriteAnimationManager::playSoundForAnimation from 0x58f7fc to 0x58f9e0 (484 bytes)
//
// 2 xrefs:
// > SpriteAnimationManager::executeAnimation @ 0x58fe04
// > ??> @ 0x48c78
//
// 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
//
__int64 __fastcall SpriteAnimationManager::playSoundForAnimation(__int64 a1, const std::string *a2)
{
cocos2d::CCString *v4; // x23
cocos2d::CCString *v5; // x0
cocos2d::CCDictionary *v6; // x22
char *CString; // x0
cocos2d::CCString *v8; // x0
__int128 v9; // q0
char *v10; // x0
char *v12; // x0
char *v13; // x21
unsigned int *v14; // x20
int v15; // w0
unsigned int *v16; // x1
int v17; // w2
_QWORD v18[2]; // [xsp+0h] [xbp+0h] BYREF
__int128 v19; // [xsp+40h] [xbp+40h]
std::string v20; // [xsp+60h] [xbp+60h] BYREF
v4 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 344), a2);
if ( v4 )
{
v5 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s%s",
(const char *)a2->m_data.m_data,
"delay");
v6 = *(cocos2d::CCDictionary **)(a1 + 344);
CString = (char *)cocos2d::CCString::getCString(v5);
sub_D153B8((unsigned int)v18 + 96, CString);
v8 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v6, &v20);
*(float *)&v9 = cocos2d::CCString::floatValue(v8);
v10 = (char *)v20.m_data.m_data - 24;
if ( (__int64 *)v20.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v20.m_data.m_data - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v20.m_data.m_data - 2);
*((_DWORD *)v20.m_data.m_data - 2) = v17 - 1;
}
if ( v17 <= 0 )
{
v19 = v9;
operator delete(v10);
LODWORD(v9) = v19;
}
}
if ( *(float *)&v9 == 0.0 )
{
v12 = (char *)cocos2d::CCString::getCString(v4);
sub_D153B8((unsigned int)v18 + 96, v12);
SpriteAnimationManager::playSound();
v13 = (char *)v20.m_data.m_data - 24;
if ( (__int64 *)v20.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)((char *)v20.m_data.m_data - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v20.m_data.m_data - 2);
*((_DWORD *)v20.m_data.m_data - 2) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v13);
}
}
}
return _stack_chk_guard;
}