//
// EditLevelLayer::verifyLevelName from 0x6e2550 to 0x6e2948 (1016 bytes)
//
// 5 xrefs:
// > EditLevelLayer::onPlay @ 0x6e2a28
// > EditLevelLayer::onEdit @ 0x6e2b80
// > EditLevelLayer::onBack @ 0x6e2cdc
// > EditLevelLayer::onClone @ 0x6e2ec0
// > ??> @ 0x3f0f0
//
// 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
//
void EditLevelLayer::verifyLevelName(EditLevelLayer *a1)
{
char *v2; // x0
__int64 v3; // x20
char *v4; // x0
__int64 v5; // x20
GJGameLevel *m_level; // x20
_DWORD *v7; // x1
char *v8; // x0
_DWORD *v9; // x24
stl::StringData::Internal *m_data; // x2
__int64 *v11; // x27
unsigned __int64 v12; // x26
stl::StringData::Internal *v13; // x1
unsigned __int64 v14; // x25
size_t v15; // x2
signed __int64 v16; // x20
unsigned int v17; // w0
LocalLevelManager *v18; // x20
cocos2d::CCArray *AllLevelsWithName; // x21
char *v20; // x0
unsigned int v21; // w19
int v22; // w20
unsigned int v23; // w1
int v24; // w0
GJGameLevel *v25; // x20
unsigned int *v26; // x1
int v27; // w2
unsigned int *v28; // x1
int v29; // w2
unsigned int *v30; // x24
int v31; // w0
unsigned int *v32; // x1
int v33; // w2
unsigned int *v34; // x20
int v35; // w1
unsigned int *v36; // x1
void *v37; // [xsp+70h] [xbp+70h] BYREF
sub_D18D28(&v37, &a1->m_level->m_levelName);
v2 = (char *)v37 - 24;
v3 = *((_QWORD *)v37 - 3);
if ( (char *)v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v28 = (unsigned int *)((char *)v37 - 8);
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v29 - 1;
}
if ( v29 <= 0 )
operator delete(v2);
}
if ( !v3 )
{
sub_D18D28(&v37, &a1->m_level->m_tempName);
v4 = (char *)v37 - 24;
v5 = *((_QWORD *)v37 - 3);
if ( (char *)v37 - 24 == (char *)&qword_124B6B0 )
goto LABEL_4;
if ( &pthread_create )
{
v32 = (unsigned int *)((char *)v37 - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v33 - 1;
}
if ( v33 > 0 )
{
LABEL_4:
if ( v5 )
goto LABEL_5;
}
else
{
operator delete(v4);
if ( v5 )
{
LABEL_5:
m_level = a1->m_level;
sub_D18D28(&v37, &m_level->m_tempName);
sub_D18EA8(&m_level->m_levelName, &v37);
v7 = v37;
v8 = (char *)v37 - 24;
if ( (char *)v37 - 24 == (char *)&qword_124B6B0 )
goto LABEL_6;
if ( &pthread_create )
{
v36 = (unsigned int *)((char *)v37 - 8);
do
v27 = __ldaxr(v36);
while ( __stlxr(v27 - 1, v36) );
goto LABEL_29;
}
goto LABEL_60;
}
}
v25 = a1->m_level;
sub_D153B8((int)&v37, "Unknown");
sub_D18EA8(&v25->m_levelName, &v37);
v7 = v37;
v8 = (char *)v37 - 24;
if ( (char *)v37 - 24 == (char *)&qword_124B6B0 )
goto LABEL_6;
if ( &pthread_create )
{
v26 = (unsigned int *)((char *)v37 - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
LABEL_29:
if ( v27 <= 0 )
operator delete(v8);
goto LABEL_6;
}
LABEL_60:
v27 = *(v7 - 2);
*(v7 - 2) = v27 - 1;
goto LABEL_29;
}
LABEL_6:
sub_D18D28(&v37, &a1->m_level->m_levelName);
v9 = v37;
m_data = a1->m_levelName.m_data.m_data;
v11 = (__int64 *)((char *)v37 - 24);
v12 = *((_QWORD *)v37 - 3);
v13 = m_data;
v14 = *((_QWORD *)m_data - 3);
if ( v14 > v12 )
v15 = *((_QWORD *)v37 - 3);
else
v15 = *((_QWORD *)m_data - 3);
LODWORD(v16) = memcmp(v37, v13, v15);
if ( !(_DWORD)v16 )
{
v16 = v12 - v14;
v17 = 0x7FFFFFFF;
if ( (__int64)(v12 - v14) <= 0x7FFFFFFF )
{
v17 = 0x80000000;
if ( v16 >= (__int64)0xFFFFFFFF80000000LL )
{
if ( v11 == &qword_124B6B0 )
{
LABEL_23:
if ( !(_DWORD)v16 )
return;
goto LABEL_13;
}
LABEL_36:
if ( &pthread_create )
{
v30 = v9 - 2;
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *(v9 - 2);
*(v9 - 2) = v31 - 1;
}
if ( v31 <= 0 )
{
operator delete(v11);
if ( !(_DWORD)v16 )
return;
goto LABEL_13;
}
goto LABEL_23;
}
}
LODWORD(v16) = v17;
}
if ( v11 != &qword_124B6B0 )
goto LABEL_36;
LABEL_13:
a1->m_level->m_levelRev = 0;
v18 = LocalLevelManager::sharedState();
sub_D18D28(&v37, &a1->m_level->m_levelName);
AllLevelsWithName = (cocos2d::CCArray *)LocalLevelManager::getAllLevelsWithName(v18, (std::string)&v37);
v20 = (char *)v37 - 24;
if ( (char *)v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v34 = (unsigned int *)((char *)v37 - 8);
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
}
else
{
v35 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v35 - 1;
}
if ( v35 <= 0 )
operator delete(v20);
}
if ( (unsigned int)cocos2d::CCArray::count(AllLevelsWithName) > 1 )
{
v21 = 0;
v22 = 0;
while ( v21 < (unsigned int)cocos2d::CCArray::count(AllLevelsWithName) )
{
v23 = v21++;
v24 = *(_DWORD *)(cocos2d::CCArray::objectAtIndex(AllLevelsWithName, v23) + 460);
if ( v22 < v24 )
v22 = v24;
}
a1->m_level->m_levelRev = v22 + 1;
}
}