//
// GJLevelList::parseListLevels from 0x72ecdc to 0x72efc0 (740 bytes)
//
// 4 xrefs:
// > GameLevelManager::updateSavedLevelList @ 0x72f074
// > GJLevelList::create @ 0x72f580
// > GJLevelList::dataLoaded @ 0x7308bc
// > ??> @ 0x46668
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall GJLevelList::parseListLevels(__int64 a1, _QWORD *a2)
{
unsigned __int64 v5; // x19
__int64 v6; // x23
__int64 v7; // x20
__int64 v8; // x3
__int64 v9; // x26
int v10; // w0
int *v11; // x1
char *v12; // x0
unsigned int *v13; // x1
int v14; // w2
char *v15; // x0
char *v16; // x0
unsigned int *v17; // x19
int v18; // w1
unsigned int *v19; // x1
int v20; // w2
int v21; // [xsp+70h] [xbp+70h] BYREF
void *v22; // [xsp+78h] [xbp+78h] BYREF
const char *v23; // [xsp+80h] [xbp+80h] BYREF
sub_D18EA8(a1 + 424, a2);
*(_QWORD *)(a1 + 328) = *(_QWORD *)(a1 + 320);
if ( !*(_QWORD *)(*a2 - 24LL) )
return _stack_chk_guard;
v5 = 0;
sub_D153B8((int)&v22, &byte_F804F8);
v6 = a1 + 320;
v7 = sub_D168E0((int)a2, v22, 0, *((_QWORD *)v22 - 3));
v8 = v7;
v9 = *(_QWORD *)(*a2 - 24LL);
while ( 1 )
{
sub_D14F84(&v23, a2, v5, v8);
if ( v5 == v9 && !*((_QWORD *)v23 - 3) )
goto LABEL_11;
v10 = atoi(v23);
v21 = v10;
v11 = *(int **)(v6 + 8);
if ( v11 == *(int **)(v6 + 16) )
break;
if ( v11 )
*v11 = v10;
*(_QWORD *)(v6 + 8) = v11 + 1;
LABEL_11:
if ( v7 == -1 )
goto LABEL_19;
LABEL_12:
v5 = v7 + 1;
v7 = sub_D168E0((int)a2, v22, (int)v7 + 1, *((_QWORD *)v22 - 3));
v12 = (char *)(v23 - 24);
if ( v23 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v23 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v23 - 2);
*((_DWORD *)v23 - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v12);
}
v8 = v7 - v5;
if ( v5 > *(_QWORD *)(*a2 - 24LL) )
sub_D13C5C(
"%s: __pos (which is %zu) > this->size() (which is %zu)",
"basic_string::substr",
v5,
*(_QWORD *)(*a2 - 24LL));
}
std::vector::_M_emplace_back_aux(v6, &v21);
if ( v7 != -1 )
goto LABEL_12;
LABEL_19:
v15 = (char *)(v23 - 24);
if ( v23 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v23 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v23 - 2);
*((_DWORD *)v23 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v15);
}
v16 = (char *)v22 - 24;
if ( (char *)v22 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)((char *)v22 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v22 - 2);
*((_DWORD *)v22 - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v16);
}
return _stack_chk_guard;
}