//
// GJSmartTemplate::saveRemap from 0x9d2604 to 0x9d34ac (3752 bytes)
//
// 3 xrefs:
// > GJSmartTemplate::dataLoaded @ 0x9d5820
// > GJSmartTemplate::savePrefab @ 0x9d5c34
// > ??> @ 0x79920
//
// 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
//
__int64 __fastcall GJSmartTemplate::saveRemap(cocos2d::CCDictionary **a1)
{
unsigned __int8 *v2; // x0
bool (__fastcall **p_canEncode)(cocos2d::CCObject *__hidden); // x0
char *v4; // x0
void *v5; // x0
void *v6; // x0
void *v7; // x0
void *v8; // x0
void *v9; // x0
void *v10; // x0
void *v11; // x0
unsigned __int64 v12; // x24
unsigned __int64 v13; // x28
size_t v14; // x2
unsigned __int64 v15; // x24
bool (__fastcall **v16)(cocos2d::CCObject *__hidden); // x0
char *v17; // x0
void *v18; // x0
void *v19; // x0
void *v20; // x0
void *v21; // x0
__int64 v22; // x28
unsigned __int64 v23; // x23
size_t v24; // x2
unsigned __int64 v25; // x23
char *v26; // x0
void *v27; // x0
unsigned __int8 *v28; // x0
char *v29; // x0
char *v30; // x0
void *v31; // x0
char *v32; // x0
char *v33; // x0
unsigned int *v35; // x28
int v36; // w1
unsigned int *v37; // x1
int v38; // w2
unsigned int *v39; // x1
int v40; // w2
unsigned int *v41; // x1
int v42; // w2
unsigned int *v43; // x1
int v44; // w2
unsigned int *v45; // x1
int v46; // w2
unsigned int *v47; // x1
int v48; // w2
unsigned int *v49; // x1
int v50; // w2
unsigned int *v51; // x1
int v52; // w2
unsigned int *v53; // x1
int v54; // w2
unsigned int *v55; // x1
int v56; // w2
unsigned int *v57; // x1
int v58; // w2
unsigned int *v59; // x1
int v60; // w2
unsigned int *v61; // x1
int v62; // w2
unsigned int *v63; // x1
int v64; // w2
unsigned int *v65; // x1
int v66; // w2
unsigned int *v67; // x1
int v68; // w2
unsigned int *p_setTag; // x1
int setTag; // w2
unsigned int *v71; // x1
int v72; // w2
unsigned int *v73; // x1
int v74; // w2
unsigned int *v75; // x1
int v76; // w2
unsigned int *v77; // x1
int v78; // w2
unsigned int *v79; // x1
int v80; // w2
unsigned int *v81; // x1
int v82; // w2
unsigned __int64 v83; // [xsp+68h] [xbp+68h]
void *v84; // [xsp+80h] [xbp+80h] BYREF
std::string v85; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCString v86; // [xsp+90h] [xbp+90h] BYREF
__int64 v87; // [xsp+D0h] [xbp+D0h] BYREF
std::string v88; // [xsp+D8h] [xbp+D8h] BYREF
cocos2d::CCString v89; // [xsp+E0h] [xbp+E0h] BYREF
_DWORD *v90; // [xsp+120h] [xbp+120h] BYREF
std::string v91; // [xsp+128h] [xbp+128h] BYREF
unsigned __int8 *v92; // [xsp+130h] [xbp+130h] BYREF
sub_D18D28(&v92);
GJSmartTemplate::getSimplifiedKey(&v92, (__int64 *)&v84);
v2 = v92 - 24;
if ( v92 - 24 != (unsigned __int8 *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(v92 - 8);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *((_DWORD *)v92 - 2);
*((_DWORD *)v92 - 2) = v54 - 1;
}
if ( v54 <= 0 )
operator delete(v2);
}
sub_D18D28(&v85);
sub_D18D28(&v86);
GJSmartTemplate::saveRemapToDict((__int64)a1, &v85, &v86, a1[8]);
p_canEncode = &v86.__vftable[-1].canEncode;
if ( (__int64 *)&v86.__vftable[-1].canEncode != &qword_124B6B0 )
{
if ( &pthread_create )
{
p_setTag = (unsigned int *)&v86.__vftable[-1].setTag;
do
setTag = __ldaxr(p_setTag);
while ( __stlxr(setTag - 1, p_setTag) );
}
else
{
setTag = (int)v86.__vftable[-1].setTag;
LODWORD(v86.__vftable[-1].setTag) = setTag - 1;
}
if ( setTag <= 0 )
operator delete(p_canEncode);
}
v4 = (char *)v85.m_data.m_data - 24;
if ( (__int64 *)v85.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v71 = (unsigned int *)((char *)v85.m_data.m_data - 8);
do
v72 = __ldaxr(v71);
while ( __stlxr(v72 - 1, v71) );
}
else
{
v72 = *((_DWORD *)v85.m_data.m_data - 2);
*((_DWORD *)v85.m_data.m_data - 2) = v72 - 1;
}
if ( v72 <= 0 )
operator delete(v4);
}
sub_D18D28(&v86.m_uID);
GJSmartTemplate::getNoCornerKey((const void **)&v86.m_uID, &v86.m_nTag);
sub_D18D28(&v86.m_uAutoReleaseCount);
GJSmartTemplate::saveRemapToDict(
(__int64)a1,
(const std::string *)&v86.m_nTag,
(cocos2d::CCString *)&v86.m_uAutoReleaseCount,
a1[9]);
v5 = (void *)(*(_QWORD *)&v86.m_uAutoReleaseCount - 24LL);
if ( (__int64 *)(*(_QWORD *)&v86.m_uAutoReleaseCount - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v63 = (unsigned int *)(*(_QWORD *)&v86.m_uAutoReleaseCount - 8LL);
do
v64 = __ldaxr(v63);
while ( __stlxr(v64 - 1, v63) );
}
else
{
v64 = *(_DWORD *)(*(_QWORD *)&v86.m_uAutoReleaseCount - 8LL);
*(_DWORD *)(*(_QWORD *)&v86.m_uAutoReleaseCount - 8LL) = v64 - 1;
}
if ( v64 <= 0 )
operator delete(v5);
}
v6 = (void *)(*(_QWORD *)&v86.m_nTag - 24LL);
if ( (__int64 *)(*(_QWORD *)&v86.m_nTag - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v65 = (unsigned int *)(*(_QWORD *)&v86.m_nTag - 8LL);
do
v66 = __ldaxr(v65);
while ( __stlxr(v66 - 1, v65) );
}
else
{
v66 = *(_DWORD *)(*(_QWORD *)&v86.m_nTag - 8LL);
*(_DWORD *)(*(_QWORD *)&v86.m_nTag - 8LL) = v66 - 1;
}
if ( v66 <= 0 )
operator delete(v6);
}
v7 = (void *)(*(_QWORD *)&v86.m_uID - 24LL);
if ( (__int64 *)(*(_QWORD *)&v86.m_uID - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v67 = (unsigned int *)(*(_QWORD *)&v86.m_uID - 8LL);
do
v68 = __ldaxr(v67);
while ( __stlxr(v68 - 1, v67) );
}
else
{
v68 = *(_DWORD *)(*(_QWORD *)&v86.m_uID - 8LL);
*(_DWORD *)(*(_QWORD *)&v86.m_uID - 8LL) = v68 - 1;
}
if ( v68 <= 0 )
operator delete(v7);
}
sub_D18D28(&v86.m_uIndexInArray);
GJSmartTemplate::getNoCornerKey((const void **)&v86.m_uIndexInArray, &v86.m_unknown2);
sub_D18D28(&v86.m_uOrderOfArrival);
GJSmartTemplate::saveRemapToDict(
(__int64)a1,
(const std::string *)&v86.m_unknown2,
(cocos2d::CCString *)&v86.m_uOrderOfArrival,
a1[9]);
v8 = (void *)(*(_QWORD *)&v86.m_uOrderOfArrival - 24LL);
if ( (__int64 *)(*(_QWORD *)&v86.m_uOrderOfArrival - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)(*(_QWORD *)&v86.m_uOrderOfArrival - 8LL);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *(_DWORD *)(*(_QWORD *)&v86.m_uOrderOfArrival - 8LL);
*(_DWORD *)(*(_QWORD *)&v86.m_uOrderOfArrival - 8LL) = v58 - 1;
}
if ( v58 <= 0 )
operator delete(v8);
}
v9 = (void *)(*(_QWORD *)&v86.m_unknown2 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v86.m_unknown2 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v59 = (unsigned int *)(*(_QWORD *)&v86.m_unknown2 - 8LL);
do
v60 = __ldaxr(v59);
while ( __stlxr(v60 - 1, v59) );
}
else
{
v60 = *(_DWORD *)(*(_QWORD *)&v86.m_unknown2 - 8LL);
*(_DWORD *)(*(_QWORD *)&v86.m_unknown2 - 8LL) = v60 - 1;
}
if ( v60 <= 0 )
operator delete(v9);
}
v10 = (void *)(*(_QWORD *)&v86.m_uIndexInArray - 24LL);
if ( (__int64 *)(*(_QWORD *)&v86.m_uIndexInArray - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v61 = (unsigned int *)(*(_QWORD *)&v86.m_uIndexInArray - 8LL);
do
v62 = __ldaxr(v61);
while ( __stlxr(v62 - 1, v61) );
}
else
{
v62 = *(_DWORD *)(*(_QWORD *)&v86.m_uIndexInArray - 8LL);
*(_DWORD *)(*(_QWORD *)&v86.m_uIndexInArray - 8LL) = v62 - 1;
}
if ( v62 <= 0 )
operator delete(v10);
}
sub_D18D28(&v87);
GJSmartTemplate::getVerySimplifiedKey(&v87, (__int64 *)&v86.m_sString);
v11 = (void *)(v87 - 24);
if ( (__int64 *)(v87 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)(v87 - 8);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *(_DWORD *)(v87 - 8);
*(_DWORD *)(v87 - 8) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v11);
}
v12 = *((_QWORD *)v84 - 3);
v13 = *((_QWORD *)v86.m_sString.m_data.m_data - 3);
if ( v13 > v12 )
v14 = *((_QWORD *)v84 - 3);
else
v14 = *((_QWORD *)v86.m_sString.m_data.m_data - 3);
if ( memcmp(v84, v86.m_sString.m_data.m_data, v14) || (v15 = v12 - v13, v15 + 0x80000000 > 0xFFFFFFFF) || (_DWORD)v15 )
{
sub_D18D28(&v88);
sub_D18D28(&v89);
GJSmartTemplate::saveRemapToDict((__int64)a1, &v88, &v89, a1[10]);
v16 = &v89.__vftable[-1].canEncode;
if ( (__int64 *)&v89.__vftable[-1].canEncode != &qword_124B6B0 )
{
if ( &pthread_create )
{
v37 = (unsigned int *)&v89.__vftable[-1].setTag;
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = (int)v89.__vftable[-1].setTag;
LODWORD(v89.__vftable[-1].setTag) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v16);
}
v17 = (char *)v88.m_data.m_data - 24;
if ( (__int64 *)v88.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v39 = (unsigned int *)((char *)v88.m_data.m_data - 8);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *((_DWORD *)v88.m_data.m_data - 2);
*((_DWORD *)v88.m_data.m_data - 2) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v17);
}
sub_D18D28(&v89.m_uID);
GJSmartTemplate::getNoCornerKey((const void **)&v89.m_uID, &v89.m_nTag);
sub_D18D28(&v89.m_uAutoReleaseCount);
GJSmartTemplate::saveRemapToDict(
(__int64)a1,
(const std::string *)&v89.m_nTag,
(cocos2d::CCString *)&v89.m_uAutoReleaseCount,
a1[11]);
v18 = (void *)(*(_QWORD *)&v89.m_uAutoReleaseCount - 24LL);
if ( (__int64 *)(*(_QWORD *)&v89.m_uAutoReleaseCount - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)(*(_QWORD *)&v89.m_uAutoReleaseCount - 8LL);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *(_DWORD *)(*(_QWORD *)&v89.m_uAutoReleaseCount - 8LL);
*(_DWORD *)(*(_QWORD *)&v89.m_uAutoReleaseCount - 8LL) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v18);
}
v19 = (void *)(*(_QWORD *)&v89.m_nTag - 24LL);
if ( (__int64 *)(*(_QWORD *)&v89.m_nTag - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v43 = (unsigned int *)(*(_QWORD *)&v89.m_nTag - 8LL);
do
v44 = __ldaxr(v43);
while ( __stlxr(v44 - 1, v43) );
}
else
{
v44 = *(_DWORD *)(*(_QWORD *)&v89.m_nTag - 8LL);
*(_DWORD *)(*(_QWORD *)&v89.m_nTag - 8LL) = v44 - 1;
}
if ( v44 <= 0 )
operator delete(v19);
}
v20 = (void *)(*(_QWORD *)&v89.m_uID - 24LL);
if ( (__int64 *)(*(_QWORD *)&v89.m_uID - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v45 = (unsigned int *)(*(_QWORD *)&v89.m_uID - 8LL);
do
v46 = __ldaxr(v45);
while ( __stlxr(v46 - 1, v45) );
}
else
{
v46 = *(_DWORD *)(*(_QWORD *)&v89.m_uID - 8LL);
*(_DWORD *)(*(_QWORD *)&v89.m_uID - 8LL) = v46 - 1;
}
if ( v46 <= 0 )
operator delete(v20);
}
}
sub_D18D28(&v89.m_unknown2);
GJSmartTemplate::getVerySimplifiedKey((__int64 *)&v89.m_unknown2, (__int64 *)&v89.m_uIndexInArray);
v21 = (void *)(*(_QWORD *)&v89.m_unknown2 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v89.m_unknown2 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v55 = (unsigned int *)(*(_QWORD *)&v89.m_unknown2 - 8LL);
do
v56 = __ldaxr(v55);
while ( __stlxr(v56 - 1, v55) );
}
else
{
v56 = *(_DWORD *)(*(_QWORD *)&v89.m_unknown2 - 8LL);
*(_DWORD *)(*(_QWORD *)&v89.m_unknown2 - 8LL) = v56 - 1;
}
if ( v56 <= 0 )
operator delete(v21);
}
v22 = *(_QWORD *)&v89.m_uIndexInArray;
v23 = *((_QWORD *)v86.m_sString.m_data.m_data - 3);
v83 = *(_QWORD *)(*(_QWORD *)&v89.m_uIndexInArray - 24LL);
if ( v83 > v23 )
v24 = *((_QWORD *)v86.m_sString.m_data.m_data - 3);
else
v24 = *(_QWORD *)(*(_QWORD *)&v89.m_uIndexInArray - 24LL);
if ( !memcmp(v86.m_sString.m_data.m_data, *(const void **)&v89.m_uIndexInArray, v24) )
{
v25 = v23 - v83;
if ( v25 + 0x80000000 <= 0xFFFFFFFF && !(_DWORD)v25 )
{
v31 = (void *)(v22 - 24);
if ( (__int64 *)(v22 - 24) == &qword_124B6B0 )
goto LABEL_33;
goto LABEL_40;
}
}
sub_D18D28(&v89.m_uOrderOfArrival);
sub_D18D28(&v89.m_sString);
GJSmartTemplate::saveRemapToDict(
(__int64)a1,
(const std::string *)&v89.m_uOrderOfArrival,
(cocos2d::CCString *)&v89.m_sString,
a1[12]);
v26 = (char *)v89.m_sString.m_data.m_data - 24;
if ( (__int64 *)v89.m_sString.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v79 = (unsigned int *)((char *)v89.m_sString.m_data.m_data - 8);
do
v80 = __ldaxr(v79);
while ( __stlxr(v80 - 1, v79) );
}
else
{
v80 = *((_DWORD *)v89.m_sString.m_data.m_data - 2);
*((_DWORD *)v89.m_sString.m_data.m_data - 2) = v80 - 1;
}
if ( v80 <= 0 )
operator delete(v26);
}
v27 = (void *)(*(_QWORD *)&v89.m_uOrderOfArrival - 24LL);
if ( (__int64 *)(*(_QWORD *)&v89.m_uOrderOfArrival - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v81 = (unsigned int *)(*(_QWORD *)&v89.m_uOrderOfArrival - 8LL);
do
v82 = __ldaxr(v81);
while ( __stlxr(v82 - 1, v81) );
}
else
{
v82 = *(_DWORD *)(*(_QWORD *)&v89.m_uOrderOfArrival - 8LL);
*(_DWORD *)(*(_QWORD *)&v89.m_uOrderOfArrival - 8LL) = v82 - 1;
}
if ( v82 <= 0 )
operator delete(v27);
}
sub_D18D28(&v90);
GJSmartTemplate::getNoCornerKey((const void **)&v90, &v91);
sub_D18D28(&v92);
GJSmartTemplate::saveRemapToDict((__int64)a1, &v91, (cocos2d::CCString *)&v92, a1[13]);
v28 = v92 - 24;
if ( v92 - 24 != (unsigned __int8 *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v75 = (unsigned int *)(v92 - 8);
do
v76 = __ldaxr(v75);
while ( __stlxr(v76 - 1, v75) );
}
else
{
v76 = *((_DWORD *)v92 - 2);
*((_DWORD *)v92 - 2) = v76 - 1;
}
if ( v76 <= 0 )
operator delete(v28);
}
v29 = (char *)v91.m_data.m_data - 24;
if ( (__int64 *)v91.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v77 = (unsigned int *)((char *)v91.m_data.m_data - 8);
do
v78 = __ldaxr(v77);
while ( __stlxr(v78 - 1, v77) );
}
else
{
v78 = *((_DWORD *)v91.m_data.m_data - 2);
*((_DWORD *)v91.m_data.m_data - 2) = v78 - 1;
}
if ( v78 <= 0 )
operator delete(v29);
}
v30 = (char *)(v90 - 6);
if ( v90 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v73 = v90 - 2;
do
v74 = __ldaxr(v73);
while ( __stlxr(v74 - 1, v73) );
}
else
{
v74 = *(v90 - 2);
*(v90 - 2) = v74 - 1;
}
if ( v74 <= 0 )
operator delete(v30);
}
v22 = *(_QWORD *)&v89.m_uIndexInArray;
v31 = (void *)(*(_QWORD *)&v89.m_uIndexInArray - 24LL);
if ( (__int64 *)(*(_QWORD *)&v89.m_uIndexInArray - 24LL) != &qword_124B6B0 )
{
LABEL_40:
if ( &pthread_create )
{
v35 = (unsigned int *)(v22 - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *(_DWORD *)(v22 - 8);
*(_DWORD *)(v22 - 8) = v36 - 1;
}
if ( v36 <= 0 )
operator delete(v31);
}
LABEL_33:
v32 = (char *)v86.m_sString.m_data.m_data - 24;
if ( (__int64 *)v86.m_sString.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v49 = (unsigned int *)((char *)v86.m_sString.m_data.m_data - 8);
do
v50 = __ldaxr(v49);
while ( __stlxr(v50 - 1, v49) );
}
else
{
v50 = *((_DWORD *)v86.m_sString.m_data.m_data - 2);
*((_DWORD *)v86.m_sString.m_data.m_data - 2) = v50 - 1;
}
if ( v50 <= 0 )
operator delete(v32);
}
v33 = (char *)v84 - 24;
if ( (char *)v84 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v47 = (unsigned int *)((char *)v84 - 8);
do
v48 = __ldaxr(v47);
while ( __stlxr(v48 - 1, v47) );
}
else
{
v48 = *((_DWORD *)v84 - 2);
*((_DWORD *)v84 - 2) = v48 - 1;
}
if ( v48 <= 0 )
operator delete(v33);
}
return _stack_chk_guard;
}