//
// GJSmartTemplate::savePrefab from 0x1004220d0 to 0x10042229c (460 bytes)
//
// 1 xrefs:
// > EditorUI::addObjectsToSmartTemplate @ 0x100042753
//
// 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
//
void __fastcall GJSmartTemplate::savePrefab(std::string *a1, __int128 *a2, const std::string *a3)
{
__int64 size; // rdi
cocos2d::CCObject *v6; // r12
unsigned int i; // r13d
__int64 v8; // rax
unsigned int v9; // r14d
size_t v10; // r14
const void *v11; // rax
unsigned int v12; // ebx
size_t v13; // rbx
std::string::pointer data; // rsi
size_t v15; // rdx
char *v16; // r13
int v17; // eax
__int128 v19; // [rsp+10h] [rbp-50h] BYREF
void *__p; // [rsp+20h] [rbp-40h]
std::string *v21; // [rsp+30h] [rbp-30h]
std::string::assign(a1 + 7, "");
size = a1[2].__r_.__value_.__l.__size_;
v6 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey_1(size, (char *)a2);
if ( !v6 )
{
v6 = (cocos2d::CCObject *)sub_10071F9E0(size, a2);
cocos2d::CCDictionary::setObject_1(a1[2].__r_.__value_.__l.__size_, v6, (char *)a2);
}
v21 = a1;
if ( (unsigned int)sub_100720070(v6) )
{
for ( i = 0; i < (unsigned int)sub_100720070(v6); ++i )
{
v8 = sub_1007200C0(v6, i);
v9 = *(unsigned __int8 *)(v8 + 80);
if ( (v9 & 1) != 0 )
{
v10 = *(_QWORD *)(v8 + 88);
v11 = *(const void **)(v8 + 96);
v12 = (unsigned int)a3->__r_.__value_.__l.0;
if ( (v12 & 1) == 0 )
goto LABEL_8;
}
else
{
v10 = v9 >> 1;
v11 = (const void *)(v8 + 81);
v12 = (unsigned int)a3->__r_.__value_.__l.0;
if ( (v12 & 1) == 0 )
{
LABEL_8:
v13 = v12 >> 1;
data = a3->__r_.__value_.__s.__data_;
goto LABEL_11;
}
}
v13 = a3->__r_.__value_.__l.__size_;
data = a3->__r_.__value_.__l.__data_;
LABEL_11:
v15 = v10;
if ( v13 < v10 )
v15 = v13;
if ( !memcmp(v11, data, v15) && v13 == v10 )
return;
}
}
v16 = (char *)operator new(0x70u);
cocos2d::CCObject::CCObject(v16);
*(_QWORD *)v16 = off_100934C98;
*(_OWORD *)(v16 + 56) = 0;
*(_OWORD *)(v16 + 72) = 0;
*(_OWORD *)(v16 + 88) = 0;
*((_QWORD *)v16 + 13) = 0;
v17 = dword_10099C950++;
*((_DWORD *)v16 + 26) = v17;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v16);
std::string::operator=((std::string *)(v16 + 80), a3);
std::string::operator=((std::string *)(v16 + 56), (const std::string *)a2);
sub_10071FCD0(v6, v16);
if ( (*(_BYTE *)a2 & 1) != 0 )
{
sub_100006B70(&v19, *((const void **)a2 + 2), *((_QWORD *)a2 + 1), 0.0);
}
else
{
__p = *((void **)a2 + 2);
v19 = *a2;
}
GJSmartTemplate::saveRemap(v21, &v19);
if ( (v19 & 1) != 0 )
operator delete(__p);
}