//
// sub_1402526C0 from 0x1402526c0 to 0x1402528e8 (552 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::activateEventTrigger @ 0x140232321
// > ??> @ 0x1406cf3c0
//
// 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: #try_helpers=1
_QWORD *__fastcall sub_1402526C0(_QWORD *a1, _QWORD *a2, _DWORD *a3, __int64 a4, int *a5, int *a6)
{
_QWORD *v8; // r11
__int64 v9; // rsi
__int64 v10; // rcx
unsigned __int64 v11; // r12
unsigned __int64 v12; // rdx
unsigned __int64 v13; // rcx
__int64 v14; // r13
_QWORD *v15; // r14
_QWORD *v16; // r15
int v17; // edx
int v18; // ecx
_QWORD *v19; // rdx
_QWORD *v20; // rcx
_QWORD *v21; // r8
_QWORD *v22; // rbx
_QWORD *i; // rsi
_QWORD *v24; // r8
v8 = (_QWORD *)*a1;
v9 = ((__int64)a2 - *a1) / 40;
v10 = a1[1] - *a1;
if ( v10 / 40 == 0x666666666666666LL )
sub_140062A20(v10, 0x666666666666666LL);
v11 = v10 / 40 + 1;
v12 = (a1[2] - (_QWORD)v8) / 40LL;
if ( v12 <= 0x666666666666666LL - (v12 >> 1) )
{
v13 = v10 / 40 + 1;
if ( (v12 >> 1) + v12 >= v11 )
v13 = (v12 >> 1) + v12;
if ( v13 > 0x666666666666666LL )
sub_140007AB0(v13, v12, 0x666666666666666LL);
}
else
{
v13 = 0x666666666666666LL;
}
v14 = 5 * v13;
v15 = sub_14003AA10(40 * v13);
v16 = &v15[5 * v9];
v17 = *a6;
v18 = *a5;
*(_DWORD *)v16 = *a3;
*((_DWORD *)v16 + 1) = v18;
*((_DWORD *)v16 + 2) = v17;
*((_BYTE *)v16 + 12) = 0;
sub_14024B270(v16 + 2, a4);
v19 = (_QWORD *)a1[1];
v20 = (_QWORD *)*a1;
v21 = v15;
if ( a2 != v19 )
{
sub_1402547D0(v20, a2, v15);
v21 = v16 + 5;
v19 = (_QWORD *)a1[1];
v20 = a2;
}
sub_1402547D0(v20, v19, v21);
v22 = (_QWORD *)*a1;
if ( *a1 )
{
for ( i = (_QWORD *)a1[1]; v22 != i; v22 += 5 )
sub_14005E430((__int64)(v22 + 2));
v24 = (_QWORD *)*a1;
if ( (unsigned __int64)(40 * ((a1[2] - *a1) / 40LL)) >= 0x1000 )
{
if ( (unsigned __int64)v24 - *(v24 - 1) - 8 > 0x1F )
invalid_parameter_noinfo_noreturn();
v24 = (_QWORD *)*(v24 - 1);
}
j_j_free(v24);
}
*a1 = v15;
a1[1] = &v15[5 * v11];
a1[2] = &v15[v14];
return v16;
}