//
// GJSmartBlockPreview::addTemplateGuide from 0x100428970 to 0x100428c00 (656 bytes)
//
// 2 xrefs:
// > BrowseSmartKeyLayer::init @ 0x1004eb038
// > BrowseSmartKeyLayer::init @ 0x1004eb195
//
// 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
//
void __fastcall GJSmartBlockPreview::addTemplateGuide(
GJSmartBlockPreview *a1,
const std::string *a2,
int a3,
double a4)
{
cocos2d::CCArray *v5; // rbx
unsigned int j; // r14d
unsigned __int8 v7; // r12
__int64 v8; // r13
int v9; // eax
unsigned int i; // r14d
__int64 v11; // r12
_BYTE v12[79]; // [rsp+0h] [rbp-C0h] BYREF
__int64 v13; // [rsp+50h] [rbp-70h]
std::string v14; // [rsp+58h] [rbp-68h] BYREF
std::string v15; // [rsp+70h] [rbp-50h] BYREF
_BYTE v16[15]; // [rsp+88h] [rbp-38h]
v13 = 0;
*(_WORD *)&v14.__r_.__value_.__l.0 = 0;
*(_WORD *)&v15.__r_.__value_.__l.0 = 0;
*(_DWORD *)v16 = 0;
v16[4] = 0;
*(_DWORD *)&v16[8] = 0;
*(_DWORD *)&v16[11] = 0;
std::string::operator=(&v14, a2);
std::string::operator=(&v15, a2);
*(_QWORD *)&v12[8] = 0;
if ( (*(_BYTE *)&v14.__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v12[16], v14.__r_.__value_.__l.__data_, v14.__r_.__value_.__l.__size_, a4);
}
else
{
*(std::string *)&v12[16] = v14;
a4 = *(double *)v14.__r_.__value_.__r.__words;
}
if ( (*(_BYTE *)&v15.__r_.__value_.__s.0 & 1) != 0 )
sub_100006B70(&v12[40], v15.__r_.__value_.__l.__data_, v15.__r_.__value_.__l.__size_, a4);
else
*(std::string *)&v12[40] = v15;
*(_QWORD *)&v12[71] = *(_QWORD *)&v16[7];
*(_QWORD *)&v12[64] = *(_QWORD *)v16;
v5 = GJSmartBlockPreview::addTemplateGuide_1(a1, *(SmartPrefabResult *)v12, 1.0);
if ( (v12[40] & 1) != 0 )
{
operator delete(*(void **)&v12[56]);
if ( (v12[16] & 1) == 0 )
{
LABEL_9:
if ( a3 != 1 )
goto LABEL_10;
LABEL_23:
for ( i = 0; i < (unsigned int)sub_100720070(v5); ++i )
{
v11 = sub_1007200C0(v5, i);
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v11 + 64LL))(v11) < 3 )
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v11 + 896LL))(v11, 50);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v11 + 944LL))(v11, &unk_10081B8F8);
}
goto LABEL_28;
}
}
else if ( (v12[16] & 1) == 0 )
{
goto LABEL_9;
}
operator delete(*(void **)&v12[32]);
if ( a3 == 1 )
goto LABEL_23;
LABEL_10:
if ( a3 == 2 )
{
for ( j = 0; ; ++j )
{
if ( j >= (unsigned int)sub_100720070(v5) )
goto LABEL_28;
v8 = sub_1007200C0(v5, j);
v9 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v8 + 64LL))(v8);
if ( !v9 )
{
v7 = -1;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v8 + 944LL))(v8, &unk_10081B8FB);
goto LABEL_13;
}
if ( v9 == 1 )
break;
if ( v9 == 2 )
{
v7 = 100;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v8 + 944LL))(v8, &unk_10081B8F8);
goto LABEL_13;
}
LABEL_14:
;
}
v7 = -56;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v8 + 944LL))(v8, &unk_10081B8FB);
LABEL_13:
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v8 + 896LL))(v8, v7);
goto LABEL_14;
}
LABEL_28:
if ( (*(_BYTE *)&v15.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v15.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v14.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v14.__r_.__value_.__l.__data_);
}