//
// GameLevelManager::getLocalLevelByName from 0x6f0684 to 0x6f0818 (404 bytes)
//
// 2 xrefs:
// > MapSelectLayer::init @ 0x9808e8
// > ??> @ 0x5a900
//
// 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 GameLevelManager::getLocalLevelByName(__int64 a1, const void **a2)
{
unsigned int v3; // w20
cocos2d::CCArray *m_localLevels; // x21
__int64 v5; // x28
_QWORD *v6; // x27
__int64 *v7; // x26
unsigned __int64 v8; // x23
unsigned __int64 v9; // x25
size_t v10; // x2
signed __int64 v11; // x19
unsigned int *v13; // x3
int v14; // w0
_QWORD *v15; // [xsp+80h] [xbp+80h] BYREF
v3 = 0;
m_localLevels = LocalLevelManager::sharedState()->m_localLevels;
if ( !(unsigned int)cocos2d::CCArray::count(m_localLevels) )
return 0;
while ( 1 )
{
v5 = cocos2d::CCArray::objectAtIndex(m_localLevels, v3);
sub_D18D28(&v15, v5 + 344);
v6 = v15;
v7 = v15 - 3;
v8 = *(v15 - 3);
v9 = *((_QWORD *)*a2 - 3);
if ( v9 > v8 )
v10 = *(v15 - 3);
else
v10 = *((_QWORD *)*a2 - 3);
LODWORD(v11) = memcmp(v15, *a2, v10);
if ( (_DWORD)v11 )
goto LABEL_9;
v11 = v8 - v9;
if ( (__int64)(v8 - v9) > 0x7FFFFFFF )
{
LODWORD(v11) = 0x7FFFFFFF;
LABEL_9:
if ( v7 == &qword_124B6B0 )
goto LABEL_10;
goto LABEL_13;
}
if ( v11 < (__int64)0xFFFFFFFF80000000LL )
{
LODWORD(v11) = 0x80000000;
goto LABEL_9;
}
if ( v7 == &qword_124B6B0 )
goto LABEL_17;
LABEL_13:
if ( &pthread_create )
{
v13 = (unsigned int *)(v6 - 1);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v6 - 2);
*((_DWORD *)v6 - 2) = v14 - 1;
}
if ( v14 <= 0 )
break;
LABEL_17:
if ( !(_DWORD)v11 )
return v5;
LABEL_10:
if ( ++v3 >= (unsigned int)cocos2d::CCArray::count(m_localLevels) )
return 0;
}
operator delete(v7);
if ( (_DWORD)v11 )
goto LABEL_10;
return v5;
}