//
// GJGarageLayer::onArrow from 0x100355ed0 to 0x10035601e (334 bytes)
//
// 2 xrefs:
// > GJGarageLayer::setupIconSelect @ 0x100355124
// > GJGarageLayer::setupIconSelect @ 0x1003551fc
//
// 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:28:52 +0000
//
__int64 __fastcall GJGarageLayer::onArrow(__int64 a1, __int64 a2)
{
int v3; // r15d
__int64 v4; // rdx
double v5; // xmm0_8
__int64 v6; // rsi
__int64 v7; // rax
__int64 v8; // rdi
__int64 v9; // rdx
double v10; // xmm0_8
__int64 v11; // rax
int v12; // eax
__int64 v13; // rcx
signed int v14; // r12d
_QWORD *v15; // r14
__int64 *v16; // r13
int v17; // ecx
__int64 *v18; // r15
__int64 v19; // rax
int v20; // edx
int v21; // eax
__int64 v22; // rsi
int v24; // [rsp+0h] [rbp-30h]
int v25; // [rsp+4h] [rbp-2Ch]
v3 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 64LL))(a2);
*(_QWORD *)&v5 = GameManager::sharedState(a2, a2, v4).u64[0];
v6 = *(unsigned int *)(a1 + 516);
v8 = v7;
GameManager::activeIconForType(v7, v6, v5);
*(_QWORD *)&v10 = GameManager::sharedState(v8, v6, v9).u64[0];
v12 = GameManager::countForType(v11, *(unsigned int *)(a1 + 516), v10);
v13 = *(_QWORD *)(a1 + 528);
v14 = *(_DWORD *)(a1 + 516);
if ( v13 )
{
while ( 1 )
{
while ( 1 )
{
v16 = (__int64 *)v13;
v17 = *(_DWORD *)(v13 + 28);
if ( v14 >= v17 )
break;
v13 = *v16;
v15 = v16;
if ( !*v16 )
goto LABEL_8;
}
if ( v14 <= v17 )
break;
v13 = v16[1];
if ( !v13 )
{
v15 = v16 + 1;
goto LABEL_8;
}
}
}
else
{
v15 = (_QWORD *)(a1 + 528);
v16 = (__int64 *)(a1 + 528);
LABEL_8:
v25 = v12;
v24 = v3;
v18 = v16;
v16 = (__int64 *)operator new(0x28u);
*((_DWORD *)v16 + 7) = v14;
*((_DWORD *)v16 + 8) = 0;
*(_OWORD *)v16 = 0;
v16[2] = (__int64)v18;
*v15 = v16;
v19 = **(_QWORD **)(a1 + 520);
if ( v19 )
*(_QWORD *)(a1 + 520) = v19;
sub_10001B680(*(__int64 **)(a1 + 528), v16);
++*(_QWORD *)(a1 + 536);
v14 = *(_DWORD *)(a1 + 516);
v3 = v24;
v12 = v25;
}
v20 = v12 / 36;
v21 = *((_DWORD *)v16 + 8) + 2 * (v3 == 1) - 1;
v22 = 0;
if ( v21 <= v20 )
v22 = (unsigned int)v21;
if ( v21 < 0 )
v22 = (unsigned int)v20;
return GJGarageLayer::setupPage(a1, v22, (unsigned int)v14);
}