//
// GJSmartTemplate::getPrefab from 0x670ea8 to 0x671306 (1118 bytes)
//
// 7 xrefs:
// > GJSmartTemplate::getPrefab @ 0x670f78
// > GJSmartTemplate::getPrefab @ 0x6712de
// > GJSmartTemplate::getPrefab @ 0x671376
// > GJSmartTemplate::scanForPrefab @ 0x671dca
// > GJSmartTemplate::scanForPrefab @ 0x671e58
// > GJSmartTemplate::scanForPrefab @ 0x671ee8
// > GJSmartTemplate::scanForPrefab @ 0x671f92
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:55:51 +0000
//
int __fastcall GJSmartTemplate::getPrefab(_DWORD *a1, unsigned __int8 *a2, int a3, int a4)
{
cocos2d::CCArray *Prefabs; // r4
int RandomPrefab; // r5
int *v9; // r0
int v10; // r0
int v11; // r1
_BYTE *v12; // r2
int *v13; // r0
int v15; // r3
int v16; // r3
int v17; // r0
int v18; // r1
_BYTE *v19; // r2
int v20; // r0
int v21; // r1
_BYTE *v22; // r2
int v23; // r0
int v24; // r1
_BYTE *v25; // r2
int v26; // r0
int v27; // r1
_BYTE *v28; // r2
int v29; // r0
int v30; // r1
_BYTE *v31; // r2
cocos2d::CCArray *v33; // r11
unsigned int j; // r10
cocos2d::CCString *v35; // r0
const char *CString; // r5
size_t v37; // r0
int v38; // [sp+0h] [bp-114h]
int v39; // [sp+4h] [bp-110h]
int i; // [sp+8h] [bp-10Ch]
int v42; // [sp+10h] [bp-104h]
int v43; // [sp+1Ch] [bp-F8h] BYREF
int v44; // [sp+20h] [bp-F4h]
_BYTE *v45; // [sp+24h] [bp-F0h]
int v46[3]; // [sp+28h] [bp-ECh] BYREF
int v47; // [sp+34h] [bp-E0h] BYREF
int v48; // [sp+38h] [bp-DCh]
_BYTE *v49; // [sp+3Ch] [bp-D8h]
int v50[3]; // [sp+40h] [bp-D4h] BYREF
int v51; // [sp+4Ch] [bp-C8h] BYREF
int v52; // [sp+50h] [bp-C4h]
_BYTE *v53; // [sp+54h] [bp-C0h]
int v54[3]; // [sp+58h] [bp-BCh] BYREF
int v55[3]; // [sp+64h] [bp-B0h] BYREF
int v56; // [sp+70h] [bp-A4h] BYREF
int v57; // [sp+74h] [bp-A0h]
_BYTE *v58; // [sp+78h] [bp-9Ch]
int v59[3]; // [sp+7Ch] [bp-98h] BYREF
int v60[3]; // [sp+88h] [bp-8Ch] BYREF
int v61; // [sp+94h] [bp-80h] BYREF
int v62; // [sp+98h] [bp-7Ch]
_BYTE *v63; // [sp+9Ch] [bp-78h]
int v64[3]; // [sp+A0h] [bp-74h] BYREF
int v65[3]; // [sp+ACh] [bp-68h] BYREF
int v66; // [sp+B8h] [bp-5Ch] BYREF
int v67; // [sp+BCh] [bp-58h]
_BYTE *v68; // [sp+C0h] [bp-54h]
int v69[3]; // [sp+C4h] [bp-50h] BYREF
int v70[3]; // [sp+D0h] [bp-44h] BYREF
int v71[3]; // [sp+DCh] [bp-38h] BYREF
int v72; // [sp+E8h] [bp-2Ch] BYREF
int v73; // [sp+ECh] [bp-28h]
_BYTE *v74; // [sp+F0h] [bp-24h]
int v75[3]; // [sp+F4h] [bp-20h] BYREF
int v76[3]; // [sp+100h] [bp-14h] BYREF
std::string::basic_string(v76, (int)a2);
Prefabs = (cocos2d::CCArray *)GJSmartTemplate::getPrefabs((int)a1, (int)v76);
std::string::~string((int)v76);
if ( Prefabs && cocos2d::CCArray::count(Prefabs) )
{
std::string::basic_string(v76, (int)a2);
RandomPrefab = GJSmartTemplate::getRandomPrefab((int)a1, (int)v76);
v9 = v76;
LABEL_12:
std::string::~string((int)v9);
}
else
{
if ( !a3 )
{
v39 = 0;
if ( a4 )
v15 = 7;
else
v15 = 4;
v42 = v15;
do
{
switch ( v39 )
{
case 1:
v16 = a1[14];
break;
case 2:
v16 = a1[16];
break;
case 3:
v16 = a1[18];
break;
case 4:
v16 = a1[15];
break;
case 5:
v16 = a1[17];
break;
case 6:
v16 = a1[19];
break;
default:
v16 = a1[13];
break;
}
v38 = v16;
for ( i = 0; i != v42; ++i )
{
v43 = 0;
v44 = 0;
v45 = nullptr;
switch ( i )
{
case 1:
std::string::basic_string(v46, (int)a2);
GJSmartTemplate::getSimplifiedKey(&v47, (unsigned __int8 *)v46);
if ( (v43 & 1) != 0 )
{
*v45 = 0;
v44 = 0;
}
else
{
LOWORD(v43) = 0;
}
std::string::reserve(&v43, 0);
v10 = v47;
v11 = v48;
v12 = v49;
v47 = 0;
v48 = 0;
v49 = nullptr;
v43 = v10;
v44 = v11;
v45 = v12;
std::string::~string((int)&v47);
v13 = v46;
goto LABEL_8;
case 2:
std::string::basic_string(v50, (int)a2);
GJSmartTemplate::getVerySimplifiedKey(&v51, (unsigned __int8 *)v50);
if ( (v43 & 1) != 0 )
{
*v45 = 0;
v44 = 0;
}
else
{
LOWORD(v43) = 0;
}
std::string::reserve(&v43, 0);
v17 = v51;
v18 = v52;
v19 = v53;
v51 = 0;
v52 = 0;
v53 = nullptr;
v43 = v17;
v44 = v18;
v45 = v19;
std::string::~string((int)&v51);
v13 = v50;
goto LABEL_8;
case 3:
std::string::basic_string(v54, (int)a2);
GJSmartTemplate::getSimplifiedKey(v55, (unsigned __int8 *)v54);
GJSmartTemplate::getVerySimplifiedKey(&v56, (unsigned __int8 *)v55);
if ( (v43 & 1) != 0 )
{
*v45 = 0;
v44 = 0;
}
else
{
LOWORD(v43) = 0;
}
std::string::reserve(&v43, 0);
v20 = v56;
v21 = v57;
v22 = v58;
v56 = 0;
v57 = 0;
v58 = nullptr;
v43 = v20;
v44 = v21;
v45 = v22;
std::string::~string((int)&v56);
std::string::~string((int)v55);
v13 = v54;
goto LABEL_8;
case 4:
std::string::basic_string(v59, (int)a2);
GJSmartTemplate::getSimplifiedKey(v60, (unsigned __int8 *)v59);
GJSmartTemplate::getNoCornerKey(&v61, (int)a1, (unsigned __int8 *)v60);
if ( (v43 & 1) != 0 )
{
*v45 = 0;
v44 = 0;
}
else
{
LOWORD(v43) = 0;
}
std::string::reserve(&v43, 0);
v23 = v61;
v24 = v62;
v25 = v63;
v61 = 0;
v62 = 0;
v63 = nullptr;
v43 = v23;
v44 = v24;
v45 = v25;
std::string::~string((int)&v61);
std::string::~string((int)v60);
v13 = v59;
goto LABEL_8;
case 5:
std::string::basic_string(v64, (int)a2);
GJSmartTemplate::getVerySimplifiedKey(v65, (unsigned __int8 *)v64);
GJSmartTemplate::getNoCornerKey(&v66, (int)a1, (unsigned __int8 *)v65);
if ( (v43 & 1) != 0 )
{
*v45 = 0;
v44 = 0;
}
else
{
LOWORD(v43) = 0;
}
std::string::reserve(&v43, 0);
v26 = v66;
v27 = v67;
v28 = v68;
v66 = 0;
v67 = 0;
v68 = nullptr;
v43 = v26;
v44 = v27;
v45 = v28;
std::string::~string((int)&v66);
std::string::~string((int)v65);
v13 = v64;
goto LABEL_8;
case 6:
std::string::basic_string(v69, (int)a2);
GJSmartTemplate::getSimplifiedKey(v70, (unsigned __int8 *)v69);
GJSmartTemplate::getVerySimplifiedKey(v71, (unsigned __int8 *)v70);
GJSmartTemplate::getNoCornerKey(&v72, (int)a1, (unsigned __int8 *)v71);
if ( (v43 & 1) != 0 )
{
*v45 = 0;
v44 = 0;
}
else
{
LOWORD(v43) = 0;
}
std::string::reserve(&v43, 0);
v29 = v72;
v30 = v73;
v31 = v74;
v72 = 0;
v73 = 0;
v74 = nullptr;
v43 = v29;
v44 = v30;
v45 = v31;
std::string::~string((int)&v72);
std::string::~string((int)v71);
std::string::~string((int)v70);
v13 = v69;
LABEL_8:
std::string::~string((int)v13);
break;
default:
std::string::operator=((unsigned __int8 *)&v43, a2);
break;
}
if ( v39 )
{
if ( v38 )
{
if ( (v43 & 1) != 0 ? v44 : (int)(unsigned __int8)v43 >> 1 )
{
v33 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v38, &v43);
if ( v33 )
{
for ( j = 0; j < cocos2d::CCArray::count(v33); ++j )
{
v35 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v33, j);
CString = (const char *)cocos2d::CCString::getCString(v35);
memset(v75, 0, sizeof(v75));
v37 = strlen(CString);
std::string::__init(v75, CString, v37);
std::string::basic_string(v76, (int)v75);
RandomPrefab = GJSmartTemplate::getPrefab(a1, v76, 1, a4);
std::string::~string((int)v76);
if ( RandomPrefab )
{
std::string::~string((int)v75);
goto LABEL_11;
}
std::string::~string((int)v75);
}
}
}
}
}
else
{
std::string::basic_string(v75, (int)&v43);
RandomPrefab = GJSmartTemplate::getPrefab(a1, v75, 1, a4);
std::string::~string((int)v75);
if ( RandomPrefab )
{
LABEL_11:
v9 = &v43;
goto LABEL_12;
}
}
std::string::~string((int)&v43);
}
++v39;
}
while ( v39 != v42 );
}
return 0;
}
return RandomPrefab;
}