//
// GJKeybindManager::applyMovementOverride from 0xc0d520 to 0xc0dbe4 (1732 bytes)
//
// 2 xrefs:
// > UILayer::applyLevelBindings @ 0x6ee8c8
// > ??> @ 0xa1908
//
// 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 13:03:55 +0000
//
__int64 __fastcall GJKeybindManager::applyMovementOverride(__int64 **this, KeybindSource *a2, KeybindSource *a3)
{
_DWORD *v5; // x26
_QWORD *v6; // x22
int *v7; // x19
int *v8; // x27
_QWORD **v9; // x27
_QWORD *v10; // x2
void **v11; // x19
int *v12; // x28
__int64 v13; // x0
_QWORD *v14; // x19
_QWORD *i; // x27
unsigned int v16; // w22
int *v17; // x19
int *v18; // x27
int *v19; // x0
int v20; // w22
int *v21; // x20
int *v22; // x19
int *v23; // x22
int v24; // w2
__int64 *v25; // x0
int v26; // w1
__int64 v27; // x0
int *v28; // x19
void *v29; // x19
_QWORD **v31; // x19
__int64 v33; // [xsp+90h] [xbp+90h]
__int64 **v34; // [xsp+98h] [xbp+98h]
int v35; // [xsp+A0h] [xbp+A0h]
__int64 v36; // [xsp+A8h] [xbp+A8h]
int *v38; // [xsp+B0h] [xbp+B0h]
int v39; // [xsp+C8h] [xbp+C8h] BYREF
int *v40; // [xsp+D0h] [xbp+D0h] BYREF
int *v41; // [xsp+D8h] [xbp+D8h] BYREF
_QWORD v42[2]; // [xsp+E0h] [xbp+E0h]
int **v43; // [xsp+F0h] [xbp+F0h] BYREF
_QWORD v44[2]; // [xsp+F8h] [xbp+F8h] BYREF
void *v45; // [xsp+108h] [xbp+108h] BYREF
int *v46; // [xsp+110h] [xbp+110h]
unsigned __int64 v47; // [xsp+118h] [xbp+118h]
void *v48; // [xsp+120h] [xbp+120h] BYREF
void *v49; // [xsp+128h] [xbp+128h] BYREF
void *v50; // [xsp+130h] [xbp+130h]
GJKeybindManager::clearMovementOverride((GJKeybindManager *)this);
if ( !(unsigned __int8)sub_C08614((__int64)a2) && !(unsigned __int8)sub_C08614((__int64)a3) )
return _stack_chk_guard;
v5 = &unk_119B410;
v34 = this + 17;
do
{
LODWORD(v41) = *v5;
GJKeybindManager::chordsForAction((GJKeybindManager *)this, (int)v41, &v45);
v43 = &v41;
v6 = (_QWORD *)std::__tree>,std::__map_value_compare>,std::less,true>,std::allocator>>>::__emplace_unique_key_args,std::tuple<>>(
v34,
(int *)&v41,
(__int64)&unk_119B468,
(int **)&v43);
v7 = (int *)v45;
v8 = v46;
v49 = nullptr;
v50 = nullptr;
v48 = &v49;
if ( v45 != v46 )
{
do
{
std::__tree::__emplace_hint_unique_key_args((__int64 ***)&v48, (__int64 **)&v49, v7, v7);
++v7;
}
while ( v8 != v7 );
}
v9 = (_QWORD **)v6[6];
v10 = v6 + 6;
v11 = (void **)(v6 + 5);
if ( v9 )
{
v11 = (void **)(v6 + 5);
std::__tree::destroy((__int64)(v6 + 5), *v9);
std::__tree::destroy((__int64)(v6 + 5), v9[1]);
operator delete(v9);
v10 = v6 + 6;
}
*v11 = v48;
v6[6] = v49;
v11[2] = v50;
if ( v6[7] )
{
*(_QWORD *)(v6[6] + 16LL) = v10;
}
else
{
v6[5] = v10;
v31 = (_QWORD **)v49;
if ( v49 )
{
std::__tree::destroy((__int64)&v48, *(_QWORD **)v49);
std::__tree::destroy((__int64)&v48, v31[1]);
operator delete(v31);
}
}
if ( v45 )
{
if ( v45 != v46 )
v46 += ~((unsigned __int64)((char *)(v46 - 1) - (_BYTE *)v45) >> 2);
operator delete(v45);
}
++v5;
}
while ( v5 != (_DWORD *)&unk_119B428 );
v43 = (int **)v44;
v42[0] = a2;
v44[0] = 0;
v44[1] = 0;
v35 = 0;
v36 = 0;
v45 = nullptr;
v46 = nullptr;
v47 = 0;
v42[1] = a3;
do
{
v33 = v42[v36];
if ( (unsigned __int8)sub_C08614(v33) )
{
v12 = (int *)&unk_119B410;
do
{
v39 = *v12;
v40 = &v39;
v13 = std::__tree>,std::__map_value_compare>,std::less,true>,std::allocator>>>::__emplace_unique_key_args,std::tuple<>>(
v34,
&v39,
(__int64)&unk_119B468,
&v40);
v14 = *(_QWORD **)(v13 + 40);
for ( i = (_QWORD *)(v13 + 48); i != v14; v14 = std::__tree_next *>(v14) )
{
while ( 1 )
{
v16 = *((_DWORD *)v14 + 7);
if ( v35 == GJKeybindManager::isControllerChord((GJKeybindManager *)v16) )
break;
v14 = std::__tree_next *>(v14);
if ( i == v14 )
goto LABEL_22;
}
GJKeybindManager::unbindChord((GJKeybindManager *)this, v16, v39);
}
LABEL_22:
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v33 + 16LL))(v33, (unsigned int)v39);
v17 = (int *)v48;
v18 = (int *)v49;
if ( v48 != v49 )
{
do
{
while ( 1 )
{
v20 = *v17;
GJKeybindManager::bindChord((GJKeybindManager *)this, *v17, v39);
std::__tree::__emplace_unique_key_args((__int64 **)&v43, &v39, &v39);
v19 = v46;
v41 = (int *)__PAIR64__(v20, v39);
if ( (unsigned __int64)v46 < v47 )
break;
std::vector>::__push_back_slow_path>(&v45, &v41);
if ( v18 == ++v17 )
goto LABEL_29;
}
if ( v46 )
{
*(_QWORD *)v46 = v41;
v19 = v46;
}
++v17;
v46 = v19 + 2;
}
while ( v18 != v17 );
LABEL_29:
v18 = (int *)v48;
}
if ( v18 )
{
if ( v49 != v18 )
v49 = (char *)v49 + 4 * ~((unsigned __int64)((char *)v49 - 4 - (char *)v18) >> 2);
operator delete(v18);
}
++v12;
}
while ( v12 != (int *)&unk_119B428 );
}
++v36;
v35 ^= 1u;
}
while ( v36 != 2 );
v38 = v46;
if ( v45 != v46 )
{
v21 = (int *)((char *)v45 + 4);
do
{
GJKeybindManager::actionsForChord((__int64 *)&v48, (GJKeybindManager *)this, *v21);
v22 = (int *)v48;
v23 = (int *)v49;
if ( v48 != v49 )
{
do
{
v24 = *v22;
v25 = (__int64 *)v44[0];
LODWORD(v40) = *v22;
while ( v25 )
{
while ( 1 )
{
v26 = *((_DWORD *)v25 + 7);
if ( v24 >= v26 )
break;
v25 = (__int64 *)*v25;
if ( !v25 )
goto LABEL_43;
}
if ( v24 <= v26 )
goto LABEL_44;
v25 = (__int64 *)v25[1];
}
LABEL_43:
GJKeybindManager::unbindChord((GJKeybindManager *)this, *v21, v24);
v41 = v21;
v27 = std::__tree>,std::__map_value_compare>,std::less,true>,std::allocator>>>::__emplace_unique_key_args,std::tuple<>>(
this + 20,
v21,
(__int64)&unk_119B468,
&v41);
std::__tree::__emplace_unique_key_args((__int64 **)(v27 + 40), (int *)&v40, &v40);
LABEL_44:
++v22;
}
while ( v23 != v22 );
v23 = (int *)v48;
}
if ( v23 )
{
if ( v49 != v23 )
v49 = (char *)v49 + 4 * ~((unsigned __int64)((char *)v49 - 4 - (char *)v23) >> 2);
operator delete(v23);
}
v28 = v21 + 1;
v21 += 2;
}
while ( v38 != v28 );
v38 = (int *)v45;
}
*((_BYTE *)this + 184) = 1;
if ( v38 )
{
if ( v46 != v38 )
v46 += 2 * ~((unsigned __int64)((char *)(v46 - 2) - (char *)v38) >> 3);
operator delete(v38);
}
v29 = (void *)v44[0];
if ( !v44[0] )
return _stack_chk_guard;
std::__tree::destroy((__int64)&v43, *(_QWORD **)v44[0]);
std::__tree::destroy((__int64)&v43, *(_QWORD **)&byte_8[(_QWORD)v29]);
operator delete(v29);
return _stack_chk_guard;
}