//
// GJEffectManager::updateCountForItem from 0xa12644 to 0xa12a68 (1060 bytes)
//
// 9 xrefs:
// > GJBaseGameLayer::activateProgressTrigger @ 0x9ec8f4
// > GJBaseGameLayer::addPickupTrigger @ 0x9eca54
// > GJBaseGameLayer::addPickupTrigger @ 0x9eca80
// > GJBaseGameLayer::addPickupTrigger @ 0x9eca94
// > GJBaseGameLayer::activateItemEditTrigger @ 0x9ecc04
// > GJBaseGameLayer::activatePersistentItemTrigger @ 0x9ecf00
// > GJBaseGameLayer::activatePersistentItemTrigger @ 0x9ecf9c
// > GJEffectManager::addCountToItem @ 0xa12ab8
// > ??> @ 0x8a160
//
// This function is hookable on this platform (idp: arm, 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:59:31 +0000
//
__int64 __fastcall GJEffectManager::updateCountForItem(GJEffectManager *this, int a2, int a3)
{
int v5; // w2
int v6; // w19
__int64 *v7; // x0
unsigned __int64 v8; // x2
unsigned __int64 v9; // x6
unsigned __int64 v10; // x4
__int64 **v11; // x0
__int64 *v12; // x20
unsigned __int64 v13; // x0
unsigned __int64 v14; // x0
__int64 v16; // x0
char *v17; // x1
__int64 (__fastcall *v18)(char *, char *); // x3
int v19; // w24
unsigned __int64 v20; // x22
__int64 v21; // x1
__int64 v22; // x2
__int64 v23; // x21
int v24; // w3
int v25; // w1
int v26; // w19
unsigned __int64 v27; // x19
__int64 v28; // x27
unsigned __int64 v29; // x28
int v30; // w10
int v31; // w9
int v32; // w8
char v33; // w7
int v34; // w6
int v35; // w5
int v36; // w4
char v37; // w3
char *v38; // x0
char *v39; // x4
__int64 v40; // x4
__int64 v41; // x0
char *v42; // x0
char *v43; // x3
unsigned int v44; // [xsp+6Ch] [xbp+6Ch]
unsigned int v45; // [xsp+70h] [xbp+70h]
unsigned __int8 v46; // [xsp+74h] [xbp+74h]
unsigned int v47; // [xsp+78h] [xbp+78h]
int v48[3]; // [xsp+7Ch] [xbp+7Ch] BYREF
__int64 (__fastcall *v49)(char *, char *); // [xsp+88h] [xbp+88h] BYREF
void *v50; // [xsp+90h] [xbp+90h] BYREF
char *v51; // [xsp+98h] [xbp+98h]
v48[0] = a2;
v5 = 9999;
if ( a2 <= 9998 )
{
if ( a2 < 0 )
v5 = 0;
else
v5 = a2;
}
v48[0] = v5;
v6 = GJEffectManager::countForItem(this, v5);
v7 = (__int64 *)((char *)this + 712);
if ( a3 )
*(_DWORD *)std::unordered_map::operator[]((__int64)v7, v48) = a3;
else
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::__erase_unique(
v7,
v48);
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
(_QWORD *)this + 94,
v48) )
{
*(_DWORD *)std::unordered_map::operator[]((__int64)this + 752, v48) = a3;
}
v8 = *((_QWORD *)this + 60);
if ( v8 )
{
v9 = v8 - 1;
v10 = ((v8 - 1) & v8) != 0 ? v48[0] % v8 : v9 & v48[0];
v11 = *(__int64 ***)(*((_QWORD *)this + 59) + 8 * v10);
if ( v11 )
{
v12 = *v11;
if ( *v11 )
{
while ( 1 )
{
v13 = v12[1];
if ( ((v8 - 1) & v8) != 0 )
v14 = v13 % v8;
else
v14 = v9 & v13;
if ( v10 != v14 )
return _stack_chk_guard;
if ( v48[0] == *((_DWORD *)v12 + 4) )
break;
v12 = (__int64 *)*v12;
if ( !v12 )
return _stack_chk_guard;
}
v16 = v12[3];
v17 = (char *)v12[4];
if ( v6 > a3 )
v18 = (__int64 (__fastcall *)(char *, char *))countSortDec;
else
v18 = (__int64 (__fastcall *)(char *, char *))countSortAsc;
v19 = 0;
v20 = 0;
v49 = v18;
std::__sort(v16, v17, &v49);
v21 = v12[3];
v22 = v12[4] - v21;
while ( 1 )
{
if ( v20 >= v22 >> 6 )
return _stack_chk_guard;
v23 = v21 + (v20 << 6);
if ( *(_BYTE *)v23 || (v24 = *(_DWORD *)(v23 + 4), v24 == a3) )
{
LABEL_54:
v20 = ++v19;
}
else
{
v25 = *(_DWORD *)(v23 + 8);
*(_DWORD *)(v23 + 4) = a3;
if ( a3 >= v25 && v24 < v25 || a3 <= v25 && v24 > v25 )
{
v26 = 0;
v47 = *(_DWORD *)(v23 + 12);
v46 = *(_BYTE *)(v23 + 16);
v45 = *(_DWORD *)(v23 + 20);
v44 = *(_DWORD *)(v23 + 24);
if ( !*(_BYTE *)(v23 + 32) )
{
v27 = v12[3] + (v20 << 6);
v28 = v12[4];
if ( v27 + 64 != v28 )
{
v29 = v27 + 64;
do
{
v27 = v29;
v30 = *(_DWORD *)(v29 + 4);
v31 = *(_DWORD *)(v29 + 8);
v32 = *(_DWORD *)(v29 + 12);
v33 = *(_BYTE *)(v29 + 16);
v34 = *(_DWORD *)(v29 + 20);
v35 = *(_DWORD *)(v29 + 24);
v36 = *(_DWORD *)(v29 + 28);
v37 = *(_BYTE *)(v29 + 32);
v38 = *(char **)(v29 - 24);
*(_BYTE *)(v29 - 64) = *(_BYTE *)v29;
*(_DWORD *)(v29 - 60) = v30;
*(_DWORD *)(v29 - 56) = v31;
*(_DWORD *)(v29 - 52) = v32;
*(_BYTE *)(v29 - 48) = v33;
*(_DWORD *)(v29 - 44) = v34;
*(_DWORD *)(v29 - 40) = v35;
*(_DWORD *)(v29 - 36) = v36;
*(_BYTE *)(v29 - 32) = v37;
if ( v38 )
{
v39 = *(char **)(v29 - 16);
if ( v38 != v39 )
*(_QWORD *)(v29 - 16) = &v39[4 * ~((unsigned __int64)(v39 - 4 - v38) >> 2)];
operator delete(v38);
}
v40 = *(_QWORD *)(v29 + 40);
v29 += 64LL;
*(_QWORD *)(v29 - 88) = v40;
*(_QWORD *)(v29 - 24) = 0;
v41 = *(_QWORD *)(v29 - 8);
*(_QWORD *)(v29 - 80) = *(_QWORD *)(v29 - 16);
*(_QWORD *)(v29 - 72) = v41;
*(_QWORD *)(v29 - 8) = 0;
*(_QWORD *)(v29 - 16) = 0;
}
while ( v28 != v29 );
v28 = v12[4];
}
for ( ; v28 != v27; v28 = v12[4] )
{
v12[4] = v28 - 64;
v42 = *(char **)(v28 - 24);
if ( v42 )
{
v43 = *(char **)(v28 - 16);
if ( v42 != v43 )
*(_QWORD *)(v28 - 16) = &v43[4 * ~((unsigned __int64)(v43 - 4 - v42) >> 2)];
operator delete(v42);
}
}
v26 = 1;
}
if ( *((_QWORD *)this + 40) )
{
std::vector::vector((__int64 *)&v50, (const void **)(v23 + 40));
(***((void (__fastcall ****)(_QWORD, _QWORD, _QWORD, void **, _QWORD, _QWORD))this + 40))(
*((_QWORD *)this + 40),
v47,
v46,
&v50,
v45,
v44);
if ( v50 )
{
if ( v50 != v51 )
v51 += 4 * ~((unsigned __int64)(v51 - 4 - (_BYTE *)v50) >> 2);
operator delete(v50);
}
}
else
{
GJEffectManager::toggleGroup(this, v47, v46);
}
v21 = v12[3];
v22 = v12[4] - v21;
if ( !v26 )
goto LABEL_54;
}
else
{
v20 = ++v19;
v21 = v12[3];
v22 = v12[4] - v21;
}
}
}
}
}
}
return _stack_chk_guard;
}