//
// SpriteAnimationManager::initWithOwner from 0x59167c to 0x5919d0 (852 bytes)
//
// 2 xrefs:
// > SpriteAnimationManager::createWithOwner @ 0x591a68
// > ??> @ 0x4b3a8
//
// 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::initWithOwner(_QWORD *a1, __int64 a2, __int64 a3)
{
const char *v5; // x0
cocos2d::CCDictionary *v6; // x0
cocos2d::CCDictionary *v7; // x0
cocos2d::CCDictionary *v8; // x0
cocos2d::CCDictionary *v9; // x0
__int64 v10; // x27
cocos2d::CCObject *v11; // x22
char *v12; // x0
cocos2d::CCDictionary *v13; // x0
__int64 v14; // x27
cocos2d::CCObject *v15; // x26
char *v16; // x0
char *v17; // x0
char *v18; // x19
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x1
int v23; // w2
unsigned int *v24; // x1
int v25; // w2
unsigned int *v26; // x21
int v27; // w0
const char *v28[2]; // [xsp+70h] [xbp+70h] BYREF
v5 = (const char *)_stack_chk_guard;
a1[40] = a2;
v28[1] = v5;
v6 = cocos2d::CCDictionary::create();
a1[47] = v6;
cocos2d::CCObject::retain(v6);
v7 = cocos2d::CCDictionary::create();
a1[43] = v7;
cocos2d::CCObject::retain(v7);
v8 = cocos2d::CCDictionary::create();
a1[46] = v8;
cocos2d::CCObject::retain(v8);
v9 = cocos2d::CCDictionary::create();
a1[41] = v9;
cocos2d::CCObject::retain(v9);
v10 = a1[41];
v11 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)&qword_60 + 3);
sub_D153B8((int)v28, "not_used");
cocos2d::CCDictionary::setObject(v10, v11);
v12 = (char *)(v28[0] - 24);
if ( (__int64 *)v28[0] - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v28[0] - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v28[0] - 2);
*((_DWORD *)v28[0] - 2) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v12);
}
v13 = cocos2d::CCDictionary::create();
a1[42] = v13;
cocos2d::CCObject::retain(v13);
v14 = a1[42];
v15 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)&qword_60 + 3);
sub_D153B8((int)v28, "not_used");
cocos2d::CCDictionary::setObject(v14, v15);
v16 = (char *)(v28[0] - 24);
if ( (__int64 *)v28[0] - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v28[0] - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *((_DWORD *)v28[0] - 2);
*((_DWORD *)v28[0] - 2) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v16);
}
sub_D1798C(a1 + 44, "not_used", 8);
sub_D1798C(a1 + 48, "not_used", 8);
sub_D1798C(a1 + 49, "not_used", 8);
sub_D18D28(v28, a3);
SpriteAnimationManager::createAnimations(v28);
v17 = (char *)(v28[0] - 24);
if ( (__int64 *)v28[0] - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)(v28[0] - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v28[0] - 2);
*((_DWORD *)v28[0] - 2) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v17);
}
sub_D18D28(v28, a3);
SpriteAnimationManager::loadAnimations(a1, v28);
v18 = (char *)(v28[0] - 24);
if ( (__int64 *)v28[0] - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)(v28[0] - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *((_DWORD *)v28[0] - 2);
*((_DWORD *)v28[0] - 2) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v18);
}
return 1;
}