//
// CCPartAnimSprite::initWithAnimDesc from 0x10035d020 to 0x10035d816 (2038 bytes)
//
// 1 xrefs:
// > CCPartAnimSprite::createWithAnimDesc @ 0x10035cfc7
//
// 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 12:28:54 +0000
//
__int64 __fastcall CCPartAnimSprite::initWithAnimDesc(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 v4; // rax
_QWORD *v5; // r14
_QWORD *v6; // rax
__int64 v7; // rax
__int64 v8; // rax
int v9; // esi
size_t v10; // rbx
size_t v11; // rdi
void *v12; // rax
void *v13; // r14
_QWORD *v14; // r15
void *v15; // r14
size_t v16; // rax
size_t v17; // rbx
char *v18; // r15
size_t v19; // r12
__int64 v20; // rbx
void *v21; // rax
const char *CString; // r12
size_t v23; // rax
size_t v24; // r15
char *v25; // r14
void *v26; // rax
__int64 v27; // r15
char *v28; // r14
__int64 v29; // rax
size_t v30; // r13
bool v31; // r15
char *v32; // r12
__int64 v33; // r14
__int64 v34; // rbx
const char *v35; // r15
size_t v36; // rax
size_t v37; // r14
char *v38; // r13
__int64 v39; // rbx
__int64 v40; // rax
size_t v41; // rbx
std::string __str; // [rsp+10h] [rbp-2B0h] BYREF
__int64 v45; // [rsp+28h] [rbp-298h]
__int64 v46; // [rsp+30h] [rbp-290h]
_QWORD *v47; // [rsp+38h] [rbp-288h]
unsigned int v48; // [rsp+40h] [rbp-280h]
int v49; // [rsp+44h] [rbp-27Ch]
__int128 __dst; // [rsp+48h] [rbp-278h] BYREF
void *__s1; // [rsp+58h] [rbp-268h]
__int128 __s2; // [rsp+60h] [rbp-260h] BYREF
void *v53; // [rsp+70h] [rbp-250h]
unsigned __int8 v54; // [rsp+7Eh] [rbp-242h]
unsigned __int8 v55; // [rsp+7Fh] [rbp-241h]
__int128 __len; // [rsp+80h] [rbp-240h] BYREF
void *__p; // [rsp+90h] [rbp-230h]
_QWORD v58[63]; // [rsp+98h] [rbp-228h] BYREF
v49 = a4;
v47 = (_QWORD *)a1;
v55 = cocos2d::CCSprite::initWithTexture_1(a1, a3, (__int64)&unk_100BE3018);
if ( v55 )
{
v4 = sub_1007FE900(a1);
v5 = v47;
v47[79] = v4;
cocos2d::CCObject::retain(v4);
v6 = cocos2d::CCDictionary::create();
v5[75] = v6;
cocos2d::CCObject::retain(v6);
v7 = CCAnimateFrameCache::sharedSpriteFrameCache();
v8 = CCAnimateFrameCache::addSpriteFramesWithFile(v7, a2);
*((_BYTE *)v5 + 616) = 1;
LOBYTE(__len) = 24;
strcpy((char *)&__len + 1, "usedTextures");
v46 = cocos2d::CCDictionary::objectForKey(v8, (char *)&__len);
if ( (__len & 1) != 0 )
operator delete(__p);
if ( (unsigned int)cocos2d::CCDictionary::count(v46) )
{
v54 = v49 ^ 1;
v9 = 0;
while ( 1 )
{
*((_QWORD *)&__len + 1) = 500;
__p = v58;
*(_QWORD *)&__len = 8;
v58[0] = 0x5F65727574786574LL;
sub_100032CB0((__int64)&__len, v9);
v10 = __len;
if ( *((_QWORD *)&__len + 1) >= (unsigned __int64)(__len + 1) )
{
v13 = __p;
}
else
{
v11 = *((_QWORD *)&__len + 1) + (*((_QWORD *)&__len + 1) >> 1);
if ( v11 <= (__int64)__len + 1 )
v11 = __len + 1;
*((_QWORD *)&__len + 1) = v11;
v12 = operator new[](v11);
v13 = v12;
v14 = __p;
if ( v10 )
memmove(v12, __p, v10);
if ( v14 != v58 && v14 != nullptr )
operator delete[](v14);
__p = v13;
}
*((_BYTE *)v13 + v10) = 0;
v15 = __p;
v16 = strlen((const char *)__p);
if ( v16 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v17 = v16;
if ( v16 >= 0x17 )
break;
LOBYTE(__dst) = 2 * v16;
v18 = (char *)&__dst + 1;
if ( v16 )
goto LABEL_22;
LABEL_23:
v18[v17] = 0;
v20 = cocos2d::CCDictionary::objectForKey(v46, (char *)&__dst);
if ( (__dst & 1) != 0 )
operator delete(__s1);
LOBYTE(__s2) = 14;
DWORD1(__s2) = 1701999988;
*(_DWORD *)((char *)&__s2 + 1) = 1954047348;
BYTE8(__s2) = 0;
v21 = cocos2d::CCDictionary::valueForKey(v20, (__int64)&__s2);
CString = (const char *)cocos2d::CCString::getCString(v21);
v23 = strlen(CString);
if ( v23 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v24 = v23;
if ( v23 >= 0x17 )
{
v29 = v23 | 7;
v30 = 26;
if ( (v24 | 7) != 0x17 )
v30 = v29 + 1;
v25 = (char *)operator new(v30);
__s1 = v25;
*(_QWORD *)&__dst = v30 | 1;
*((_QWORD *)&__dst + 1) = v24;
}
else
{
LOBYTE(__dst) = 2 * v23;
v25 = (char *)&__dst + 1;
if ( !v23 )
{
BYTE1(__dst) = 0;
if ( (__s2 & 1) == 0 )
goto LABEL_30;
LABEL_29:
operator delete(v53);
goto LABEL_30;
}
}
memmove(v25, CString, v24);
v25[v24] = 0;
if ( (__s2 & 1) != 0 )
goto LABEL_29;
LABEL_30:
LOBYTE(__s2) = 6;
*(_DWORD *)((char *)&__s2 + 1) = 6775156;
v26 = cocos2d::CCDictionary::valueForKey(v20, (__int64)&__s2);
v48 = cocos2d::CCString::intValue(v26);
if ( (__s2 & 1) != 0 )
operator delete(v53);
LOWORD(__s2) = 12290;
BYTE2(__s2) = 0;
if ( (__dst & 1) != 0 )
{
v27 = *((_QWORD *)&__dst + 1);
v28 = (char *)__s1;
}
else
{
v27 = (unsigned __int8)__dst >> 1;
v28 = (char *)&__dst + 1;
}
v31 = memcmp(v28, (char *)&__s2 + 1, v27 != 0) == 0 && v27 == 1;
if ( !(_BYTE)v49 && !v31 )
{
v32 = (char *)CCSpritePart::createWithSpriteFrameName(v28);
goto LABEL_52;
}
v32 = (char *)operator new(0x290u);
cocos2d::CCSprite::CCSprite((__int64)v32);
*(_OWORD *)(v32 + 600) = 0;
*(_DWORD *)(v32 + 615) = 0;
*(_QWORD *)v32 = off_100B25F48;
*((_QWORD *)v32 + 40) = off_100B26440;
*((_QWORD *)v32 + 43) = off_100B264C0;
v32[619] = 0;
*((_OWORD *)v32 + 39) = 0;
*((_OWORD *)v32 + 40) = 0;
if ( (unsigned __int8)CCSpritePlus::initWithTexture(v32, a3) )
{
cocos2d::CCObject::autorelease(v32);
if ( v54 | v31 )
goto LABEL_52;
}
else
{
(*(void (__fastcall **)(char *))(*(_QWORD *)v32 + 16LL))(v32);
v32 = nullptr;
if ( v54 | v31 )
goto LABEL_52;
}
if ( (__dst & 1) != 0 )
{
sub_10001AD30(&__str, __s1, *((unsigned __int64 *)&__dst + 1));
}
else
{
__str.__r_.__value_.__r.__words[2] = (std::string::size_type)__s1;
*(_OWORD *)&__str.__r_.__value_.__l.0 = __dst;
}
std::string::operator=((std::string *)v32 + 26, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
LABEL_52:
(*(void (__fastcall **)(char *, _QWORD))(*(_QWORD *)v32 + 72LL))(v32, v48);
LOBYTE(__s2) = 16;
strcpy((char *)&__s2 + 1, "customID");
v33 = cocos2d::CCDictionary::objectForKey(v20, (char *)&__s2);
if ( (__s2 & 1) != 0 )
operator delete(v53);
if ( !v33 )
goto LABEL_67;
LOBYTE(__s2) = 16;
strcpy((char *)&__s2 + 1, "customID");
v34 = cocos2d::CCDictionary::objectForKey(v20, (char *)&__s2);
if ( (__s2 & 1) != 0 )
operator delete(v53);
v45 = v47[75];
v35 = (const char *)cocos2d::CCString::getCString(v34);
v36 = strlen(v35);
if ( v36 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v37 = v36;
if ( v36 >= 0x17 )
{
v40 = v36 | 7;
v41 = 26;
if ( (v37 | 7) != 0x17 )
v41 = v40 + 1;
v38 = (char *)operator new(v41);
v53 = v38;
*(_QWORD *)&__s2 = v41 | 1;
*((_QWORD *)&__s2 + 1) = v37;
v39 = v45;
LABEL_64:
memmove(v38, v35, v37);
goto LABEL_65;
}
LOBYTE(__s2) = 2 * v36;
v38 = (char *)&__s2 + 1;
v39 = v45;
if ( v36 )
goto LABEL_64;
LABEL_65:
v38[v37] = 0;
cocos2d::CCDictionary::setObject(v39, (__int64)v32, (char *)&__s2);
if ( (__s2 & 1) != 0 )
operator delete(v53);
LABEL_67:
sub_1007FEBF0(v47[79], v32);
(*(void (__fastcall **)(_QWORD *, char *, _QWORD, _QWORD))(*v47 + 472LL))(v47, v32, 0, v48);
(*(void (__fastcall **)(char *, _QWORD))(*(_QWORD *)v32 + 344LL))(v32, 0);
if ( (__dst & 1) != 0 )
operator delete(__s1);
if ( __p != v58 && __p != nullptr )
operator delete[](__p);
if ( ++v9 >= (unsigned int)cocos2d::CCDictionary::count(v46) )
return v55;
}
v19 = (v16 | 7) + 1;
if ( (v16 | 7) == 0x17 )
v19 = 26;
v18 = (char *)operator new(v19);
__s1 = v18;
*(_QWORD *)&__dst = v19 | 1;
*((_QWORD *)&__dst + 1) = v17;
LABEL_22:
memmove(v18, v15, v17);
goto LABEL_23;
}
}
return v55;
}