//
// GJSmartTemplate::logTemplateStatus from 0x100427370 to 0x1004277b1 (1089 bytes)
//
// 2 xrefs:
// > EditorUI::addObjectsToSmartTemplate @ 0x1000427da
// > SetupSmartTemplateLayer::init @ 0x1004e8158
//
// 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
//
size_t *__fastcall GJSmartTemplate::logTemplateStatus(size_t *a1, __int64 a2, double a3)
{
cocos2d::CCDictionary *v3; // rbx
cocos2d::CCNode *v4; // rax
unsigned int v5; // r14d
cocos2d::CCString *v6; // rax
const char *CString; // r15
size_t v8; // rax
size_t v9; // r13
char *v10; // r12
char v11; // r12
__int64 v12; // rax
size_t v13; // rbx
const std::string::value_type *v14; // rsi
std::string::size_type v15; // rdx
__int128 *v16; // rdi
unsigned __int8 isUnrequired; // r15
__int64 v18; // rax
__int64 v19; // r13
int v20; // eax
int v21; // eax
unsigned int v22; // r13d
unsigned int v23; // eax
cocos2d::CCString *v24; // rax
const char *v25; // rbx
size_t v26; // rax
size_t v27; // r14
size_t *v28; // r13
void *v29; // r15
size_t v30; // r12
char v32; // [rsp+0h] [rbp-F0h]
__int128 v34; // [rsp+10h] [rbp-E0h] BYREF
void *data; // [rsp+20h] [rbp-D0h]
cocos2d::CCArray *v36; // [rsp+28h] [rbp-C8h]
size_t *v37; // [rsp+30h] [rbp-C0h]
std::string::pointer *p_data; // [rsp+38h] [rbp-B8h]
std::string::value_type __s[16]; // [rsp+40h] [rbp-B0h] BYREF
void *__p; // [rsp+50h] [rbp-A0h]
__int128 __dst; // [rsp+58h] [rbp-98h] BYREF
void *v42; // [rsp+68h] [rbp-88h]
__int64 v43; // [rsp+70h] [rbp-80h]
std::string v44; // [rsp+78h] [rbp-78h] BYREF
int v45; // [rsp+90h] [rbp-60h]
int v46; // [rsp+94h] [rbp-5Ch]
int v47; // [rsp+98h] [rbp-58h]
int v48; // [rsp+9Ch] [rbp-54h]
char v49[32]; // [rsp+A0h] [rbp-50h] BYREF
v37 = a1;
v3 = cocos2d::CCDictionary::create();
v4 = cocos2d::CCNode::create();
sub_100421D40(8u, (__int64)v49, 0, (__int64)v3, v4, a3);
v36 = cocos2d::CCDictionary::allKeys(v3);
v45 = 0;
v46 = 0;
v48 = 0;
v47 = 0;
if ( (unsigned int)sub_100720070(v36) )
{
v47 = 0;
p_data = &v44.__r_.__value_.__l.__data_;
v48 = 0;
v46 = 0;
v5 = 0;
v45 = 0;
v43 = 0;
do
{
v6 = cocos2d::CCArray::stringAtIndex(v36, v5);
CString = cocos2d::CCString::getCString(v6);
v8 = strlen(CString);
if ( v8 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a3);
v9 = v8;
if ( v8 >= 0x17 )
{
v12 = v8 | 7;
v13 = 26;
if ( (v9 | 7) != 0x17 )
v13 = v12 + 1;
v10 = (char *)operator new(v13);
v42 = v10;
*(_QWORD *)&__dst = v13 | 1;
*((_QWORD *)&__dst + 1) = v9;
}
else
{
LOBYTE(__dst) = 2 * v8;
v10 = (char *)&__dst + 1;
if ( !v8 )
{
BYTE1(__dst) = 0;
v11 = __dst;
if ( (__dst & 1) == 0 )
goto LABEL_7;
goto LABEL_12;
}
}
memmove(v10, CString, v9);
v10[v9] = 0;
v11 = __dst;
if ( (__dst & 1) == 0 )
{
LABEL_7:
__p = v42;
a3 = *(double *)&__dst;
*(_OWORD *)__s = __dst;
goto LABEL_13;
}
LABEL_12:
sub_100006B70(__s, v42, *((unsigned __int64 *)&__dst + 1), a3);
LABEL_13:
*(_WORD *)&v44.__r_.__value_.__l.0 = 12546;
v44.__r_.__value_.__s.__data_[1] = 0;
if ( (__s[0] & 1) != 0 )
{
v14 = (const std::string::value_type *)__p;
v15 = *(_QWORD *)&__s[8];
}
else
{
v15 = (unsigned __int8)__s[0] >> 1;
v14 = &__s[1];
}
v16 = (__int128 *)&v44;
std::string::append(&v44, v14, v15);
if ( (__s[0] & 1) != 0 )
{
v16 = (__int128 *)__p;
operator delete(__p);
}
if ( (*(_BYTE *)&v44.__r_.__value_.__s.0 & 1) != 0 )
{
v16 = &v34;
sub_100006B70(&v34, v44.__r_.__value_.__l.__data_, v44.__r_.__value_.__l.__size_, a3);
}
else
{
data = v44.__r_.__value_.__l.__data_;
a3 = *(double *)v44.__r_.__value_.__r.__words;
v34 = *(_OWORD *)&v44.__r_.__value_.__l.0;
}
isUnrequired = GJSmartTemplate::isUnrequired(v16, &v34);
if ( (v34 & 1) != 0 )
operator delete(data);
v18 = cocos2d::CCDictionary::objectForKey_1(*(_QWORD *)(a2 + 56), (char *)&v44);
v19 = v18;
if ( v18 )
{
v20 = sub_100720070(v18);
++v47;
v48 += isUnrequired ^ 1;
if ( v20 )
{
v21 = sub_100720070(v19);
++v46;
v45 += v21;
v22 = v43;
if ( isUnrequired )
v22 = v43;
if ( (*(_BYTE *)&v44.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_34;
goto LABEL_33;
}
}
else
{
++v47;
v48 += isUnrequired ^ 1;
}
v22 = v43 + 1;
if ( isUnrequired )
v22 = v43;
if ( (*(_BYTE *)&v44.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_34;
LABEL_33:
operator delete(v44.__r_.__value_.__l.__data_);
LABEL_34:
if ( (v11 & 1) != 0 )
operator delete(v42);
v23 = sub_100720070(v36);
++v5;
v43 = v22;
}
while ( v5 < v23 );
}
v24 = (cocos2d::CCString *)sub_1007AB580("Defined: %i / %i(%i), Variations : %i, Required Missing : %i", v32);
v25 = cocos2d::CCString::getCString(v24);
v26 = strlen(v25);
if ( v26 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a3);
v27 = v26;
if ( v26 >= 0x17 )
{
v30 = 26;
if ( (v26 | 7) != 0x17 )
v30 = (v26 | 7) + 1;
v29 = operator new(v30);
v28 = v37;
v37[2] = (size_t)v29;
*v28 = v30 | 1;
v28[1] = v27;
}
else
{
v28 = v37;
*(_BYTE *)v37 = 2 * v26;
v29 = (char *)v28 + 1;
if ( !v26 )
goto LABEL_45;
}
memmove(v29, v25, v27);
LABEL_45:
*((_BYTE *)v29 + v27) = 0;
return v28;
}