//
// GJEffectManager::runCountTrigger from 0x1002e9e00 to 0x1002ea088 (648 bytes)
//
// 1 xrefs:
// > CountTriggerGameObject::triggerObject @ 0x1001d6d9f
//
// 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
//
void __fastcall GJEffectManager::runCountTrigger(
GJEffectManager *a1,
int a2,
int a3,
bool a4,
int a5,
bool a6,
std::vector *const a7,
int a8,
int a9)
{
__int64 v13; // rbx
int v14; // esi
int next_high; // r8d
int v16; // eax
unsigned __int64 v17; // rcx
unsigned __int64 value; // rdi
unsigned __int64 v19; // r11
unsigned __int64 v20; // r9
std::__hash_node_base, void *> *> *v21; // rax
std::__hash_node_base, void *> *>::__next_pointer next; // r10
unsigned __int64 v23; // rdi
unsigned __int64 v24; // rax
std::__hash_node_base, void *> *>::__next_pointer v25; // rax
unsigned __int64 v26; // r14
__int64 v27; // r14
int v28; // [rsp+2Ch] [rbp-54h] BYREF
int v29; // [rsp+30h] [rbp-50h] BYREF
_BOOL4 v30; // [rsp+34h] [rbp-4Ch]
int v31; // [rsp+38h] [rbp-48h]
int v32; // [rsp+3Ch] [rbp-44h]
int *v33; // [rsp+40h] [rbp-40h] BYREF
char v34; // [rsp+4Fh] [rbp-31h] BYREF
int v35; // [rsp+50h] [rbp-30h] BYREF
bool v36; // [rsp+56h] [rbp-2Ah] BYREF
bool v37; // [rsp+57h] [rbp-29h] BYREF
v31 = a9;
v32 = a8;
v35 = a2;
v28 = a3;
v30 = a4;
v36 = a4;
v29 = a5;
v37 = a6;
v33 = &v35;
v13 = sub_1002F5360(&a1->m_countTriggerActions, &v35, &unk_100819506, &v33, &v34);
v14 = v35;
next_high = 0;
v16 = 0;
if ( v35 > 0 )
v16 = v35;
v17 = 9999;
if ( v16 < 9999 )
v17 = (unsigned int)v16;
value = a1->m_itemCountMap.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
if ( value )
{
v19 = (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 ( v19 > 1 )
{
v20 = v17;
if ( value <= v17 )
v20 = (unsigned __int16)((unsigned __int16)v17 % (unsigned __int16)value);
}
else
{
v20 = ((_DWORD)value + 0x3FFF) & (unsigned int)v17;
}
v21 = a1->m_itemCountMap.__table_.__bucket_list_.__ptr_.__value_[v20];
if ( v21 )
{
next = v21->__next_;
if ( v21->__next_ )
{
if ( (unsigned int)v19 < 2 )
{
v23 = value - 1;
while ( 1 )
{
v25 = next[1].__next_;
if ( v25 == (std::__hash_node_base, void *> *>::__next_pointer)v17 )
{
if ( LODWORD(next[2].__next_) == (_DWORD)v17 )
goto LABEL_29;
}
else if ( (v23 & (unsigned __int64)v25) != v20 )
{
goto LABEL_30;
}
next = next->__next_;
if ( !next )
goto LABEL_30;
}
}
while ( 1 )
{
v24 = (unsigned __int64)next[1].__next_;
if ( v24 == v17 )
{
if ( LODWORD(next[2].__next_) == (_DWORD)v17 )
{
LABEL_29:
next_high = HIDWORD(next[2].__next_);
break;
}
}
else
{
if ( v24 < value )
goto LABEL_20;
if ( (value | v24) >> 32 )
{
v24 %= value;
LABEL_20:
if ( v24 != v20 )
goto LABEL_23;
goto LABEL_15;
}
if ( (unsigned int)v24 % (unsigned int)value != v20 )
{
LABEL_23:
next_high = 0;
break;
}
}
LABEL_15:
next = next->__next_;
if ( !next )
goto LABEL_23;
}
}
}
}
LABEL_30:
LODWORD(v33) = next_high;
v26 = *(_QWORD *)(v13 + 32);
if ( v26 >= *(_QWORD *)(v13 + 40) )
{
v27 = sub_1002F58B0(
(int)v13 + 24,
(unsigned int)&v29,
(unsigned int)&v28,
(unsigned int)&v37,
(unsigned int)&v36,
(unsigned int)&v35,
(__int64)&v33,
(__int64)a7,
(__int64)&a8,
(__int64)&a9);
}
else
{
*(_BYTE *)v26 = 0;
*(_OWORD *)(v26 + 40) = 0;
*(_QWORD *)(v26 + 56) = 0;
*(_DWORD *)(v26 + 12) = a5;
*(_DWORD *)(v26 + 8) = a3;
*(_BYTE *)(v26 + 16) = a6;
*(_BYTE *)(v26 + 32) = v30;
*(_DWORD *)(v26 + 28) = v14;
*(_DWORD *)(v26 + 4) = next_high;
*(_DWORD *)(v26 + 20) = v32;
*(_DWORD *)(v26 + 24) = v31;
if ( (std::vector *const)(v26 + 40) != a7 )
sub_1000C51C0((char **)(v26 + 40), (char *)a7->__begin_, (__int64)a7->__end_, a7->__end_ - a7->__begin_);
v27 = v26 + 64;
*(_QWORD *)(v13 + 32) = v27;
}
*(_QWORD *)(v13 + 32) = v27;
}