//
// sub_1402B6AE0 from 0x1402b6ae0 to 0x1402b6c61 (385 bytes)
//
// 7 xrefs:
// > GJSmartTemplate::scanForPrefab @ 0x1402b1b99
// > GJSmartTemplate::scanForPrefab @ 0x1402b1bb7
// > GJSmartTemplate::scanForPrefab @ 0x1402b1bd9
// > GJSmartTemplate::scanForPrefab @ 0x1402b1bfd
// > GJSmartTemplate::scanForPrefab @ 0x1402b1c20
// > GJSmartTemplate::scanForPrefab @ 0x1402b276a
// > ??> @ 0x1406d24bc
//
// 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
//
// Hidden C++ exception states: #wind=4
__int64 __fastcall sub_1402B6AE0(_QWORD *a1, __int64 a2, _QWORD *a3)
{
__int64 *v6; // rbp
__int64 *v7; // rbx
__int64 *v8; // rdi
char *v9; // rdi
__int128 v11; // [rsp+20h] [rbp-58h] BYREF
__int128 v12; // [rsp+30h] [rbp-48h]
v6 = (__int64 *)*a1;
v7 = *(__int64 **)(*a1 + 8LL);
*(_QWORD *)&v12 = v7;
DWORD2(v12) = 0;
v8 = v6;
while ( !*((_BYTE *)v7 + 25) )
{
*(_QWORD *)&v12 = v7;
if ( sub_14003A760(v7 + 4, a3) >= 0 )
{
DWORD2(v12) = 1;
v8 = v7;
v7 = (__int64 *)*v7;
}
else
{
DWORD2(v12) = 0;
v7 = (__int64 *)v7[2];
}
}
if ( *((_BYTE *)v8 + 25) || sub_14003A760(a3, v8 + 4) < 0 )
{
if ( a1[1] == 0x1AF286BCA1AF286LL )
sub_140052E40(a1, a2, a3);
v9 = (char *)operator new(0x98u);
sub_14003BDB0((__int64)(v9 + 32), (__int64)a3);
*((_QWORD *)v9 + 8) = 0;
*(_OWORD *)(v9 + 72) = 0;
*((_QWORD *)v9 + 11) = 0;
*((_QWORD *)v9 + 12) = 15;
v9[72] = 0;
*(_OWORD *)(v9 + 104) = 0;
*((_QWORD *)v9 + 15) = 0;
*((_QWORD *)v9 + 16) = 15;
v9[104] = 0;
*((_DWORD *)v9 + 34) = 0;
v9[140] = 0;
*((_DWORD *)v9 + 36) = 0;
*((_WORD *)v9 + 74) = 0;
v9[150] = 0;
*(_QWORD *)v9 = v6;
*((_QWORD *)v9 + 1) = v6;
*((_QWORD *)v9 + 2) = v6;
*((_WORD *)v9 + 12) = 0;
v11 = v12;
*(_QWORD *)a2 = sub_1400636D0(a1, (__int64)&v11, (__int64)v9);
*(_BYTE *)(a2 + 8) = 1;
}
else
{
*(_QWORD *)a2 = v8;
*(_BYTE *)(a2 + 8) = 0;
}
return a2;
}