//
// UILayer::reapplyLevelControls from 0x1004c2d90 to 0x1004c2ef7 (359 bytes)
//
// 5 xrefs:
// > sub_10095E390 @ 0x10095e430
// > sub_10095EA10 @ 0x10095eb63
// > sub_10095F710 @ 0x10095f74d
// > PlatformerControlsPopup::onLevelControlsRefreshed @ 0x10095fd0b
// > PlatformerControlsPopup::onClose @ 0x10095fea2
//
// 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:06 +0000
//
__int64 __fastcall UILayer::reapplyLevelControls(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 result; // rax
__int64 *v6; // r15
unsigned __int64 v7; // r12
__int64 v8; // r13
__int64 v9; // rdi
__int64 v10; // rdi
_QWORD v11[6]; // [rsp+0h] [rbp-30h] BYREF
v11[0] = v1;
if ( *(_BYTE *)(a1 + 596) == 1 )
UILayer::resolveLevelControls(a1);
if ( (*(_BYTE *)(a1 + 626) != 1 || *(_BYTE *)(a1 + 627) == 1)
&& *(_BYTE *)(a1 + 596) == 1
&& (v2 = *(_QWORD *)(a1 + 640)) != 0
&& (*(_QWORD *)(v2 + 96) || *(_QWORD *)(v2 + 136)) )
{
v3 = GJKeybindManager::sharedState(a1);
GJKeybindManager::applyMovementOverride(v3, *(_QWORD *)(a1 + 640) + 72LL, *(_QWORD *)(a1 + 640) + 112LL);
}
else
{
v4 = GJKeybindManager::sharedState(a1);
GJKeybindManager::clearMovementOverride(v4);
}
*(_QWORD *)(a1 + 584) = -1;
*(_WORD *)(a1 + 578) = 0;
*(_BYTE *)(a1 + 580) = 0;
result = *(_QWORD *)(a1 + 616);
if ( result )
{
result = *(_QWORD *)(result + 56);
if ( *(_DWORD *)result )
{
v6 = *(__int64 **)(result + 16);
v7 = (unsigned __int64)&v6[*(unsigned int *)result - 1];
do
{
v8 = *v6;
if ( !*v6 )
break;
*(_DWORD *)(v8 + 352) = -1;
*(_WORD *)(v8 + 383) = 0;
v9 = *(_QWORD *)(v8 + 320);
if ( v9 )
{
BYTE6(v11[0]) = -1;
WORD2(v11[0]) = -1;
(*(void (__fastcall **)(__int64, char *))(*(_QWORD *)v9 + 960LL))(v9, (char *)v11 + 4);
}
result = *(unsigned __int8 *)(v8 + 381) ^ 1u;
v10 = *(_QWORD *)(v8 + 8 * result + 320);
if ( v10 )
{
BYTE2(v11[0]) = -1;
LOWORD(v11[0]) = -1;
result = (*(__int64 (__fastcall **)(__int64, _QWORD *))(*(_QWORD *)v10 + 960LL))(v10, v11);
}
++v6;
}
while ( (unsigned __int64)v6 <= v7 );
}
}
return result;
}