//
// GJEffectManager::toggleItemPersistent from 0x1002ec350 to 0x1002ec543 (499 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::activatePersistentItemTrigger @ 0x10014d5a5
//
// 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::toggleItemPersistent(GJEffectManager *a1, int a2, bool a3)
{
__m128 v3; // xmm0
unsigned __int64 value; // rcx
int v5; // ebx
std::unordered_map *p_m_itemCountMap; // r10
unsigned __int64 v7; // r14
unsigned __int64 v8; // r9
std::__hash_node_base, void *> *> *v9; // rax
std::__hash_node_base, void *> *>::__next_pointer next; // r11
unsigned __int64 v11; // rcx
unsigned __int64 v12; // rax
std::__hash_node_base, void *> *>::__next_pointer v13; // rax
int *v14; // [rsp+0h] [rbp-20h] BYREF
int v15; // [rsp+8h] [rbp-18h] BYREF
v15 = a2;
if ( !a3 )
{
sub_1000569A0(&a1->m_persistentItemCountMap.__table_.__bucket_list_.__ptr_.__value_, &v15);
return;
}
value = a1->m_itemCountMap.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
v5 = 0;
if ( !value )
goto LABEL_31;
p_m_itemCountMap = &a1->m_itemCountMap;
v7 = (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 ( v7 <= 1 )
{
v8 = a2 & (value - 1);
v9 = p_m_itemCountMap->__table_.__bucket_list_.__ptr_.__value_[v8];
if ( !v9 )
goto LABEL_31;
goto LABEL_11;
}
v8 = a2;
if ( value > a2 )
goto LABEL_10;
if ( (value | a2) >> 32 )
{
v8 = a2 % value;
LABEL_10:
v9 = p_m_itemCountMap->__table_.__bucket_list_.__ptr_.__value_[v8];
if ( !v9 )
goto LABEL_31;
goto LABEL_11;
}
v8 = a2 % (unsigned int)value;
v9 = p_m_itemCountMap->__table_.__bucket_list_.__ptr_.__value_[v8];
if ( v9 )
{
LABEL_11:
next = v9->__next_;
if ( !v9->__next_ )
goto LABEL_31;
if ( (unsigned int)v7 < 2 )
{
v11 = value - 1;
while ( 1 )
{
v13 = next[1].__next_;
if ( v13 == (std::__hash_node_base, void *> *>::__next_pointer)a2 )
{
if ( LODWORD(next[2].__next_) == a2 )
goto LABEL_29;
}
else if ( (v11 & (unsigned __int64)v13) != v8 )
{
goto LABEL_31;
}
next = next->__next_;
if ( !next )
goto LABEL_31;
}
}
while ( 1 )
{
v12 = (unsigned __int64)next[1].__next_;
if ( v12 == a2 )
{
if ( LODWORD(next[2].__next_) == a2 )
{
LABEL_29:
v14 = &v15;
v5 = *((_DWORD *)sub_100055BA0((float *)&a1->m_itemCountMap, &v15, v3, (__int64)&unk_100819506, &v14) + 5);
break;
}
}
else
{
if ( v12 < value )
goto LABEL_20;
if ( (value | v12) >> 32 )
{
v12 %= value;
LABEL_20:
if ( v12 != v8 )
goto LABEL_23;
goto LABEL_15;
}
if ( (unsigned int)v12 % (unsigned int)value != v8 )
{
LABEL_23:
v5 = 0;
break;
}
}
LABEL_15:
next = next->__next_;
if ( !next )
goto LABEL_23;
}
}
LABEL_31:
v14 = &v15;
*((_DWORD *)sub_100055BA0((float *)&a1->m_persistentItemCountMap, &v15, v3, (__int64)&unk_100819506, &v14) + 5) = v5;
}