//
// GJSmartBlockPreview::addTemplateGuide from 0x9d6ce0 to 0x9d71cc (1260 bytes)
//
// 3 xrefs:
// > BrowseSmartKeyLayer::init @ 0x9e09c0
// > BrowseSmartKeyLayer::init @ 0x9e109c
// > ??> @ 0x7ccb0
//
// 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
//
cocos2d::CCArray *GJSmartBlockPreview::addTemplateGuide(GJSmartBlockPreview *a1, SmartPrefabResult *a2, float a3)
{
int v3; // w2
int v6; // w25
cocos2d::CCArray *v7; // x21
void *v8; // x0
void *v9; // x0
__int64 v10; // x1
void *v11; // x0
void *v12; // x0
unsigned int i; // w20
__int64 v15; // x19
int v16; // w0
unsigned int *v17; // x1
int v18; // w2
unsigned int v19; // w20
__int64 v20; // x19
int v21; // w0
unsigned int *v22; // x19
int v23; // w1
unsigned int *v24; // x1
int v25; // w2
unsigned int *v26; // x1
int v27; // w2
__int64 v28; // [xsp+60h] [xbp+60h] BYREF
__int64 v29; // [xsp+68h] [xbp+68h] BYREF
int v30; // [xsp+70h] [xbp+70h]
char v31; // [xsp+74h] [xbp+74h]
int v32; // [xsp+78h] [xbp+78h]
char v33; // [xsp+7Ch] [xbp+7Ch]
char v34; // [xsp+7Dh] [xbp+7Dh]
char v35; // [xsp+7Eh] [xbp+7Eh]
__int64 v36; // [xsp+80h] [xbp+80h] BYREF
__int64 v37; // [xsp+88h] [xbp+88h] BYREF
__int64 v38; // [xsp+90h] [xbp+90h] BYREF
int v39; // [xsp+98h] [xbp+98h]
char v40; // [xsp+9Ch] [xbp+9Ch]
int v41; // [xsp+A0h] [xbp+A0h]
char v42; // [xsp+A4h] [xbp+A4h]
char v43; // [xsp+A5h] [xbp+A5h]
char v44; // [xsp+A6h] [xbp+A6h]
v6 = v3;
sub_D153B8((int)&v28, &byte_F288A0);
sub_D153B8((int)&v29, &byte_F288A0);
v30 = 0;
v31 = 0;
v32 = 0;
v33 = 0;
v34 = 0;
v35 = 0;
sub_D18EA8(&v28, a2);
sub_D18EA8(&v29, a2);
v36 = 0;
sub_D18D28(&v37);
sub_D18D28(&v38);
v39 = v30;
v40 = v31;
v41 = v32;
v42 = v33;
v43 = v34;
v44 = v35;
v7 = GJSmartBlockPreview::addTemplateGuide(a1, (__int64)&v36, 1.0);
v8 = (void *)(v38 - 24);
if ( (__int64 *)(v38 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)(v38 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *(_DWORD *)(v38 - 8);
*(_DWORD *)(v38 - 8) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v8);
}
v9 = (void *)(v37 - 24);
if ( (__int64 *)(v37 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)(v37 - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *(_DWORD *)(v37 - 8);
*(_DWORD *)(v37 - 8) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v9);
}
if ( v6 != 1 )
{
if ( v6 == 2 )
{
v19 = 0;
while ( v19 < (unsigned int)cocos2d::CCArray::count(v7) )
{
v20 = cocos2d::CCArray::objectAtIndex(v7, v19);
v21 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v20 + 64LL))(v20);
if ( v21 == 1 )
{
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v20 + 944LL))(v20, &unk_F039C0);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v20 + 896LL))(v20, 4294967240LL);
++v19;
}
else if ( v21 == 2 )
{
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v20 + 944LL))(v20, &unk_F039B8);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v20 + 896LL))(v20, 100);
++v19;
}
else
{
if ( !v21 )
{
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v20 + 944LL))(v20, &unk_F039C0);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v20 + 896LL))(v20, 0xFFFFFFFFLL);
}
++v19;
}
}
}
v10 = v29;
v11 = (void *)(v29 - 24);
if ( (__int64 *)(v29 - 24) == &qword_124B6B0 )
goto LABEL_6;
LABEL_15:
if ( &pthread_create )
{
v17 = (unsigned int *)(v10 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(_DWORD *)(v10 - 8);
*(_DWORD *)(v10 - 8) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v11);
goto LABEL_6;
}
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(v7); ++i )
{
v15 = cocos2d::CCArray::objectAtIndex(v7, i);
v16 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v15 + 64LL))(v15);
if ( (v16 & 0x80000000) == 0 && v16 <= 2 )
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v15 + 896LL))(v15, 50);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v15 + 944LL))(v15, &unk_F039B8);
}
v10 = v29;
v11 = (void *)(v29 - 24);
if ( (__int64 *)(v29 - 24) != &qword_124B6B0 )
goto LABEL_15;
LABEL_6:
v12 = (void *)(v28 - 24);
if ( (__int64 *)(v28 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v28 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(_DWORD *)(v28 - 8);
*(_DWORD *)(v28 - 8) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v12);
}
return (cocos2d::CCArray *)_stack_chk_guard;
}