//
// LevelSearchLayer::toggleDifficultyNum from 0x1403122d0 to 0x140312450 (384 bytes)
//
// 10 xrefs:
// > LevelSearchLayer::init @ 0x14030dd4c
// > LevelSearchLayer::clearFilters @ 0x14030e8b9
// > LevelSearchLayer::toggleDifficulty @ 0x140311fd0
// > LevelSearchLayer::toggleDifficulty @ 0x1403120f8
// > LevelSearchLayer::toggleDifficulty @ 0x140312128
// > LevelSearchLayer::toggleDifficulty @ 0x140312158
// > LevelSearchLayer::toggleDifficulty @ 0x14031216e
// > LevelSearchLayer::toggleDifficulty @ 0x14031217d
// > LevelSearchLayer::toggleDifficulty @ 0x14031218c
// > ??> @ 0x1406d485c
//
// 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
//
// Hidden C++ exception states: #wind=2
void LevelSearchLayer::toggleDifficultyNum(LevelSearchLayer *a1, int a2, bool a3)
{
BOOL v3; // ebx
cocos2d::CCString *v6; // rax
const char *CString; // rax
size_t v8; // r8
struct cocos2d::CCString *v9; // rax
void *v10; // rcx
char *p_m_unknown2; // rcx
__int16 *v12; // rdx
GameLevelManager *v13; // rcx
__int16 v14; // [rsp+20h] [rbp-58h] BYREF
char v15; // [rsp+22h] [rbp-56h]
_WORD v16[2]; // [rsp+24h] [rbp-54h] BYREF
void *v17; // [rsp+28h] [rbp-50h]
void *Block[2]; // [rsp+30h] [rbp-48h] BYREF
__int64 v19; // [rsp+40h] [rbp-38h]
unsigned __int64 v20; // [rsp+48h] [rbp-30h]
v3 = a3;
v6 = cocos2d::CCString::createWithFormat("D%i", a2);
CString = cocos2d::CCString::getCString(v6);
*(_OWORD *)Block = 0;
v19 = 0;
v20 = 0;
v8 = -1;
do
++v8;
while ( CString[v8] );
sub_14003A930(Block, CString, v8);
v9 = cocos2d::CCString::createWithFormat("%i", v3);
cocos2d::CCDictionary::setObject(a1->m_difficultyDict, v9, Block);
if ( v20 > 0xF )
{
v10 = Block[0];
if ( v20 + 1 >= 0x1000 )
{
v10 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v10 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v10);
}
p_m_unknown2 = (char *)&cocos2d::CCArray::objectAtIndex(a1->m_difficultySprites, a2)[5].m_unknown2;
if ( v3 )
{
v14 = -1;
v15 = -1;
v12 = &v14;
}
else
{
v14 = 32125;
memset(v16, 125, 3);
v12 = v16;
}
(**(void (__fastcall ***)(char *, __int16 *))p_m_unknown2)(p_m_unknown2, v12);
v13 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v17 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v17);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v13 = (GameLevelManager *)qword_1406C2EC0;
}
GameLevelManager::setDiffVal(v13, a2, v3);
}