//
// GJSmartBlockPreview::addTemplateGuide from 0x1004155e0 to 0x100415870 (656 bytes)
//
// 2 xrefs:
// > BrowseSmartKeyLayer::init @ 0x1004e5bc8
// > BrowseSmartKeyLayer::init @ 0x1004e5d25
//
// 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:11 +0000
//
void __fastcall GJSmartBlockPreview::addTemplateGuide(__int64 a1, const std::string *a2, int a3)
{
__int64 v4; // rbx
unsigned int j; // r14d
unsigned __int8 v6; // r12
__int64 v7; // r13
int v8; // eax
unsigned int i; // r14d
__int64 v10; // r12
__int64 v11; // [rsp+8h] [rbp-B8h] BYREF
__int128 v12; // [rsp+10h] [rbp-B0h] BYREF
void *data; // [rsp+20h] [rbp-A0h]
__int128 v14; // [rsp+28h] [rbp-98h] BYREF
void *__p; // [rsp+38h] [rbp-88h]
_BYTE v16[15]; // [rsp+40h] [rbp-80h]
__int64 v17; // [rsp+50h] [rbp-70h]
std::string v18; // [rsp+58h] [rbp-68h] BYREF
std::string v19; // [rsp+70h] [rbp-50h] BYREF
_BYTE v20[15]; // [rsp+88h] [rbp-38h]
v17 = 0;
*(_WORD *)&v18.__r_.__value_.__l.0 = 0;
*(_WORD *)&v19.__r_.__value_.__l.0 = 0;
*(_DWORD *)v20 = 0;
v20[4] = 0;
*(_DWORD *)&v20[8] = 0;
*(_DWORD *)&v20[11] = 0;
std::string::operator=(&v18, a2);
std::string::operator=(&v19, a2);
v11 = 0;
if ( (*(_BYTE *)&v18.__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&v12, v18.__r_.__value_.__l.__data_, v18.__r_.__value_.__l.__size_);
}
else
{
data = v18.__r_.__value_.__l.__data_;
v12 = *(_OWORD *)&v18.__r_.__value_.__l.0;
}
if ( (*(_BYTE *)&v19.__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&v14, v19.__r_.__value_.__l.__data_, v19.__r_.__value_.__l.__size_);
}
else
{
__p = v19.__r_.__value_.__l.__data_;
v14 = *(_OWORD *)&v19.__r_.__value_.__l.0;
}
*(_QWORD *)&v16[7] = *(_QWORD *)&v20[7];
*(_QWORD *)v16 = *(_QWORD *)v20;
v4 = GJSmartBlockPreview::addTemplateGuide_1(a1, &v11, 1.0);
if ( (v14 & 1) != 0 )
{
operator delete(__p);
if ( (v12 & 1) == 0 )
{
LABEL_9:
if ( a3 != 1 )
goto LABEL_10;
LABEL_23:
for ( i = 0; i < (unsigned int)sub_1007FEF90(v4); ++i )
{
v10 = sub_1007FEFE0(v4, i);
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v10 + 64LL))(v10) < 3 )
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v10 + 912LL))(v10, 50);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v10 + 960LL))(v10, &unk_100A09EA8);
}
goto LABEL_28;
}
}
else if ( (v12 & 1) == 0 )
{
goto LABEL_9;
}
operator delete(data);
if ( a3 == 1 )
goto LABEL_23;
LABEL_10:
if ( a3 == 2 )
{
for ( j = 0; ; ++j )
{
if ( j >= (unsigned int)sub_1007FEF90(v4) )
goto LABEL_28;
v7 = sub_1007FEFE0(v4, j);
v8 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v7 + 64LL))(v7);
if ( !v8 )
{
v6 = -1;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v7 + 960LL))(v7, &unk_100A09EAB);
goto LABEL_13;
}
if ( v8 == 1 )
break;
if ( v8 == 2 )
{
v6 = 100;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v7 + 960LL))(v7, &unk_100A09EA8);
goto LABEL_13;
}
LABEL_14:
;
}
v6 = -56;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v7 + 960LL))(v7, &unk_100A09EAB);
LABEL_13:
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v7 + 912LL))(v7, v6);
goto LABEL_14;
}
LABEL_28:
if ( (*(_BYTE *)&v19.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v19.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v18.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v18.__r_.__value_.__l.__data_);
}