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