//
// ObjectManager::setup from 0x14007bfb0 to 0x14007c29c (748 bytes)
//
// 2 xrefs:
// > LoadingLayer::loadAssets @ 0x140469ec7
// > ??> @ 0x140911df8
//
// This function is hookable on this platform (idp: pc, 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 11:25:53 +0000
//
// Hidden C++ exception states: #wind=2
unsigned int __fastcall ObjectManager::setup(__int64 a1)
{
int v1; // esi
cocos2d::CCArray *v2; // rbx
unsigned int v3; // r12d
unsigned int result; // eax
cocos2d::CCString *v5; // rax
const char *CString; // rax
size_t v7; // r8
char *v8; // r13
int v9; // esi
__int128 *v10; // rdx
size_t v11; // r8
void **v12; // rcx
char *v13; // r14
unsigned __int64 v14; // r15
unsigned __int64 v15; // rbx
size_t v16; // r8
__int128 *v17; // rdi
char *v18; // rbx
__int64 v19; // rax
char v20; // bl
char *v21; // rax
__int128 *v22; // rdx
size_t v23; // r8
void *v24; // rcx
cocos2d::CCArray *v25; // [rsp+38h] [rbp-41h]
__int128 v26; // [rsp+60h] [rbp-19h] BYREF
unsigned __int64 v27; // [rsp+70h] [rbp-9h]
unsigned __int64 v28; // [rsp+78h] [rbp-1h]
void *Buf1[2]; // [rsp+80h] [rbp+7h] BYREF
unsigned __int64 v30; // [rsp+90h] [rbp+17h]
unsigned __int64 v31; // [rsp+98h] [rbp+1Fh]
v1 = 0;
v2 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(a1 + 320));
v25 = v2;
v3 = 0;
result = cocos2d::CCArray::count(v2);
if ( result )
{
do
{
v5 = cocos2d::CCArray::objectAtIndex(v2, v3);
CString = cocos2d::CCString::getCString(v5);
v26 = 0;
v27 = 0;
v28 = 0;
v7 = -1;
do
++v7;
while ( CString[v7] );
sub_14003D230(&v26, CString, v7);
v8 = (char *)sub_14003D460(0x20u);
strcpy(v8, "GlobalAnimations");
v9 = v1 | 1;
v10 = &v26;
if ( v28 > 0xF )
v10 = (__int128 *)v26;
*(_OWORD *)Buf1 = 0;
v30 = 0;
v31 = 0;
v11 = -1;
do
++v11;
while ( *((_BYTE *)v10 + v11) );
sub_14003D230(Buf1, v10, v11);
v1 = v9 | 2;
v12 = Buf1;
v13 = (char *)Buf1[0];
v14 = v31;
if ( v31 > 0xF )
v12 = (void **)Buf1[0];
v15 = v30;
v16 = v30;
if ( v30 > 0x10 )
v16 = 16;
if ( !memcmp(v12, v8, v16) && v15 == 16 )
goto LABEL_19;
v17 = &v26;
if ( v28 > 0xF )
v17 = (__int128 *)v26;
if ( v27 < 3
|| (v18 = (char *)v17 + v27, v19 = sub_1406774C0(v17, (char *)v17 + v27, &dword_140707548, 3),
(char *)v19 == v18)
|| v19 - (_QWORD)v17 == -1 )
{
v20 = 1;
}
else
{
LABEL_19:
v20 = 0;
}
if ( (v1 & 2) != 0 )
{
v1 &= ~2u;
if ( v14 > 0xF )
{
v21 = v13;
if ( v14 + 1 >= 0x1000 )
{
v13 = *((char **)v13 - 1);
if ( (unsigned __int64)(v21 - v13 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v13);
}
}
if ( (v1 & 1) != 0 )
{
v1 &= ~1u;
j_j_free(v8);
}
if ( v20 )
{
v22 = &v26;
if ( v28 > 0xF )
v22 = (__int128 *)v26;
*(_OWORD *)Buf1 = 0;
v30 = 0;
v31 = 0;
v23 = -1;
do
++v23;
while ( *((_BYTE *)v22 + v23) );
sub_14003D230(Buf1, v22, v23);
SpriteAnimationManager::createAnimations(Buf1);
}
if ( v28 > 0xF )
{
v24 = (void *)v26;
if ( v28 + 1 >= 0x1000 )
{
v24 = *(void **)(v26 - 8);
if ( (unsigned __int64)(v26 - (_QWORD)v24 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v24);
}
++v3;
v2 = v25;
result = cocos2d::CCArray::count(v25);
}
while ( v3 < result );
}
return result;
}