//
// SpriteAnimationManager::switchToFirstFrameOfAnimation from 0x590900 to 0x590af8 (504 bytes)
//
// 1 xrefs:
// > ??> @ 0x6d9f8
//
// 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::switchToFirstFrameOfAnimation(__int64 a1, const std::string *a2)
{
spriteMode AnimType; // w24
char *v6; // x0
const char *m_data; // x1
cocos2d::CCDictionary *v8; // x23
cocos2d::CCString *v9; // x0
char *CString; // x0
__int64 v11; // x22
char *v12; // x0
unsigned int *v13; // x1
int v14; // w2
unsigned int *v15; // x1
int v16; // w2
std::string v17; // [xsp+50h] [xbp+50h] BYREF
if ( !*(_DWORD *)(cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 376), a2) + 28LL) )
{
sub_D18D28(&v17, a2);
AnimType = (unsigned int)SpriteAnimationManager::getAnimType(a1, &v17);
v6 = (char *)v17.m_data.m_data - 24;
if ( (__int64 *)v17.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)((char *)v17.m_data.m_data - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v17.m_data.m_data - 2);
*((_DWORD *)v17.m_data.m_data - 2) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v6);
}
CCAnimatedSprite::switchToMode(*(CCAnimatedSprite **)(a1 + 320), AnimType);
m_data = (const char *)a2->m_data.m_data;
v8 = *(cocos2d::CCDictionary **)(a1 + 376);
v9 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s_first", m_data);
CString = (char *)cocos2d::CCString::getCString(v9);
sub_D153B8((int)&v17, CString);
v11 = cocos2d::CCDictionary::objectForKey(v8, &v17);
v12 = (char *)v17.m_data.m_data - 24;
if ( (__int64 *)v17.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)((char *)v17.m_data.m_data - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v17.m_data.m_data - 2);
*((_DWORD *)v17.m_data.m_data - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v12);
}
if ( (unsigned int)(*(_DWORD *)(v11 + 28) - 1) <= 1 )
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(*(_QWORD *)(a1 + 320) + 624LL) + 1144LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 320) + 624LL),
v11);
}
return _stack_chk_guard;
}