//
// sub_498B52 from 0x498b52 to 0x498be8 (150 bytes)
//
// 3 xrefs:
// > GJEffectManager::toggleItemPersistent @ 0x49d442
// > GJEffectManager::transferPersistentItems @ 0x49d49e
// > GJEffectManager::updateCountForItem @ 0x4a33dc
//
// 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 sub_498B52(int *a1, _DWORD *a2)
{
unsigned int v2; // r9
int v4; // r6
void **result; // r0
int v6; // r8
void **v7; // r7
_DWORD *v8; // r10
int v9; // r1
int v10; // r2
int v11; // r1
v2 = a1[1];
v4 = *a2 % v2;
result = (void **)sub_498B14(a1, v4, a2);
if ( result )
{
v6 = *a1;
v7 = (void **)*result;
if ( result != *(void ***)(*a1 + 4 * v4) )
{
if ( *v7 )
{
v11 = *((_DWORD *)*v7 + 1) % v2;
if ( v11 != v4 )
*(_DWORD *)(v6 + 4 * v11) = result;
}
goto LABEL_12;
}
v8 = *v7;
if ( *v7 )
{
v9 = v8[1] % v2;
if ( v9 == v4 )
{
LABEL_12:
*result = *v7;
operator delete(v7);
--a1[3];
return (void **)(&dword_0 + 1);
}
*(_DWORD *)(v6 + 4 * v9) = result;
}
v10 = *a1;
if ( *(int **)(*a1 + 4 * v4) == a1 + 2 )
a1[2] = (int)v8;
*(_DWORD *)(v10 + 4 * v4) = 0;
goto LABEL_12;
}
return result;
}