//
// UILayer::toggleMenuVisibility from 0x1004c4e00 to 0x1004c4f60 (352 bytes)
//
// 7 xrefs:
// > PlayLayer::showEndLayer @ 0x100082b41
// > sub_100084250 @ 0x100084291
// > PlayLayer::resetLevel @ 0x10008c9aa
// > PlayLayer::pauseGame @ 0x10008da8d
// > PlayLayer::resumeAndRestart @ 0x10008dbab
// > PlayLayer::resume @ 0x10008dd75
// > UILayer::editorPlaytest @ 0x1004c37c9
//
// 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:31:07 +0000
//
__int64 __fastcall UILayer::toggleMenuVisibility(__int64 a1, char a2)
{
__int64 v3; // rax
unsigned int *v4; // rax
__int64 *v5; // r13
__int64 *v6; // r14
__int64 v7; // r15
__int64 v8; // rdi
__int64 v9; // rdi
__int64 v10; // rax
__int64 result; // rax
__int64 v12; // rax
unsigned int v13; // r15d
__int64 v14; // rsi
__int64 v15; // rax
__int16 v17; // [rsp+10h] [rbp-30h] BYREF
char v18; // [rsp+12h] [rbp-2Eh]
__int16 v19; // [rsp+14h] [rbp-2Ch] BYREF
char v20; // [rsp+16h] [rbp-2Ah]
v3 = *(_QWORD *)(a1 + 616);
if ( v3 )
{
v4 = *(unsigned int **)(v3 + 56);
if ( *v4 )
{
v5 = *((__int64 **)v4 + 2);
v6 = &v5[*v4 - 1];
do
{
v7 = *v5;
if ( !*v5 )
break;
*(_DWORD *)(v7 + 352) = -1;
*(_WORD *)(v7 + 383) = 0;
v8 = *(_QWORD *)(v7 + 320);
if ( v8 )
{
v20 = -1;
v19 = -1;
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v8 + 960LL))(v8, &v19);
}
v9 = *(_QWORD *)(v7 + 8LL * (*(unsigned __int8 *)(v7 + 381) ^ 1u) + 320);
if ( v9 )
{
v18 = -1;
v17 = -1;
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v9 + 960LL))(v9, &v17);
}
++v5;
}
while ( v5 <= v6 );
}
}
v10 = GameManager::sharedState();
result = GameManager::getGameVariable(v10, "0024");
if ( (_BYTE)result )
{
v12 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 568) + 1072LL))(*(_QWORD *)(a1 + 568));
v13 = 0;
v14 = 75;
if ( !a2 )
v14 = 0;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v12 + 912LL))(v12, v14);
result = sub_1007FEF90(*(_QWORD *)(a1 + 616));
if ( (_DWORD)result )
{
do
{
v15 = sub_1007FEFE0(*(_QWORD *)(a1 + 616), v13);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v15 + 344LL))(v15, 0);
++v13;
result = sub_1007FEF90(*(_QWORD *)(a1 + 616));
}
while ( v13 < (unsigned int)result );
}
}
return result;
}