//
// sub_1002A00C0 from 0x1002a00c0 to 0x1002a0219 (345 bytes)
//
// 3 xrefs:
// > GameLevelOptionsLayer::didToggle @ 0x10029ff11
// > GameLevelOptionsLayer::FLAlert_Clicked @ 0x1002a0245
// > sub_1002A0250 @ 0x1002a0279
//
// This function is hookable on this platform (idp: pc, 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:27:54 +0000
//
unsigned __int64 __fastcall sub_1002A00C0(_QWORD *a1)
{
unsigned __int64 result; // rax
unsigned __int8 v2; // cl
unsigned __int64 v3; // rsi
__int64 v4; // r8
__int64 **v5; // rdx
__int64 *v6; // rdi
unsigned __int64 v7; // rsi
__int64 v8; // rdi
result = a1[141];
v2 = *(_BYTE *)(result + 769) ^ 1;
*(_BYTE *)(result + 769) = v2;
v3 = a1[136];
if ( v3 )
{
result = (0x101010101010101LL
* ((((v3 - ((v3 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v3 - ((v3 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v3 - ((v3 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v3 - ((v3 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
v4 = v3 != 1;
if ( result < 2 )
v4 = (v3 & 1) == 0;
v5 = *(__int64 ***)(a1[135] + 8 * v4);
if ( v5 )
{
v6 = *v5;
if ( *v5 )
{
if ( (unsigned int)result < 2 )
{
v7 = v3 - 1;
while ( 1 )
{
result = v6[1];
if ( result == 1 )
{
if ( *((_DWORD *)v6 + 4) == 1 )
goto LABEL_23;
}
else
{
result &= v7;
if ( result != v4 )
return result;
}
v6 = (__int64 *)*v6;
if ( !v6 )
return result;
}
}
do
{
result = v6[1];
if ( result == 1 )
{
if ( *((_DWORD *)v6 + 4) == 1 )
{
LABEL_23:
v8 = v6[3];
if ( v8 )
return CCMenuItemToggler::toggle(v8, v2);
return result;
}
}
else
{
if ( result < v3 )
goto LABEL_19;
if ( (v3 | result) >> 32 )
{
result %= v3;
LABEL_19:
if ( result != v4 )
return result;
goto LABEL_14;
}
result = (unsigned int)result % (unsigned int)v3;
if ( result != v4 )
return result;
}
LABEL_14:
v6 = (__int64 *)*v6;
}
while ( v6 );
}
}
}
return result;
}