//
// GJEffectManager::timeForItem from 0x1002eda50 to 0x1002edb9a (330 bytes)
//
// 7 xrefs:
// > GJBaseGameLayer::getItemValue @ 0x10014c2d3
// > GJBaseGameLayer::activateItemEditTrigger @ 0x10014c700
// > GJBaseGameLayer::activateItemEditTrigger @ 0x10014c7a9
// > GJBaseGameLayer::activateItemEditTrigger @ 0x10014c904
// > GJBaseGameLayer::activateItemCompareTrigger @ 0x10014ce2e
// > GJBaseGameLayer::activateItemCompareTrigger @ 0x10014d1d6
// > GJBaseGameLayer::updateTimerLabels @ 0x10014d87e
//
// 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
//
double __fastcall GJEffectManager::timeForItem(GJEffectManager *a1, int a2)
{
int v2; // eax
unsigned __int64 v3; // rcx
unsigned __int64 value; // rsi
double result; // xmm0_8
unsigned __int64 v6; // r9
unsigned __int64 v7; // r8
std::__hash_node_base, void *> *> *v8; // rax
std::__hash_node_base, void *> *>::__next_pointer next; // rdi
unsigned __int64 v10; // rsi
std::__hash_node_base, void *> *>::__next_pointer v11; // rax
unsigned __int64 v12; // rax
v2 = 0;
if ( a2 > 0 )
v2 = a2;
v3 = 9999;
if ( v2 < 9999 )
v3 = (unsigned int)v2;
value = a1->m_timerItemMap.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
result = 0.0;
if ( value )
{
v6 = (0x101010101010101LL
* ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v6 > 1 )
{
v7 = v3;
if ( value <= v3 )
v7 = (unsigned __int16)((unsigned __int16)v3 % (unsigned __int16)value);
}
else
{
v7 = ((_DWORD)value + 0x3FFF) & (unsigned int)v3;
}
v8 = a1->m_timerItemMap.__table_.__bucket_list_.__ptr_.__value_[v7];
if ( v8 )
{
next = v8->__next_;
if ( v8->__next_ )
{
if ( (unsigned int)v6 < 2 )
{
v10 = value - 1;
while ( 1 )
{
v11 = next[1].__next_;
if ( v11 == (std::__hash_node_base, void *> *>::__next_pointer)v3 )
{
if ( LODWORD(next[2].__next_) == (_DWORD)v3 )
return *(double *)&next[4].__next_;
}
else if ( (v10 & (unsigned __int64)v11) != v7 )
{
return result;
}
next = next->__next_;
if ( !next )
return result;
}
}
do
{
v12 = (unsigned __int64)next[1].__next_;
if ( v12 == v3 )
{
if ( LODWORD(next[2].__next_) == (_DWORD)v3 )
return *(double *)&next[4].__next_;
}
else
{
if ( v12 < value )
goto LABEL_25;
if ( (value | v12) >> 32 )
{
v12 %= value;
LABEL_25:
if ( v12 != v7 )
return result;
goto LABEL_20;
}
if ( (unsigned int)v12 % (unsigned int)value != v7 )
return result;
}
LABEL_20:
next = next->__next_;
}
while ( next );
}
}
}
return result;
}