//
// cocos2d::CCMenu::alignItemsInRowsWithArray from 0xaf288c to 0xaf2d4c (1216 bytes)
//
// 2 xrefs:
// > cocos2d::CCMenu::alignItemsInRows @ 0xaf2e18
// > ??> @ 0x95718
//
// 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
//
void cocos2d::CCMenu::alignItemsInRowsWithArray(cocos2d::CCMenu *a1, cocos2d::CCArray *a2)
{
cocos2d::CCArray *m_pChildren; // x0
int v4; // w21
_BYTE *v5; // x24
unsigned int v6; // w19
cocos2d::CCDirector *v7; // x0
cocos2d::CCArray *v8; // x0
cocos2d::CCArray *v9; // x0
cocos2d::ccArray *data; // x1
const void **arr; // x20
const void *v12; // x0
unsigned int v13; // w27
float v14; // w22
int v15; // w21
void *v16; // x0
void *v17; // x23
float v18; // s8
float v19; // s0
float *v20; // x0
cocos2d::CCArray *v21; // x0
cocos2d::ccArray *v22; // x1
const void **v23; // x20
const void *v24; // x0
float v25; // s9
float v26; // s8
unsigned int v27; // w22
unsigned int v28; // w21
unsigned int v29; // w23
void *v30; // x0
void *v31; // x28
float v32; // s10
float v33; // s0
unsigned int v34; // w0
size_t v35; // x23
unsigned __int64 v36; // x1
unsigned __int64 v37; // x19
char *v38; // x3
unsigned __int64 v39; // x0
char *v40; // [xsp+A0h] [xbp+A0h]
unsigned int *v41; // [xsp+B0h] [xbp+B0h]
const void **v42; // [xsp+B8h] [xbp+B8h]
const void **v43; // [xsp+B8h] [xbp+B8h]
unsigned int v44; // [xsp+C0h] [xbp+C0h]
void (__fastcall *v45)(void *, cocos2d::CCPoint *); // [xsp+C0h] [xbp+C0h]
char *v46; // [xsp+C0h] [xbp+C0h]
unsigned int v47; // [xsp+C8h] [xbp+C8h]
float v48; // [xsp+DCh] [xbp+DCh]
cocos2d::CCPoint v49; // [xsp+E0h] [xbp+E0h] BYREF
void *v50; // [xsp+E8h] [xbp+E8h] BYREF
void *p; // [xsp+100h] [xbp+100h] BYREF
float *v52; // [xsp+108h] [xbp+108h]
float *v53; // [xsp+110h] [xbp+110h]
sub_AF22EC((__int64)a2, &v50);
p = nullptr;
m_pChildren = a1->m_pChildren;
v52 = nullptr;
v53 = nullptr;
if ( m_pChildren )
{
if ( (unsigned int)cocos2d::CCArray::count(m_pChildren) )
{
v9 = a1->m_pChildren;
if ( v9 )
{
data = v9->data;
if ( data->num )
{
arr = (const void **)data->arr;
v42 = &arr[data->num - 1];
if ( arr <= v42 )
{
v12 = *arr;
if ( *arr )
{
v40 = nullptr;
v5 = nullptr;
v41 = nullptr;
v13 = 0;
v6 = 0;
v47 = 0;
v14 = NAN;
v15 = -10;
while ( 1 )
{
v16 = _dynamic_cast(
v12,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
0);
v17 = v16;
if ( !v16 )
goto LABEL_31;
v44 = *((_DWORD *)v50 + v47);
v18 = (float)v13;
v19 = *(float *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)v16 + 312LL))(v16);
if ( v19 <= (float)v13 || (v13 = (unsigned int)v19, __isnanf(v19)) )
v13 = (unsigned int)v18;
++v6;
LODWORD(v14) += (int)(float)(*(float *)((*(__int64 (__fastcall **)(void *))(*(_QWORD *)v17 + 312LL))(v17)
+ 4)
+ 5.0);
if ( v44 > v6 )
goto LABEL_31;
if ( v40 != (char *)v41 )
{
if ( v41 )
*v41 = v13;
++v41;
goto LABEL_26;
}
v35 = v40 - v5;
v36 = (v40 - v5) >> 2;
if ( !v36 )
break;
v39 = 2 * v36;
v37 = -4;
if ( v36 > 2 * v36 )
goto LABEL_54;
if ( v39 > 0x3FFFFFFFFFFFFFFFLL )
goto LABEL_54;
v37 = 8 * v36;
v38 = nullptr;
if ( v39 )
goto LABEL_54;
LABEL_55:
if ( &v38[v35] )
*(_DWORD *)&v38[v35] = v13;
if ( v36 )
{
v38 = (char *)memmove(v38, v5, v35);
v41 = (unsigned int *)&v38[v35 + 4];
LABEL_59:
v46 = v38;
operator delete(v5);
v38 = v46;
goto LABEL_60;
}
v41 = (unsigned int *)&v38[v35 + 4];
if ( v5 )
goto LABEL_59;
LABEL_60:
v5 = v38;
v40 = &v38[v37];
LABEL_26:
v49.x = v14;
v20 = v52;
if ( v52 == v53 )
{
std::vector::_M_emplace_back_aux((__int64)&p, &v49);
}
else
{
if ( v52 )
*v52 = v14;
v52 = v20 + 1;
}
v15 += 10 + v13;
v6 = 0;
v13 = 0;
++v47;
v14 = NAN;
LABEL_31:
if ( v42 >= ++arr )
{
v12 = *arr;
if ( *arr )
continue;
}
v4 = v15 / -2;
goto LABEL_4;
}
v37 = 4;
LABEL_54:
v38 = (char *)operator new(v37);
v36 = (v40 - v5) >> 2;
goto LABEL_55;
}
}
}
}
}
}
v4 = 5;
v5 = nullptr;
v6 = 0;
LABEL_4:
v7 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v7);
v8 = a1->m_pChildren;
if ( v8 )
{
if ( (unsigned int)cocos2d::CCArray::count(v8) )
{
v21 = a1->m_pChildren;
if ( v21 )
{
v22 = v21->data;
if ( v22->num )
{
v23 = (const void **)v22->arr;
v43 = &v23[v22->num - 1];
if ( v23 <= v43 )
{
v24 = *v23;
if ( *v23 )
{
v25 = 0.0;
v26 = (float)v4;
v27 = 0;
v28 = 0;
v29 = 0;
do
{
v30 = _dynamic_cast(
v24,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
0);
v31 = v30;
if ( v30 )
{
if ( !v27 )
{
v27 = *((_DWORD *)v50 + v29);
v25 = (float)*((unsigned int *)p + v29);
}
v32 = (float)v28;
v33 = *(float *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)v30 + 312LL))(v30);
if ( v33 <= (float)v28 || (v28 = (unsigned int)v33, __isnanf(v33)) )
v28 = (unsigned int)v32;
++v6;
v45 = *(void (__fastcall **)(void *, cocos2d::CCPoint *))(*(_QWORD *)v31 + 184LL);
cocos2d::CCPoint::CCPoint(&v49, (float)(*(_DWORD *)&v5[4 * v29] >> 1) + v26, v25 - (float)(v48 * 0.5));
v45(v31, &v49);
v25 = v25
- (float)(*(float *)((*(__int64 (__fastcall **)(void *))(*(_QWORD *)v31 + 312LL))(v31) + 4) + 10.0);
if ( v27 <= v6 )
{
v34 = v28 + 5;
++v29;
v28 = 0;
v27 = 0;
v6 = 0;
v26 = v26 + (float)v34;
}
}
if ( v43 < ++v23 )
break;
v24 = *v23;
}
while ( *v23 );
}
}
}
}
}
}
if ( p )
operator delete(p);
if ( v5 )
operator delete(v5);
if ( v50 )
operator delete(v50);
}