//
// DemonFilterSelectLayer::init from 0x10070c140 to 0x10070c5da (1178 bytes)
//
// 2 xrefs:
// > sub_100708450 @ 0x1007085f4
// > ??> @ 0x100b98810
//
// This function is hookable on this platform (idp: pc, 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:36:03 +0000
//
__int64 __fastcall DemonFilterSelectLayer::init(__int64 a1)
{
__int64 result; // rax
__int64 v3; // rax
void *v4; // r14
void *v5; // r14
__int64 v6; // rdi
__int64 v7; // rax
__int64 v8; // rdi
__int64 v9; // rdx
__int64 v10; // rcx
__int64 v11; // rax
__int64 v12; // rax
void *v13; // r15
int v14; // r13d
unsigned int v15; // r14d
__int64 v16; // rax
const std::string::value_type *CString; // rsi
std::string::pointer data; // rdi
char *v19; // r12
void *v20; // r12
__int64 v21; // r14
__int64 v22; // r12
__int64 v23; // rax
void *v24; // r14
__int64 v25; // r12
unsigned int v26; // r14d
__int64 v27; // r15
__int64 v28; // r12
int v29; // r13d
void *v30; // rsi
char v31; // [rsp+0h] [rbp-70h]
unsigned int v32; // [rsp+8h] [rbp-68h] BYREF
__int64 v33; // [rsp+10h] [rbp-60h]
int IntForKey; // [rsp+1Ch] [rbp-54h]
std::string v35; // [rsp+20h] [rbp-50h] BYREF
__int64 v36; // [rsp+3Ch] [rbp-34h] BYREF
unsigned __int8 v37; // [rsp+47h] [rbp-29h]
result = FLAlertLayer::init_1((_BYTE *)a1, 75);
if ( (_BYTE)result )
{
v37 = result;
v3 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v36, v3);
sub_100278270((__int64)&v35, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v4 = cocos2d::extension::CCScale9Sprite::create_2((__int64)"GJ_square01.png", (unsigned __int64 *)&v35);
sub_100278260((float *)&v35, 380.0, 180.0);
(*(void (__fastcall **)(void *, std::string *))(*(_QWORD *)v4 + 320LL))(v4, &v35);
(*(void (__fastcall **)(_QWORD, void *, __int64))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v4,
0xFFFFFFFFLL);
sub_100278250((float *)&v35, *(float *)&v36 * 0.5, *((float *)&v36 + 1) * 0.5);
(*(void (__fastcall **)(void *, std::string *))(*(_QWORD *)v4 + 184LL))(v4, &v35);
v5 = cocos2d::CCLabelBMFont::create_3((__int64)"Demon Filter", (__int64)"bigFont.fnt");
sub_100278250((float *)&v35, *(float *)&v36 * 0.5, (float)((float)(*((float *)&v36 + 1) * 0.5) + 90.0) + -20.0);
(*(void (__fastcall **)(void *, std::string *))(*(_QWORD *)v5 + 184LL))(v5, &v35);
v6 = *(_QWORD *)(a1 + 584);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v6 + 456LL))(v6, v5);
v7 = sub_1007FE900(v6);
*(_QWORD *)(a1 + 664) = v7;
v8 = v7;
cocos2d::CCObject::retain(v7);
v33 = sub_1007FE900(v8);
v11 = cocos2d::CCMenu::create(v8, v5, v9, v10);
*(_QWORD *)(a1 + 552) = v11;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 464LL))(*(_QWORD *)(a1 + 584), v11, 10);
v12 = GameLevelManager::sharedState();
IntForKey = GameLevelManager::getIntForKey(v12, "demon_filter");
v13 = nullptr;
v14 = 0;
while ( 2 )
{
v15 = 6;
switch ( v14 )
{
case 0:
memset(&v35, 0, sizeof(v35));
v15 = 0;
std::string::assign(&v35, "difficulty_06_btn_001.png");
goto LABEL_11;
case 1:
v15 = 7;
goto LABEL_10;
case 2:
v15 = 8;
goto LABEL_10;
case 4:
v15 = 9;
goto LABEL_10;
case 5:
v15 = 10;
goto LABEL_10;
default:
LABEL_10:
memset(&v35, 0, sizeof(v35));
v16 = sub_10088E820("difficulty_%02d_btn2_001.png", v31);
CString = (const std::string::value_type *)cocos2d::CCString::getCString(v16);
std::string::assign(&v35, CString);
LABEL_11:
data = v35.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) != 0 )
data = v35.__r_.__value_.__l.__data_;
v19 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)data, 0.0);
(*(void (__fastcall **)(char *, float))(*(_QWORD *)v19 + 160LL))(v19, 1.1);
v20 = CCMenuItemSpriteExtra::create((__int64)v19, 0, a1, (__int64)DemonFilterSelectLayer::selectRating, 0);
(*(void (__fastcall **)(_QWORD, void *))(**(_QWORD **)(a1 + 552) + 456LL))(*(_QWORD *)(a1 + 552), v20);
sub_1007FEBF0(*(_QWORD *)(a1 + 664), v20);
(*(void (__fastcall **)(void *, _QWORD))(*(_QWORD *)v20 + 72LL))(v20, v15);
sub_1007FEBF0(v33, v20);
if ( v15 == IntForKey )
v13 = v20;
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v35.__r_.__value_.__l.__data_);
if ( ++v14 != 6 )
continue;
v21 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)&v32, *(float *)&v36 * 0.5, (float)(*((float *)&v36 + 1) * 0.5) + 3.0);
cocos2d::CCNode::convertToNodeSpace((double *)&v35, v21, &v32);
v22 = v33;
GameToolbox::alignItemsHorisontally(v33, (unsigned __int64 *)&v35, 0, (__m128)0x41900000u);
sub_1007FF190(v22);
v23 = sub_100059E00((__int64)"OK");
v24 = CCMenuItemSpriteExtra::create(v23, 0, a1, (__int64)DemonFilterSelectLayer::onClose, 0);
(*(void (__fastcall **)(_QWORD, void *))(**(_QWORD **)(a1 + 552) + 456LL))(*(_QWORD *)(a1 + 552), v24);
sub_1007FEBF0(v22, v24);
v25 = *(_QWORD *)(a1 + 552);
sub_100278250(
(float *)&v32,
*(float *)&v36 * 0.5,
(float)((float)(0.5 * *((float *)&v36 + 1)) + -90.0) + 25.0);
cocos2d::CCNode::convertToNodeSpace((double *)&v35, v25, &v32);
(*(void (__fastcall **)(void *, std::string *))(*(_QWORD *)v24 + 184LL))(v24, &v35);
if ( v13 )
{
*(_DWORD *)(a1 + 680) = (*(__int64 (__fastcall **)(void *))(*(_QWORD *)v13 + 64LL))(v13);
if ( (unsigned int)sub_1007FEF90(*(_QWORD *)(a1 + 664)) )
{
v26 = 0;
do
{
v27 = sub_1007FEFE0(*(_QWORD *)(a1 + 664), v26);
v28 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v27 + 1072LL))(v27);
v29 = *(_DWORD *)(a1 + 680);
v30 = &unk_100A11D58;
if ( v29 == (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v27 + 64LL))(v27) )
v30 = &unk_100A11D5B;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v28 + 960LL))(v28, v30);
++v26;
}
while ( v26 < (unsigned int)sub_1007FEF90(*(_QWORD *)(a1 + 664)) );
}
}
result = v37;
break;
}
break;
}
}
return result;
}