//
// GJSmartTemplate::getPrefab_1 from 0x100411c90 to 0x1004125bf (2351 bytes)
//
// 7 xrefs:
// > GJSmartTemplate::scanForPrefab @ 0x100410b89
// > GJSmartTemplate::scanForPrefab @ 0x100410cc9
// > GJSmartTemplate::scanForPrefab @ 0x100410de9
// > GJSmartTemplate::scanForPrefab @ 0x100410f52
// > GJSmartTemplate::getPrefab_1 @ 0x10041245f
// > GJSmartTemplate::getPrefab_1 @ 0x1004124ce
// > GJSmartTemplate::getPrefab @ 0x100412b7f
//
// 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
//
__int64 __fastcall GJSmartTemplate::getPrefab_1(__int64 a1, std::string *a2, char a3, unsigned __int8 a4)
{
bool v6; // zf
__int64 v7; // r14
__int64 result; // rax
__int64 *v9; // rdx
__int64 v10; // rcx
__int64 *v11; // rax
__int64 v12; // rax
std::string::pointer data; // rdi
unsigned int v14; // r15d
__int64 v15; // rax
const char *CString; // r12
size_t v17; // rax
std::string::size_type v18; // rbx
char *v19; // r14
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v20; // r12
__int64 v21; // rax
size_t v22; // r13
__int64 Prefab_1; // rbx
char v24; // r14
__int64 v25; // rbx
unsigned __int8 v26[16]; // [rsp+8h] [rbp-288h] BYREF
void *v27; // [rsp+18h] [rbp-278h]
std::string v28; // [rsp+20h] [rbp-270h] BYREF
std::string v29; // [rsp+38h] [rbp-258h] BYREF
unsigned __int8 v30[16]; // [rsp+50h] [rbp-240h] BYREF
void *v31; // [rsp+60h] [rbp-230h]
std::string v32; // [rsp+68h] [rbp-228h] BYREF
__int64 v33; // [rsp+80h] [rbp-210h]
__int64 *v34; // [rsp+88h] [rbp-208h]
__int64 *v35; // [rsp+90h] [rbp-200h]
__int64 *v36; // [rsp+98h] [rbp-1F8h]
__int64 *v37; // [rsp+A0h] [rbp-1F0h]
__int64 *v38; // [rsp+A8h] [rbp-1E8h]
__int64 *v39; // [rsp+B0h] [rbp-1E0h]
__int64 *v40; // [rsp+B8h] [rbp-1D8h]
__int128 v41; // [rsp+C0h] [rbp-1D0h] BYREF
void *__p; // [rsp+D0h] [rbp-1C0h]
__int128 v43; // [rsp+E0h] [rbp-1B0h] BYREF
void *v44; // [rsp+F0h] [rbp-1A0h]
std::string v45; // [rsp+100h] [rbp-190h] BYREF
std::string v46; // [rsp+120h] [rbp-170h] BYREF
std::string v47; // [rsp+140h] [rbp-150h] BYREF
std::string v48; // [rsp+160h] [rbp-130h] BYREF
std::string v49; // [rsp+180h] [rbp-110h] BYREF
__int128 v50; // [rsp+1A0h] [rbp-F0h] BYREF
void *v51; // [rsp+1B0h] [rbp-E0h]
__int128 v52; // [rsp+1C0h] [rbp-D0h] BYREF
void *v53; // [rsp+1D0h] [rbp-C0h]
__int64 v54; // [rsp+1D8h] [rbp-B8h]
__int64 v55; // [rsp+1E0h] [rbp-B0h]
__int64 v56; // [rsp+1E8h] [rbp-A8h]
__int64 v57; // [rsp+1F0h] [rbp-A0h]
__int64 v58; // [rsp+1F8h] [rbp-98h]
std::string v59; // [rsp+200h] [rbp-90h] BYREF
int v60; // [rsp+224h] [rbp-6Ch]
__int64 *v61; // [rsp+228h] [rbp-68h]
std::string *__str; // [rsp+230h] [rbp-60h]
std::string __dst; // [rsp+238h] [rbp-58h] BYREF
std::string v64; // [rsp+250h] [rbp-40h] BYREF
v61 = (__int64 *)a1;
v6 = (*(_BYTE *)&a2->__r_.__value_.__s.0 & 1) == 0;
__str = a2;
if ( v6 )
{
__p = a2->__r_.__value_.__l.__data_;
v41 = *(_OWORD *)&a2->__r_.__value_.__l.0;
}
else
{
sub_10001AD30(&v41, a2->__r_.__value_.__l.__data_, a2->__r_.__value_.__l.__size_);
}
v7 = cocos2d::CCDictionary::objectForKey(v61[7], (char *)&v41);
if ( (v41 & 1) != 0 )
operator delete(__p);
if ( !v7 || !(unsigned int)sub_1007FEF90(v7) )
{
result = 0;
if ( a3 )
return result;
v9 = v61 + 7;
v55 = a4;
v60 = 3 * a4 + 4;
v35 = v61 + 13;
v36 = v61 + 11;
v37 = v61 + 9;
v38 = v61 + 12;
v39 = v61 + 10;
v40 = v61 + 8;
v10 = 0;
v34 = v61 + 7;
LABEL_12:
v56 = v10;
v11 = v9;
switch ( (int)v10 )
{
case 1:
v11 = v40;
break;
case 2:
v11 = v39;
break;
case 3:
v11 = v38;
break;
case 4:
v11 = v37;
break;
case 5:
v11 = v36;
break;
case 6:
v11 = v35;
break;
default:
break;
}
v57 = *v11;
v12 = 0;
while ( 1 )
{
memset(&v64, 0, sizeof(v64));
v33 = v12;
switch ( (int)v12 )
{
case 1:
if ( (*(_BYTE *)&__str->__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v59, __str->__r_.__value_.__l.__data_, __str->__r_.__value_.__l.__size_);
else
v59 = *__str;
GJSmartTemplate::getSimplifiedKey(&__dst, &v59);
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v64.__r_.__value_.__l.__data_);
v64 = __dst;
*(_WORD *)&__dst.__r_.__value_.__l.0 = 0;
if ( (*(_BYTE *)&v59.__r_.__value_.__s.0 & 1) != 0 )
{
data = v59.__r_.__value_.__l.__data_;
goto LABEL_75;
}
goto LABEL_76;
case 2:
if ( (*(_BYTE *)&__str->__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v45, __str->__r_.__value_.__l.__data_, __str->__r_.__value_.__l.__size_);
else
v45 = *__str;
GJSmartTemplate::getVerySimplifiedKey((__int64)&__dst, &v45);
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v64.__r_.__value_.__l.__data_);
v64 = __dst;
if ( (*(_BYTE *)&v45.__r_.__value_.__s.0 & 1) != 0 )
{
data = v45.__r_.__value_.__l.__data_;
goto LABEL_75;
}
goto LABEL_76;
case 3:
if ( (*(_BYTE *)&__str->__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v46, __str->__r_.__value_.__l.__data_, __str->__r_.__value_.__l.__size_);
else
v46 = *__str;
GJSmartTemplate::getSimplifiedKey(&v28, &v46);
GJSmartTemplate::getVerySimplifiedKey((__int64)&__dst, &v28);
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v64.__r_.__value_.__l.__data_);
v64 = __dst;
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v28.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v46.__r_.__value_.__s.0 & 1) != 0 )
{
data = v46.__r_.__value_.__l.__data_;
goto LABEL_75;
}
goto LABEL_76;
case 4:
if ( (*(_BYTE *)&__str->__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v47, __str->__r_.__value_.__l.__data_, __str->__r_.__value_.__l.__size_);
else
v47 = *__str;
GJSmartTemplate::getSimplifiedKey(&v29, &v47);
GJSmartTemplate::getNoCornerKey(&__dst, (__int64)&v47, (unsigned __int8 *)&v29);
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v64.__r_.__value_.__l.__data_);
v64 = __dst;
if ( (*(_BYTE *)&v29.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v29.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v47.__r_.__value_.__s.0 & 1) != 0 )
{
data = v47.__r_.__value_.__l.__data_;
goto LABEL_75;
}
goto LABEL_76;
case 5:
if ( (*(_BYTE *)&__str->__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v48, __str->__r_.__value_.__l.__data_, __str->__r_.__value_.__l.__size_);
else
v48 = *__str;
GJSmartTemplate::getVerySimplifiedKey((__int64)v30, &v48);
GJSmartTemplate::getNoCornerKey(&__dst, (__int64)&v48, v30);
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v64.__r_.__value_.__l.__data_);
v64 = __dst;
if ( (v30[0] & 1) != 0 )
operator delete(v31);
if ( (*(_BYTE *)&v48.__r_.__value_.__s.0 & 1) != 0 )
{
data = v48.__r_.__value_.__l.__data_;
goto LABEL_75;
}
goto LABEL_76;
case 6:
if ( (*(_BYTE *)&__str->__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v49, __str->__r_.__value_.__l.__data_, __str->__r_.__value_.__l.__size_);
else
v49 = *__str;
GJSmartTemplate::getSimplifiedKey(&v32, &v49);
GJSmartTemplate::getVerySimplifiedKey((__int64)v26, &v32);
GJSmartTemplate::getNoCornerKey(&__dst, (__int64)&v32, v26);
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v64.__r_.__value_.__l.__data_);
v64 = __dst;
if ( (v26[0] & 1) != 0 )
{
operator delete(v27);
if ( (*(_BYTE *)&v32.__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_73:
operator delete(v32.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v49.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_76;
goto LABEL_74;
}
}
else if ( (*(_BYTE *)&v32.__r_.__value_.__s.0 & 1) != 0 )
{
goto LABEL_73;
}
if ( (*(_BYTE *)&v49.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_76;
LABEL_74:
data = v49.__r_.__value_.__l.__data_;
LABEL_75:
operator delete(data);
LABEL_76:
if ( (_DWORD)v56 )
{
if ( !v57 )
goto LABEL_109;
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) == 0 )
{
if ( !(*(_BYTE *)&v64.__r_.__value_.__l.0 >> 1) )
goto LABEL_109;
LABEL_84:
v54 = cocos2d::CCDictionary::objectForKey(v57, (char *)&v64);
if ( !v54 )
goto LABEL_109;
v14 = 0;
while ( 2 )
{
if ( v14 >= (unsigned int)sub_1007FEF90(v54) )
goto LABEL_109;
v15 = cocos2d::CCArray::stringAtIndex(v54, v14);
CString = (const char *)cocos2d::CCString::getCString(v15);
v17 = strlen(CString);
if ( v17 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v18 = v17;
if ( v17 >= 0x17 )
{
v21 = v17 | 7;
v22 = 26;
if ( (v18 | 7) != 0x17 )
v22 = v21 + 1;
v19 = (char *)operator new(v22);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)v19;
__dst.__r_.__value_.__r.__words[0] = v22 | 1;
__dst.__r_.__value_.__l.__size_ = v18;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v17);
v19 = __dst.__r_.__value_.__s.__data_;
if ( !v17 )
{
__dst.__r_.__value_.__s.__data_[0] = 0;
v20 = __dst.__r_.__value_.__s.0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_92;
LABEL_97:
sub_10001AD30(&v52, __dst.__r_.__value_.__l.__data_, __dst.__r_.__value_.__l.__size_);
goto LABEL_98;
}
}
memmove(v19, CString, v18);
v19[v18] = 0;
v20 = __dst.__r_.__value_.__s.0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_97;
LABEL_92:
v53 = __dst.__r_.__value_.__l.__data_;
v52 = *(_OWORD *)&__dst.__r_.__value_.__l.0;
LABEL_98:
Prefab_1 = GJSmartTemplate::getPrefab_1(v61, &v52, 1, v55);
if ( (v52 & 1) != 0 )
{
operator delete(v53);
if ( (*(_BYTE *)&v20 & 1) != 0 )
goto LABEL_102;
}
else if ( (*(_BYTE *)&v20 & 1) != 0 )
{
LABEL_102:
operator delete(__dst.__r_.__value_.__l.__data_);
}
++v14;
if ( Prefab_1 )
goto LABEL_107;
continue;
}
}
if ( v64.__r_.__value_.__l.__size_ )
goto LABEL_84;
}
else
{
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&v50, v64.__r_.__value_.__l.__data_, v64.__r_.__value_.__l.__size_);
}
else
{
v51 = v64.__r_.__value_.__l.__data_;
v50 = *(_OWORD *)&v64.__r_.__value_.__l.0;
}
Prefab_1 = GJSmartTemplate::getPrefab_1(v61, &v50, 1, v55);
if ( (v50 & 1) != 0 )
operator delete(v51);
if ( Prefab_1 )
{
LABEL_107:
v24 = 0;
v58 = Prefab_1;
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_110;
goto LABEL_111;
}
}
LABEL_109:
v24 = 1;
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
LABEL_110:
operator delete(v64.__r_.__value_.__l.__data_);
LABEL_111:
if ( !v24 )
return v58;
v12 = (unsigned int)(v33 + 1);
if ( (_DWORD)v12 == v60 )
{
v10 = (unsigned int)(v56 + 1);
result = 0;
v9 = v34;
if ( (_DWORD)v10 == v60 )
return result;
goto LABEL_12;
}
break;
default:
std::string::operator=(&v64, __str);
goto LABEL_76;
}
}
}
if ( (*(_BYTE *)&__str->__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&v43, __str->__r_.__value_.__l.__data_, __str->__r_.__value_.__l.__size_);
}
else
{
v44 = __str->__r_.__value_.__l.__data_;
v43 = *(_OWORD *)&__str->__r_.__value_.__l.0;
}
result = GJSmartTemplate::getRandomPrefab((__int64)v61, &v43);
if ( (v43 & 1) != 0 )
{
v25 = result;
operator delete(v44);
return v25;
}
return result;
}