//
// PlatformerControlsPopup::ensureCustomDraft from 0xcfa278 to 0xcfa4d8 (608 bytes)
//
// 4 xrefs:
// > PlatformerControlsPopup::onKeyboard @ 0xcfa518
// > PlatformerControlsPopup::onController @ 0xcfa564
// > PlatformerControlsPopup::onTouch @ 0xcfa5d4
// > ??> @ 0xf9eb0
//
// 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 13:06:50 +0000
//
__int64 __fastcall PlatformerControlsPopup::ensureCustomDraft(PlatformerControlsPopup *this)
{
int v2; // w21
LevelControlConfig *v3; // x0
int v4; // w3
size_t v5; // x2
unsigned __int8 v6; // w0
char *v7; // x22
int v8; // w4
__int64 v9; // x1
char *v11; // x0
__int64 v12; // x2
cocos2d::CCObject *v13; // x0
char *v14; // x0
char *v15; // x19
int v16; // w21
__int64 v17; // x2
size_t v18; // x2
size_t v19; // x1
LevelControlConfig *v20; // x0
unsigned __int8 *v21; // x0
unsigned __int8 *v22; // x1
unsigned __int8 *v23; // x3
unsigned __int8 *v24; // x2
int v25; // t1
cocos2d::CCObject *v26; // x0
unsigned __int64 v27; // x0
unsigned __int64 v28; // x0
unsigned __int8 v29; // w2
__int64 v30; // [xsp+40h] [xbp+40h] BYREF
size_t v31; // [xsp+48h] [xbp+48h]
void *v32; // [xsp+50h] [xbp+50h]
v2 = *((unsigned __int8 *)this + 1096);
v3 = *((LevelControlConfig **)this + 133);
if ( v2 )
{
*((_BYTE *)this + 1096) = 0;
if ( !v3 )
{
LABEL_12:
v7 = (char *)this + 1072;
goto LABEL_13;
}
LevelControlConfig::encodeB64(&v30, v3);
v4 = v30 & 1;
v5 = (unsigned __int8)v30 >> 1;
if ( v4 )
v5 = v31;
v6 = *((_BYTE *)this + 1072);
v7 = (char *)this + 1072;
v8 = v6 & 1;
v9 = v6 >> 1;
if ( (v6 & 1) != 0 )
v9 = *((_QWORD *)this + 135);
if ( v5 == v9 )
{
v21 = (unsigned __int8 *)&v30 + 1;
if ( v4 )
v21 = (unsigned __int8 *)v32;
v22 = (unsigned __int8 *)this + 1073;
if ( v8 )
v22 = *((unsigned __int8 **)this + 136);
if ( !v4 )
{
if ( v5 )
{
if ( *v21 != *v22 )
goto LABEL_9;
v23 = v21 + 1;
v24 = &v21[v5];
while ( 1 )
{
++v22;
if ( v23 == v24 )
break;
v25 = *v23++;
if ( *v22 != v25 )
goto LABEL_9;
}
}
LABEL_37:
if ( v2 )
{
v26 = *((cocos2d::CCObject **)this + 133);
if ( v26 )
{
cocos2d::CCObject::release(v26);
*((_QWORD *)this + 133) = 0;
}
LABEL_13:
v11 = (char *)(*((_QWORD *)this + 131) + 1816LL);
v12 = (unsigned __int8)*v11 >> 1;
if ( (*v11 & 1) != 0 )
v12 = *(_QWORD *)(*((_QWORD *)this + 131) + 1824LL);
if ( v12 )
{
v13 = (cocos2d::CCObject *)LevelControlConfig::createFromB64(v11);
*((_QWORD *)this + 133) = v13;
}
else
{
v20 = (LevelControlConfig *)LevelControlConfig::create((LevelControlConfig *)v11);
*((_QWORD *)this + 133) = v20;
LevelControlConfig::seedBase(v20);
v13 = *((cocos2d::CCObject **)this + 133);
}
cocos2d::CCObject::retain(v13);
LevelControlConfig::encodeB64(&v30, *((LevelControlConfig **)this + 133));
if ( (*((_BYTE *)this + 1072) & 1) == 0 )
goto LABEL_25;
**((_BYTE **)v7 + 2) = 0;
*((_QWORD *)v7 + 1) = 0;
if ( (*((_BYTE *)this + 1072) & 1) != 0 )
{
v14 = (char *)this + 1073;
v15 = *((char **)v7 + 2);
v16 = 1;
}
else
{
v27 = *((_BYTE *)this + 1072) >> 1;
if ( v27 <= 0x16 || (v28 = (v27 + 16) & 0xFFFFFFFFFFFFFFF0LL, v28 == 23) )
{
LABEL_25:
*((_QWORD *)v7 + 2) = v32;
v19 = v31;
*(_QWORD *)v7 = v30;
*((_QWORD *)v7 + 1) = v19;
return _stack_chk_guard;
}
v14 = (char *)operator new(v28);
v29 = *((_BYTE *)this + 1072);
v16 = v29 & 1;
if ( (v29 & 1) == 0 )
{
v15 = (char *)this + 1073;
v17 = v29 >> 1;
goto LABEL_21;
}
v15 = *((char **)v7 + 2);
}
v17 = *((_QWORD *)v7 + 1);
LABEL_21:
v18 = v17 + 1;
if ( v18 )
memcpy(v14, v15, v18);
if ( v16 )
operator delete(v15);
goto LABEL_25;
}
goto LABEL_9;
}
if ( v5 )
v2 = memcmp(v21, v22, v5) == 0;
}
else
{
if ( !v4 )
{
LABEL_9:
v3 = *((LevelControlConfig **)this + 133);
goto LABEL_10;
}
v2 = 0;
}
operator delete(v32);
goto LABEL_37;
}
LABEL_10:
if ( !v3 )
goto LABEL_12;
return _stack_chk_guard;
}