//
// GJSmartBlockPreview::addTemplateGuide from 0x1403bc030 to 0x1403bc2ca (666 bytes)
//
// 4 xrefs:
// > BrowseSmartKeyLayer::init @ 0x1405f1343
// > BrowseSmartKeyLayer::init @ 0x1405f1410
// > ??> @ 0x140923e1c
// > ??> @ 0x140923e28
//
// 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 11:31:26 +0000
//
// Hidden C++ exception states: #wind=4
void __fastcall GJSmartBlockPreview::addTemplateGuide(__int64 a1, __int128 *a2, int a3)
{
__int64 v4; // r14
unsigned int v6; // edi
void *v7; // rdx
cocos2d::CCArray *v8; // rax
cocos2d::CCArray *v9; // rsi
struct cocos2d::CCObject *v10; // rbx
int v11; // eax
__int64 v12; // rdx
struct cocos2d::CCObject *v13; // rbx
int v14; // eax
int v15; // eax
__int64 v16; // rdx
__int64 v17; // [rsp+28h] [rbp-91h] BYREF
_BYTE v18[32]; // [rsp+30h] [rbp-89h] BYREF
_BYTE v19[32]; // [rsp+50h] [rbp-69h] BYREF
int v20; // [rsp+70h] [rbp-49h]
char v21; // [rsp+74h] [rbp-45h]
int v22; // [rsp+78h] [rbp-41h]
__int16 v23; // [rsp+7Ch] [rbp-3Dh]
char v24; // [rsp+7Eh] [rbp-3Bh]
__int128 *v25; // [rsp+80h] [rbp-39h]
__int64 v26; // [rsp+90h] [rbp-29h]
__int128 v27; // [rsp+98h] [rbp-21h] BYREF
__int64 v28; // [rsp+A8h] [rbp-11h]
__int64 v29; // [rsp+B0h] [rbp-9h]
__int128 v30; // [rsp+B8h] [rbp-1h] BYREF
__int64 v31; // [rsp+C8h] [rbp+Fh]
__int64 v32; // [rsp+D0h] [rbp+17h]
int v33; // [rsp+D8h] [rbp+1Fh]
char v34; // [rsp+DCh] [rbp+23h]
int v35; // [rsp+E0h] [rbp+27h]
__int16 v36; // [rsp+E4h] [rbp+2Bh]
char v37; // [rsp+E6h] [rbp+2Dh]
v4 = (__int64)a2;
v25 = a2;
v6 = 0;
v26 = 0;
v27 = 0;
v28 = 0;
v29 = 15;
LOBYTE(v27) = 0;
v30 = 0;
v31 = 0;
v32 = 15;
LOBYTE(v30) = 0;
v33 = 0;
v34 = 0;
v35 = 0;
v36 = 0;
v37 = 0;
if ( &v27 != a2 )
{
if ( *((_QWORD *)a2 + 3) > 0xFu )
a2 = *(__int128 **)a2;
sub_1400405A0((void **)&v27, a2, *(_QWORD *)(v4 + 16));
}
if ( &v30 != (__int128 *)v4 )
{
v7 = (void *)v4;
if ( *(_QWORD *)(v4 + 24) > 0xFu )
v7 = *(void **)v4;
sub_1400405A0((void **)&v30, v7, *(_QWORD *)(v4 + 16));
}
v17 = v26;
sub_14003F4F0((__int64)v18, (__int64)&v27);
sub_14003F4F0((__int64)v19, (__int64)&v30);
v20 = v33;
v21 = v34;
v22 = v35;
v23 = v36;
v24 = v37;
v8 = (cocos2d::CCArray *)GJSmartBlockPreview::addTemplateGuide_1(a1, &v17);
v9 = v8;
if ( a3 != 1 )
{
if ( a3 != 2 || !cocos2d::CCArray::count(v8) )
goto LABEL_26;
while ( 1 )
{
v13 = cocos2d::CCArray::objectAtIndex(v9, v6);
v14 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v13 + 56LL))(v13);
if ( !v14 )
{
(**((void (__fastcall ***)(__int64, __int16 *))v13 + 40))((__int64)v13 + 320, &word_1407034C0);
LOBYTE(v16) = -1;
goto LABEL_24;
}
v15 = v14 - 1;
if ( !v15 )
break;
if ( v15 == 1 )
{
(**((void (__fastcall ***)(__int64, void *))v13 + 40))((__int64)v13 + 320, &unk_1407034BC);
LOBYTE(v16) = 100;
LABEL_24:
(*(void (__fastcall **)(__int64, __int64))(*((_QWORD *)v13 + 40) + 40LL))((__int64)v13 + 320, v16);
}
if ( ++v6 >= cocos2d::CCArray::count(v9) )
goto LABEL_26;
}
(**((void (__fastcall ***)(__int64, __int16 *))v13 + 40))((__int64)v13 + 320, &word_1407034C0);
LOBYTE(v16) = -56;
goto LABEL_24;
}
if ( cocos2d::CCArray::count(v8) )
{
do
{
v10 = cocos2d::CCArray::objectAtIndex(v9, v6);
v11 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v10 + 56LL))(v10);
if ( !v11 || (unsigned int)(v11 - 1) <= 1 )
{
LOBYTE(v12) = 50;
(*(void (__fastcall **)(__int64, __int64))(*((_QWORD *)v10 + 40) + 40LL))((__int64)v10 + 320, v12);
}
(**((void (__fastcall ***)(__int64, void *))v10 + 40))((__int64)v10 + 320, &unk_1407034BC);
++v6;
}
while ( v6 < cocos2d::CCArray::count(v9) );
}
LABEL_26:
sub_14003D310((__int64)&v30);
sub_14003D310((__int64)&v27);
sub_14003D310(v4);
}