//
// GJEffectManager::timeForItem from 0x1002d86d0 to 0x1002d881a (330 bytes)
//
// 7 xrefs:
// > GJBaseGameLayer::getItemValue @ 0x10012a143
// > GJBaseGameLayer::activateItemEditTrigger @ 0x10012a570
// > GJBaseGameLayer::activateItemEditTrigger @ 0x10012a619
// > GJBaseGameLayer::activateItemEditTrigger @ 0x10012a774
// > GJBaseGameLayer::activateItemCompareTrigger @ 0x10012ac9e
// > GJBaseGameLayer::activateItemCompareTrigger @ 0x10012b046
// > GJBaseGameLayer::updateTimerLabels @ 0x10012b6ee
//
// 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:16 +0000
//
double __fastcall GJEffectManager::timeForItem(__int64 a1, int a2)
{
int v2; // eax
unsigned __int64 v3; // rcx
unsigned __int64 v4; // rsi
double result; // xmm0_8
unsigned __int64 v6; // r9
unsigned __int64 v7; // r8
double **v8; // rax
double *v9; // rdi
unsigned __int64 v10; // rsi
__int64 v11; // rax
unsigned __int64 v12; // rax
v2 = 0;
if ( a2 > 0 )
v2 = a2;
v3 = 9999;
if ( v2 < 9999 )
v3 = (unsigned int)v2;
v4 = *(_QWORD *)(a1 + 928);
result = 0.0;
if ( v4 )
{
v6 = (0x101010101010101LL
* ((((v4 - ((v4 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v4 - ((v4 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v4 - ((v4 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v4 - ((v4 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v6 > 1 )
{
v7 = v3;
if ( v4 <= v3 )
v7 = (unsigned __int16)((unsigned __int16)v3 % (unsigned __int16)v4);
}
else
{
v7 = ((_DWORD)v4 + 0x3FFF) & (unsigned int)v3;
}
v8 = *(double ***)(*(_QWORD *)(a1 + 920) + 8 * v7);
if ( v8 )
{
v9 = *v8;
if ( *v8 )
{
if ( (unsigned int)v6 < 2 )
{
v10 = v4 - 1;
while ( 1 )
{
v11 = *((_QWORD *)v9 + 1);
if ( v11 == v3 )
{
if ( *((_DWORD *)v9 + 4) == (_DWORD)v3 )
return v9[4];
}
else if ( (v10 & v11) != v7 )
{
return result;
}
v9 = *(double **)v9;
if ( !v9 )
return result;
}
}
do
{
v12 = *((_QWORD *)v9 + 1);
if ( v12 == v3 )
{
if ( *((_DWORD *)v9 + 4) == (_DWORD)v3 )
return v9[4];
}
else
{
if ( v12 < v4 )
goto LABEL_25;
if ( (v4 | v12) >> 32 )
{
v12 %= v4;
LABEL_25:
if ( v12 != v7 )
return result;
goto LABEL_20;
}
if ( (unsigned int)v12 % (unsigned int)v4 != v7 )
return result;
}
LABEL_20:
v9 = *(double **)v9;
}
while ( v9 );
}
}
}
return result;
}