//
// LevelSearchLayer::toggleDifficulty from 0x7df728 to 0x7dfa0c (740 bytes)
//
// 3 xrefs:
// > ??> @ 0xdd998
// > LevelSearchLayer::init @ 0x7e37bc
// > ??> @ 0x1546a50
//
// 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:54:25 +0000
//
__int64 __fastcall LevelSearchLayer::toggleDifficulty(cocos2d::CCArray **this, cocos2d::CCObject *a2)
{
unsigned int v3; // w21
unsigned int v4; // w25
int v5; // w24
__int64 v6; // x26
cocos2d::CCObject *v7; // x20
size_t v8; // x0
__int64 v9; // x0
char v10; // w2
void (__fastcall *v11)(__int64, _BYTE *); // x3
int j; // w20
unsigned int v13; // w1
GameLevelManager *v14; // x0
GameLevelManager *v15; // x0
__int64 v16; // x20
const char *v17; // x0
size_t v18; // x0
cocos2d::CCString *v19; // x0
unsigned int v20; // w20
unsigned int k; // w20
unsigned int v23; // w1
unsigned int m; // w20
unsigned int v25; // w1
unsigned int i; // w20
char *DiffKey; // [xsp+58h] [xbp+58h]
char *v28; // [xsp+58h] [xbp+58h]
_BYTE v29[8]; // [xsp+68h] [xbp+68h] BYREF
__int64 v30; // [xsp+70h] [xbp+70h] BYREF
__int64 v31; // [xsp+78h] [xbp+78h]
void *v32; // [xsp+80h] [xbp+80h]
v3 = (*(__int64 (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)a2 + 64LL))(a2);
v4 = (unsigned __int8)LevelSearchLayer::checkDiff((LevelSearchLayer *)this, (const char *)v3);
if ( *((_DWORD *)this + 108) == 1 )
{
for ( i = 0; i != 8; ++i )
{
if ( i != v3 )
LevelSearchLayer::toggleDifficultyNum((LevelSearchLayer *)this, i, 0);
}
}
v5 = v4 ^ 1;
v6 = (__int64)*(this + 60);
v7 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)(v4 ^ 1));
v30 = 0;
DiffKey = (char *)LevelSearchLayer::getDiffKey((LevelSearchLayer *)this, (const char *)v3);
v31 = 0;
v32 = nullptr;
v8 = strlen(DiffKey);
std::string::__init(&v30, DiffKey, v8);
cocos2d::CCDictionary::setObject(v6, v7);
if ( (v30 & 1) != 0 )
operator delete(v32);
v9 = cocos2d::CCArray::objectAtIndex(*(this + 58), v3);
v10 = -1;
if ( !v5 )
v10 = 125;
v11 = *(void (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)v9 + 960LL);
v29[0] = v10;
v29[1] = v10;
v29[2] = v10;
v11(v9, v29);
if ( (v3 == 0) > v4 )
{
for ( j = 1; j != 8; ++j )
{
v13 = j;
v14 = (GameLevelManager *)LevelSearchLayer::toggleDifficultyNum((LevelSearchLayer *)this, v13, 0);
}
goto LABEL_9;
}
if ( (v3 == 6) > v4 )
{
for ( k = 0; k != 6; ++k )
{
v23 = k;
LevelSearchLayer::toggleDifficultyNum((LevelSearchLayer *)this, v23, 0);
}
goto LABEL_15;
}
if ( (v3 == 7) <= v4 )
{
LevelSearchLayer::toggleDifficultyNum((LevelSearchLayer *)this, 0, 0);
LevelSearchLayer::toggleDifficultyNum((LevelSearchLayer *)this, 6u, 0);
LABEL_15:
v14 = (GameLevelManager *)LevelSearchLayer::toggleDifficultyNum((LevelSearchLayer *)this, 7u, 0);
goto LABEL_9;
}
for ( m = 0; m != 7; ++m )
{
v25 = m;
v14 = (GameLevelManager *)LevelSearchLayer::toggleDifficultyNum((LevelSearchLayer *)this, v25, 0);
}
LABEL_9:
v15 = (GameLevelManager *)GameLevelManager::sharedState(v14);
GameLevelManager::setDiffVal(v15, v3, v5);
v16 = (__int64)*(this + 60);
v17 = (const char *)LevelSearchLayer::getDiffKey((LevelSearchLayer *)this, &byte_6);
v30 = 0;
v28 = (char *)v17;
v31 = 0;
v32 = nullptr;
v18 = strlen(v17);
std::string::__init(&v30, v28, v18);
v19 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v16, &v30);
v20 = cocos2d::CCString::boolValue(v19);
if ( (v30 & 1) != 0 )
operator delete(v32);
(*(void (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)*(this + 62) + 1056LL))(*(this + 62), v20);
(*(void (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)*(this + 62) + 344LL))(*(this + 62), v20);
return _stack_chk_guard;
}