//
// GJSmartTemplate::saveRemapToDict from 0x1402b0ef0 to 0x1402b10c5 (469 bytes)
//
// 8 xrefs:
// > GJSmartTemplate::saveRemap @ 0x1402b0b9e
// > GJSmartTemplate::saveRemap @ 0x1402b0be1
// > GJSmartTemplate::saveRemap @ 0x1402b0c24
// > GJSmartTemplate::saveRemap @ 0x1402b0d1e
// > GJSmartTemplate::saveRemap @ 0x1402b0d63
// > GJSmartTemplate::saveRemap @ 0x1402b0e47
// > GJSmartTemplate::saveRemap @ 0x1402b0e8a
// > ??> @ 0x1406d233c
//
// 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
//
// Hidden C++ exception states: #wind=2
void __fastcall GJSmartTemplate::saveRemapToDict(__int64 a1, __int64 a2, const void **a3, __int64 a4)
{
__int64 v7; // rcx
cocos2d::CCArray *v8; // r12
unsigned int v9; // r15d
cocos2d::CCString *v10; // rax
const char *CString; // rax
size_t v12; // r8
const void *v13; // rdx
void **v14; // rcx
unsigned __int64 v15; // r13
char *v16; // rdi
const void *v17; // r14
size_t v18; // rbp
size_t v19; // r8
int v20; // ebx
char *v21; // rax
struct cocos2d::CCObject *v22; // rax
bool v23; // [rsp+20h] [rbp-88h]
void *Buf1[2]; // [rsp+40h] [rbp-68h] BYREF
size_t v26; // [rsp+50h] [rbp-58h]
unsigned __int64 v27; // [rsp+58h] [rbp-50h]
if ( *(_QWORD *)(a2 + 16) )
{
v8 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a4, a2);
if ( !v8 )
{
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
cocos2d::CCDictionary::setObject(a4, v8, a2);
}
v9 = 0;
if ( cocos2d::CCArray::count(v8) )
{
while ( 1 )
{
v10 = cocos2d::CCArray::stringAtIndex(v8, v9);
CString = cocos2d::CCString::getCString(v10);
*(_OWORD *)Buf1 = 0;
v26 = 0;
v27 = 0;
v12 = -1;
do
++v12;
while ( CString[v12] );
sub_14003A930(Buf1, CString, v12);
v13 = a3;
if ( (unsigned __int64)a3[3] > 0xF )
v13 = *a3;
v14 = Buf1;
v15 = v27;
v23 = v27 > 0xF;
v16 = (char *)Buf1[0];
if ( v27 > 0xF )
v14 = (void **)Buf1[0];
v17 = a3[2];
v18 = v26;
v19 = v26;
if ( (unsigned __int64)v17 < v26 )
v19 = (size_t)a3[2];
v20 = memcmp(v14, v13, v19);
if ( !v20 )
{
if ( v18 >= (unsigned __int64)v17 )
v20 = v18 > (unsigned __int64)v17;
else
v20 = -1;
}
if ( v23 )
{
v21 = v16;
if ( v15 + 1 >= 0x1000 )
{
v16 = *((char **)v16 - 1);
if ( (unsigned __int64)(v21 - v16 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v16);
}
if ( !v20 )
break;
if ( ++v9 >= cocos2d::CCArray::count(v8) )
goto LABEL_25;
}
}
else
{
LABEL_25:
v22 = (struct cocos2d::CCObject *)cocos2d::CCString::create(a3);
cocos2d::CCArray::addObject(v8, v22);
}
}
sub_14003A830(a2);
sub_14003A830((__int64)a3);
}