//
// GJBaseGameLayer::controlEventLink from 0x1001144c0 to 0x1001146a1 (481 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::controlTriggersInGroup @ 0x100113abe
// > GJBaseGameLayer::controlTriggersWithControlID @ 0x100114967
//
// 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:24:33 +0000
//
void __fastcall GJBaseGameLayer::controlEventLink(__int64 a1, int a2, int a3, int a4)
{
_QWORD *v4; // r12
int v5; // r14d
int v6; // esi
__int128 v7; // xmm1
__int64 v8; // rax
__int64 v9; // r15
__int64 v10; // rcx
int v11; // r13d
char v12; // cl
__int64 v13; // rcx
__int64 v14; // rbx
__int64 v15; // r14
__int64 v16; // rax
void *v17; // rdi
void *v18; // rdi
_QWORD *v19; // rcx
_QWORD *v20; // rax
bool v21; // zf
_QWORD *v22; // [rsp+0h] [rbp-40h]
v4 = *(_QWORD **)(a1 + 1304);
v22 = (_QWORD *)(a1 + 1312);
if ( v4 != (_QWORD *)(a1 + 1312) )
{
v5 = a4;
v6 = a3;
v7 = 0;
while ( 1 )
{
v8 = v4[5];
v9 = v4[6];
if ( v9 != v8 )
break;
LABEL_29:
v19 = (_QWORD *)v4[1];
if ( v19 )
{
do
{
v20 = v19;
v19 = (_QWORD *)*v19;
}
while ( v19 );
}
else
{
do
{
v20 = (_QWORD *)v4[2];
v21 = *v20 == (_QWORD)v4;
v4 = v20;
}
while ( !v21 );
}
v4 = v20;
if ( v20 == v22 )
return;
}
v10 = 0;
v11 = 0;
while ( 1 )
{
v13 = 5 * v10;
v14 = v8 + 8 * v13;
if ( (v6 == -1 || *(_DWORD *)(v8 + 8 * v13 + 8) != v6) && (v6 != -1 || *(_DWORD *)(v14 + 4) != a2) )
goto LABEL_8;
if ( v5 == 2 )
break;
if ( v5 == 1 )
{
v12 = 1;
LABEL_7:
*(_BYTE *)(v14 + 12) = v12;
goto LABEL_8;
}
if ( !v5 )
{
if ( v14 + 40 != v9 )
{
v15 = v8 + 8 * v13 + 24;
do
{
*(_QWORD *)(v15 - 19) = *(_QWORD *)(v15 + 21);
v17 = *(void **)(v15 - 8);
*(_QWORD *)(v15 - 24) = *(_QWORD *)(v15 + 16);
if ( v17 )
{
*(_QWORD *)v15 = v17;
operator delete(v17);
v7 = 0;
*(_OWORD *)v15 = 0;
}
v16 = v15 - 24;
*(_OWORD *)(v15 - 8) = *(_OWORD *)(v15 + 32);
*(_QWORD *)(v15 + 8) = *(_QWORD *)(v15 + 48);
*(_OWORD *)(v15 - 24 + 56) = v7;
*(_QWORD *)(v15 - 24 + 72) = 0;
v14 += 40;
v15 += 40;
}
while ( v16 + 80 != v9 );
v9 = v4[6];
v5 = a4;
}
while ( v9 != v14 )
{
v18 = *(void **)(v9 - 24);
if ( v18 )
{
*(_QWORD *)(v9 - 16) = v18;
operator delete(v18);
v7 = 0;
}
v9 -= 40;
}
v4[6] = v14;
v8 = v4[5];
v9 = v14;
v6 = a3;
goto LABEL_9;
}
LABEL_8:
++v11;
LABEL_9:
v10 = v11;
if ( 0xCCCCCCCCCCCCCCCDLL * ((v9 - v8) >> 3) <= v11 )
goto LABEL_29;
}
v12 = 0;
goto LABEL_7;
}
}