//
// GameLevelManager::onReportLevelCompleted from 0x6ff974 to 0x6ffb70 (508 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732e34
// > ??> @ 0x6dc68
//
// 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::onReportLevelCompleted(GameLevelManager *a1, const void **a2, const char **a3)
{
int v5; // w25
_DWORD *v6; // x26
unsigned __int64 v7; // x27
unsigned __int64 v8; // x20
size_t v9; // x2
int v10; // w19
__int64 v11; // x20
__int64 *v12; // x0
cocos2d::CCDictionary *m_reportedLevels; // x19
char *ReportKey; // x0
char *v16; // x19
unsigned int *v17; // x26
int v18; // w0
unsigned int *v19; // x26
int v20; // w1
void *v21; // [xsp+70h] [xbp+70h] BYREF
v5 = atoi(*a3);
sub_D153B8((int)&v21, "-1");
v6 = v21;
v7 = *((_QWORD *)v21 - 3);
v8 = *((_QWORD *)*a2 - 3);
if ( v7 > v8 )
v9 = *((_QWORD *)*a2 - 3);
else
v9 = *((_QWORD *)v21 - 3);
v10 = memcmp(*a2, v21, v9);
if ( v10 || (v10 = 0x7FFFFFFF, v11 = v8 - v7, v11 > 0x7FFFFFFF) )
{
v12 = (__int64 *)(v6 - 6);
if ( v6 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v12 = (__int64 *)(v6 - 6);
if ( v11 >= (__int64)0xFFFFFFFF80000000LL )
v10 = v11;
else
v10 = 0x80000000;
if ( v12 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v19 = v6 - 2;
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(v6 - 2);
*(v6 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v12);
LABEL_7:
if ( !v10 )
{
m_reportedLevels = a1->m_reportedLevels;
ReportKey = (char *)GameLevelManager::getReportKey(a1, v5);
sub_D153B8((int)&v21, ReportKey);
cocos2d::CCDictionary::removeObjectForKey(m_reportedLevels, (const std::string *)&v21);
v16 = (char *)v21 - 24;
if ( (char *)v21 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)((char *)v21 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v21 - 2);
*((_DWORD *)v21 - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v16);
}
}
return _stack_chk_guard;
}