//
// SetupRandAdvTriggerPopup::updateGroupIDButtons from 0xaef7e0 to 0xaf01b8 (2520 bytes)
//
// 9 xrefs:
// > SetupRandAdvTriggerPopup::init @ 0xaf0c08
// > SetupRandAdvTriggerPopup::addChance @ 0xaf1008
// > SetupRandAdvTriggerPopup::addChance @ 0xaf1058
// > SetupRandAdvTriggerPopup::removeGroupID @ 0xaf109c
// > SetupRandAdvTriggerPopup::removeGroupID @ 0xaf10e8
// > SetupRandAdvTriggerPopup::onGroupIDScrollUp @ 0xaf1140
// > SetupRandAdvTriggerPopup::onGroupIDScrollDown @ 0xaf1154
// > SetupRandAdvTriggerPopup::onAddChance @ 0xaf1214
// > ??> @ 0x5f7b8
//
// 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:01:12 +0000
//
__int64 __fastcall SetupRandAdvTriggerPopup::updateGroupIDButtons(cocos2d::CCArray **this)
{
unsigned int i; // w19
unsigned int v3; // w1
__int64 v4; // x0
cocos2d::CCArray *v5; // x0
RandTriggerGameObject *v6; // x22
char *v7; // x19
char *v8; // x21
unsigned __int64 v9; // x1
char *v10; // x0
int v11; // w27
signed __int64 v12; // x24
signed int v13; // w1
int v14; // w0
__int64 v15; // x0
_BOOL4 v16; // w19
__int64 v17; // x0
int v18; // w19
cocos2d::CCDirector *v19; // x0
cocos2d::CCDirector *v20; // x0
cocos2d::CCNode *v21; // x21
double v22; // d0
__int64 v23; // x22
int v24; // w19
unsigned int *v25; // x23
const char *v26; // x24
int v27; // w0
_BOOL4 v28; // w20
int v29; // w2
cocos2d::CCString *v30; // x0
char *CString; // x0
const char *v32; // x6
ButtonSprite *v33; // x0
__int64 v34; // x0
__int64 v35; // x24
__int64 v36; // x0
void (__fastcall *v37)(__int64, char **); // x2
cocos2d::CCObject *v38; // x20
void (__fastcall *v39)(cocos2d::CCObject *, char **); // x25
unsigned int v41; // w20
const char *v42; // x1
RandTriggerGameObject *v43; // x19
int v44; // w0
int *v45; // x21
int *v46; // x26
int v47; // w22
unsigned __int64 v48; // x19
unsigned __int64 v49; // x23
unsigned __int64 v50; // x1
__int64 v51; // x5
unsigned __int64 v52; // x4
_QWORD *v53; // x20
__int64 **v54; // x0
__int64 *v55; // x2
unsigned __int64 v56; // x2
unsigned __int64 v57; // x0
int v58; // w25
unsigned __int64 v59; // x24
void **v60; // x2
void **v61; // x20
unsigned __int64 v62; // x2
unsigned __int64 v63; // x2
float v64; // s0
__int64 v65; // x0
unsigned __int64 prime; // x22
unsigned __int64 v67; // x0
bool v68; // cf
unsigned __int64 v69; // x24
unsigned __int64 v70; // x1
void **v71; // x0
char *v72; // x20
unsigned __int64 v73; // x0
unsigned __int64 v74; // x1
unsigned __int64 v75; // x0
unsigned __int64 v76; // x0
_DWORD *v77; // x19
char *v78; // x1
unsigned int v79; // w23
_QWORD *v80; // x0
_QWORD *v81; // x19
void *v82; // x0
unsigned int v83; // [xsp+98h] [xbp+98h]
unsigned int v84; // [xsp+98h] [xbp+98h]
int TotalChance; // [xsp+9Ch] [xbp+9Ch]
__int64 v86; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v87; // [xsp+A8h] [xbp+A8h] BYREF
char v88[8]; // [xsp+B0h] [xbp+B0h] BYREF
char *v89; // [xsp+B8h] [xbp+B8h] BYREF
void *v90; // [xsp+C0h] [xbp+C0h] BYREF
char *v91; // [xsp+C8h] [xbp+C8h]
unsigned __int64 v92; // [xsp+D0h] [xbp+D0h]
__int64 v93[2]; // [xsp+D8h] [xbp+D8h] BYREF
ButtonSprite *v94; // [xsp+E8h] [xbp+E8h]
void *v95; // [xsp+F0h] [xbp+F0h] BYREF
unsigned __int64 v96; // [xsp+F8h] [xbp+F8h]
void *v97; // [xsp+100h] [xbp+100h] BYREF
unsigned __int64 v98; // [xsp+108h] [xbp+108h]
float v99; // [xsp+110h] [xbp+110h]
for ( i = 0; ; ++i )
{
v68 = i >= (unsigned int)cocos2d::CCArray::count(*(this + 127));
v5 = *(this + 127);
if ( v68 )
break;
v3 = i;
v4 = cocos2d::CCArray::objectAtIndex(v5, v3);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v4 + 520LL))(v4);
}
cocos2d::CCArray::removeAllObjects(v5);
v6 = *(this + 85);
v90 = nullptr;
v91 = nullptr;
v92 = 0;
if ( v6 )
{
v7 = *((char **)v6 + 230);
v8 = *((char **)v6 + 231);
if ( v7 != v8 )
{
v9 = 0;
v10 = nullptr;
while ( 1 )
{
v95 = v7;
if ( (unsigned __int64)v10 < v9 )
{
if ( v10 )
{
*(_QWORD *)v10 = v7;
v10 = v91;
}
v7 += 16;
v91 = v10 + 8;
if ( v8 == v7 )
break;
}
else
{
std::vector::__push_back_slow_path((__int64)&v90, &v95);
v7 += 16;
if ( v8 == v7 )
break;
}
v10 = v91;
v9 = v92;
}
}
TotalChance = RandTriggerGameObject::getTotalChance(v6);
v11 = 1;
goto LABEL_14;
}
v95 = nullptr;
v11 = 1;
v84 = 0;
v96 = 0;
TotalChance = 0;
v97 = nullptr;
v98 = 0;
v99 = 1.0;
while ( v84 < (unsigned int)cocos2d::CCArray::count(*(this + 86)) )
{
v43 = (RandTriggerGameObject *)cocos2d::CCArray::objectAtIndex(*(this + 86), v84);
v44 = RandTriggerGameObject::getTotalChance(v43);
v45 = *((int **)v43 + 230);
v46 = *((int **)v43 + 231);
TotalChance = v44;
if ( v45 != v46 )
{
while ( 1 )
{
v47 = *v45;
v48 = v96;
v49 = *v45;
if ( v96 )
{
v50 = v96 - 1;
v51 = (v96 - 1) & v96;
v52 = v47 & (v96 - 1);
if ( v51 )
v52 = v47 % v96;
v53 = v95;
v54 = *((__int64 ***)v95 + v52);
if ( v54 )
{
LABEL_57:
v54 = (__int64 **)*v54;
if ( v54 )
{
v55 = v54[1];
if ( !v51 )
{
v56 = v50 & (unsigned __int64)v55;
goto LABEL_60;
}
while ( 1 )
{
v56 = (unsigned __int64)v55 % v48;
LABEL_60:
if ( v52 != v56 )
break;
v55 = (__int64 *)*((unsigned int *)v54 + 4);
if ( v47 != (_DWORD)v55 )
goto LABEL_57;
v54 = nullptr;
__break(0x3E8u);
}
}
}
v57 = v50 & v48;
v58 = v45[2];
v59 = v47 & v50;
if ( (v50 & v48) != 0 )
v59 = v47 % v48;
v60 = (void **)v53[v59];
if ( v60 )
{
v61 = (void **)*v60;
if ( *v60 )
{
v62 = (unsigned __int64)v61[1];
if ( !v57 )
{
LABEL_66:
v63 = v62 & v50;
goto LABEL_67;
}
while ( 1 )
{
v63 = v62 % v48;
LABEL_67:
if ( v59 != v63 )
break;
if ( *((_DWORD *)v61 + 4) == v47 )
goto LABEL_87;
v61 = (void **)*v61;
if ( !v61 )
break;
v62 = (unsigned __int64)v61[1];
if ( !v57 )
goto LABEL_66;
}
}
}
}
else
{
v58 = v45[2];
v59 = 0;
}
v61 = (void **)operator new(0x28u);
*((_DWORD *)v61 + 4) = *v45;
*((_DWORD *)v61 + 5) = v47;
*((_DWORD *)v61 + 6) = v47;
*((_DWORD *)v61 + 7) = v58;
*((_DWORD *)v61 + 8) = 0;
v61[1] = (void *)v47;
*v61 = nullptr;
v64 = (float)(v98 + 1);
if ( v64 <= (float)((float)v48 * v99) )
break;
v65 = 2 * v48;
if ( v48 <= 2 )
goto LABEL_71;
prime = (((v48 - 1) & v48) != 0) + v65;
v76 = vcvtps_u32_f32(v64 / v99);
if ( v76 >= prime )
prime = v76;
if ( prime == 1 )
{
LABEL_115:
v48 = v96;
prime = 2;
v68 = v96 <= 2;
if ( v96 < 2 )
goto LABEL_116;
goto LABEL_77;
}
LABEL_74:
if ( ((prime - 1) & prime) != 0 )
prime = std::__next_prime(prime);
v48 = v96;
v68 = prime >= v96;
if ( prime > v96 )
{
LABEL_116:
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::__rehash(
(__int64)&v95,
prime);
goto LABEL_96;
}
LABEL_77:
if ( v68 )
goto LABEL_97;
if ( v48 <= 2 || (v69 = v48 - 1, ((v48 - 1) & v48) != 0) )
{
v73 = std::__next_prime(vcvtps_u32_f32((float)v98 / v99));
if ( v73 < prime )
v70 = prime;
else
v70 = v73;
if ( v48 <= v70 )
goto LABEL_96;
}
else
{
v70 = 1LL << (64 - (unsigned __int8)__clz(vcvtps_u32_f32((float)v98 / v99) - 1));
if ( v70 < prime )
v70 = prime;
if ( v48 <= v70 )
{
LABEL_83:
v59 = v69 & v49;
LABEL_84:
v71 = *((void ***)v95 + v59);
if ( v71 )
goto LABEL_85;
goto LABEL_99;
}
}
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::__rehash(
(__int64)&v95,
v70);
LABEL_96:
v48 = v96;
LABEL_97:
v69 = v48 - 1;
if ( ((v48 - 1) & v48) == 0 )
goto LABEL_83;
v59 = v49 % v48;
v71 = *((void ***)v95 + v49 % v48);
if ( v71 )
{
LABEL_85:
*v61 = *v71;
*v71 = v61;
goto LABEL_86;
}
LABEL_99:
*v61 = v97;
v97 = v61;
*((_QWORD *)v95 + v59) = &v97;
if ( *v61 )
{
v74 = *((_QWORD *)*v61 + 1);
if ( ((v48 - 1) & v48) != 0 )
v75 = v74 % v48;
else
v75 = (v48 - 1) & v74;
*((_QWORD *)v95 + v75) = v61;
}
LABEL_86:
++v98;
LABEL_87:
v72 = (char *)v61 + 20;
*((_DWORD *)v72 + 3) = 0;
if ( *((_DWORD *)v72 + 2) != v45[2] )
{
v11 = 0;
*((_DWORD *)v72 + 2) = -1;
}
v45 += 4;
*((_DWORD *)v72 + 3) = 1;
if ( v46 == v45 )
goto LABEL_90;
}
if ( v48 )
goto LABEL_84;
v65 = 0;
LABEL_71:
prime = v65 + 1;
v67 = vcvtps_u32_f32(v64 / v99);
if ( v67 >= prime )
prime = v67;
if ( prime == 1 )
goto LABEL_115;
goto LABEL_74;
}
LABEL_90:
++v84;
}
v77 = v97;
if ( v97 )
{
do
{
while ( 1 )
{
v79 = v77[8];
v68 = v79 >= (unsigned int)cocos2d::CCArray::count(*(this + 86));
v78 = v91;
if ( !v68 )
v11 = 0;
v89 = (char *)(v77 + 5);
if ( (unsigned __int64)v91 < v92 )
break;
std::vector::__push_back_slow_path((__int64)&v90, &v89);
v77 = *(_DWORD **)v77;
if ( !v77 )
goto LABEL_127;
}
if ( v91 )
{
*(_QWORD *)v91 = v77 + 5;
v78 = v91;
}
v91 = v78 + 8;
v77 = *(_DWORD **)v77;
}
while ( v77 );
LABEL_127:
v80 = v97;
if ( v97 )
{
do
{
v81 = (_QWORD *)*v80;
operator delete(v80);
v80 = v81;
}
while ( v81 );
}
}
v82 = v95;
v95 = nullptr;
if ( v82 )
operator delete(v82);
LABEL_14:
v12 = (v91 - (_BYTE *)v90) >> 3;
v13 = vcvtps_s32_f32((float)(int)v12 / 5.0);
v14 = v13 - 2;
if ( v13 - 2 < 0 )
v14 = 0;
if ( v14 < *((_DWORD *)this + 266) )
*((_DWORD *)this + 266) = v14;
v15 = (__int64)*(this + 131);
v16 = v13 > 2;
if ( v15 )
(*(void (__fastcall **)(__int64, bool))(*(_QWORD *)v15 + 344LL))(v15, v13 > 2);
v17 = (__int64)*(this + 132);
if ( v17 )
(*(void (__fastcall **)(__int64, _BOOL4))(*(_QWORD *)v17 + 344LL))(v17, v16);
v18 = 5 * *((_DWORD *)this + 266);
v19 = (cocos2d::CCDirector *)(unsigned int)(v18 + 10);
if ( (int)v12 > (int)v19 )
LODWORD(v12) = v18 + 10;
v20 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v19);
cocos2d::CCDirector::getWinSize(&v86, v20);
v21 = *(this + 69);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v95,
(float)(*(float *)&v86 * 0.5) + -132.0,
(float)(*((float *)&v86 + 1) * 0.5) + 10.0);
cocos2d::CCNode::convertToNodeSpace(&v87, v21, (const cocos2d::CCPoint *)&v95);
v95 = chanceObjCompare;
std::__sort(
(__int64)v90,
v91,
(unsigned __int8 (__fastcall **)(__int64, __int64))&v95);
if ( v18 < (int)v12 )
{
v83 = v12 - v18;
v23 = 8LL * v18;
v24 = 0;
do
{
v25 = *(unsigned int **)((char *)v90 + v23);
if ( *(this + 85) || (v41 = v25[3], v41 >= (unsigned int)cocos2d::CCArray::count(*(this + 86))) )
v26 = "GJ_button_04.png";
else
v26 = "GJ_button_05.png";
v27 = v25[2];
v93[1] = 0;
v94 = nullptr;
v28 = v27 <= 0;
v29 = v25[2];
v93[0] = 0;
*(float *)&v22 = roundf((float)((float)v29 / (float)TotalChance) * 100.0);
if ( v11 )
{
if ( v27 <= 0 )
v30 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i - ?\n?%%",
(const char *)*v25,
v22);
else
v30 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i - %i\n%i%%",
(const char *)*v25);
}
else
{
v42 = (const char *)*v25;
if ( v27 <= 0 )
v30 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i - ?", v42, v22);
else
v30 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i - %i", v42, v22);
}
CString = (char *)cocos2d::CCString::getCString(v30);
std::string::assign(v93, CString);
if ( (v93[0] & 1) != 0 )
v33 = v94;
else
v33 = (ButtonSprite *)((char *)v93 + 1);
v34 = ButtonSprite::create(v33, (const char *)&qword_28, 0, 1, 0.35, "bigFont.fnt", v26, v32, 30.0);
v35 = v34;
if ( v28 )
{
v36 = *(_QWORD *)(v34 + 624);
v37 = *(void (__fastcall **)(__int64, char **))(*(_QWORD *)v36 + 1072LL);
LOBYTE(v89) = -1;
*(_WORD *)((char *)&v89 + 1) = 150;
v37(v36, &v89);
}
v38 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::create(
v35,
0,
(__int64)this,
(__int64)SetupRandAdvTriggerPopup::onRemoveFromGroup,
0);
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v38 + 72LL))(v38, *v25);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(*(_QWORD *)*(this + 69) + 456LL))(*(this + 69), v38);
v39 = *(void (__fastcall **)(cocos2d::CCObject *, char **))(*(_QWORD *)v38 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v88, (float)(v24 % 5) * 66.0, (float)(-38 * (v24 / 5)));
cocos2d::CCPoint::operator+(&v89, &v87);
v39(v38, &v89);
cocos2d::CCArray::addObject(*(this + 127), v38);
if ( (v93[0] & 1) != 0 )
operator delete(v94);
++v24;
v23 += 8;
}
while ( v24 != v83 );
}
if ( v90 )
{
if ( v90 != v91 )
v91 += 8 * ~((unsigned __int64)(v91 - 8 - (_BYTE *)v90) >> 3);
operator delete(v90);
}
return _stack_chk_guard;
}