//
// GJLevelList::reorderLevel from 0x8579e4 to 0x857b08 (292 bytes)
//
// 3 xrefs:
// > GJLevelList::reorderLevelStep @ 0x857b4c
// > LevelListLayer::setIDPopupClosed @ 0xba97cc
// > ??> @ 0x5bdb0
//
// 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 12:55:30 +0000
//
__int64 __fastcall GJLevelList::reorderLevel(GJLevelList *this, int a2, int a3)
{
unsigned __int64 v4; // x22
char *v5; // x5
char *v6; // x2
char *v7; // x0
int v8; // t1
char *v9; // x4
__int64 v11; // x21
char *v12; // x4
__int64 v13; // x1
unsigned __int64 v14; // x2
int v15; // [xsp+34h] [xbp+34h] BYREF
v4 = a3;
v5 = *((char **)this + 40);
v6 = *((char **)this + 41);
if ( v5 != v6 )
{
if ( *(_DWORD *)v5 == a2 )
{
v9 = *((char **)this + 40);
LABEL_8:
v15 = a2;
v11 = v6 - (v9 + 4);
if ( v11 >> 2 )
{
v9 = (char *)memmove(v9, v9 + 4, v6 - (v9 + 4));
v5 = *((char **)this + 40);
v6 = *((char **)this + 41);
}
v12 = &v9[v11];
if ( v12 != v6 )
{
v6 += 4 * ~((unsigned __int64)(v6 - 4 - v12) >> 2);
*((_QWORD *)this + 41) = v6;
}
if ( (v4 & 0x80000000) != 0 )
{
v13 = 0;
}
else
{
v13 = 4 * v4;
v14 = (v6 - v5) >> 2;
if ( v4 > v14 )
v13 = 4LL * (int)v14;
}
std::vector::insert((_QWORD *)this + 40, &v5[v13], (char *)&v15);
}
else
{
v7 = v5 + 4;
while ( 1 )
{
v9 = v7;
if ( v6 == v7 )
break;
v8 = *(_DWORD *)v7;
v7 += 4;
if ( v8 == a2 )
goto LABEL_8;
}
}
}
GJLevelList::updateLevelsString(this);
return _stack_chk_guard;
}