//
// cocos2d::CCMenu::alignItemsInColumnsWithArray from 0xaf23ec to 0xaf26f8 (780 bytes)
//
// 2 xrefs:
// > cocos2d::CCMenu::alignItemsInColumns @ 0xaf27c4
// > ??> @ 0x9cde0
//
// 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::alignItemsInColumnsWithArray(cocos2d::CCMenu *a1, cocos2d::CCArray *a2)
{
cocos2d::CCArray *m_pChildren; // x0
int v4; // w22
unsigned int v5; // w19
cocos2d::CCDirector *v6; // x0
cocos2d::CCArray *v7; // x0
cocos2d::CCArray *v8; // x0
cocos2d::ccArray *data; // x1
const void **arr; // x21
__int64 v11; // x0
char *v12; // x23
const void *v13; // x0
unsigned int v14; // w20
unsigned int v15; // w24
int v16; // w22
void *v17; // x0
unsigned int v18; // w27
float v19; // s8
float v20; // s0
cocos2d::CCArray *v21; // x0
cocos2d::ccArray *v22; // x1
const void **v23; // x20
const void *v24; // x0
float v25; // s9
unsigned int v26; // w21
float v27; // s8
unsigned int v28; // w22
float v29; // s10
void *v30; // x28
float v31; // s11
float v32; // s0
void (__fastcall *v33)(void *, cocos2d::CCPoint *); // x23
__int64 v34; // x0
float v35; // s0
const void **v36; // [xsp+90h] [xbp+90h]
unsigned int v37; // [xsp+9Ch] [xbp+9Ch]
float v38; // [xsp+B0h] [xbp+B0h]
cocos2d::CCPoint v39; // [xsp+B8h] [xbp+B8h] BYREF
void *p; // [xsp+C0h] [xbp+C0h] BYREF
sub_AF22EC((__int64)a2, &p);
m_pChildren = a1->m_pChildren;
if ( m_pChildren
&& (unsigned int)cocos2d::CCArray::count(m_pChildren)
&& (v8 = a1->m_pChildren) != nullptr
&& (data = v8->data, data->num)
&& (arr = (const void **)data->arr,
v11 = 8LL * data->num - 8,
v12 = (char *)arr + v11,
arr <= (const void **)((char *)arr + v11))
&& (v13 = *arr) != nullptr )
{
v5 = 0;
v14 = 0;
v15 = 0;
v16 = -5;
do
{
v17 = _dynamic_cast(
v13,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
0);
if ( v17 )
{
v18 = *((_DWORD *)p + v15);
v19 = (float)v14;
v20 = *(float *)((*(__int64 (__fastcall **)(void *))(*(_QWORD *)v17 + 312LL))(v17) + 4);
if ( v20 <= (float)v14 || (v14 = (unsigned int)v20, __isnanf(v20)) )
v14 = (unsigned int)v19;
if ( v18 <= ++v5 )
{
++v15;
v16 += 5 + v14;
v5 = 0;
v14 = 0;
}
}
if ( v12 < (char *)++arr )
break;
v13 = *arr;
}
while ( *arr );
v4 = v16 / 2;
}
else
{
v4 = -2;
v5 = 0;
}
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v6);
v7 = a1->m_pChildren;
if ( v7 )
{
if ( (unsigned int)cocos2d::CCArray::count(v7) )
{
v21 = a1->m_pChildren;
if ( v21 )
{
v22 = v21->data;
if ( v22->num )
{
v23 = (const void **)v22->arr;
v36 = &v23[v22->num - 1];
if ( v23 <= v36 )
{
v24 = *v23;
if ( *v23 )
{
v25 = 0.0;
v26 = 0;
v27 = (float)v4;
v37 = 0;
v28 = 0;
v29 = 0.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);
if ( v30 )
{
if ( !v26 )
{
v26 = *((_DWORD *)p + v37);
v29 = v38 / (float)(v26 + 1);
v25 = v29;
}
v31 = (float)v28;
v32 = *(float *)((*(__int64 (__fastcall **)(void *))(*(_QWORD *)v30 + 312LL))(v30) + 4);
if ( v32 <= (float)v28 || (v28 = (unsigned int)v32, __isnanf(v32)) )
v28 = (unsigned int)v31;
++v5;
v33 = *(void (__fastcall **)(void *, cocos2d::CCPoint *))(*(_QWORD *)v30 + 184LL);
v34 = (*(__int64 (__fastcall **)(void *))(*(_QWORD *)v30 + 312LL))(v30);
cocos2d::CCPoint::CCPoint(&v39, v25 - (float)(v38 * 0.5), v27 - (float)(*(float *)(v34 + 4) * 0.5));
v33(v30, &v39);
v25 = v25 + v29;
if ( v26 <= v5 )
{
v26 = 0;
v5 = 0;
v35 = (float)(v28 + 5);
v28 = 0;
++v37;
v27 = v27 - v35;
}
}
if ( v36 < ++v23 )
break;
v24 = *v23;
}
while ( *v23 );
}
}
}
}
}
}
if ( p )
operator delete(p);
}