//
// cocos2d::CCMenu::alignItemsInRowsWithArray from 0x5d45ac to 0x5d48dc (816 bytes)
//
// 1 xrefs:
// > cocos2d::CCMenu::alignItemsInRows @ 0x5d493c
//
// 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)
{
unsigned int v3; // r5
cocos2d::CCArray *m_pChildren; // r0
cocos2d::CCArray *num; // r4
int v6; // r6
cocos2d::CCDirector *v7; // r0
cocos2d::CCArray *v8; // r0
cocos2d::CCArray *v9; // r3
cocos2d::ccArray *v10; // r2
float v11; // s17
const void **v12; // r8
float v13; // s16
unsigned int v14; // r6
unsigned int v15; // r10
int v16; // r9
cocos2d::ccArray *data; // r3
cocos2d::CCObject **arr; // r3
char *v19; // r6
float v20; // r9
struct __class_type_info *v21; // r2
struct __class_type_info *v22; // r8
const void *v23; // r0
const void *v24; // t1
void *v25; // r0
void *v26; // r11
float *v27; // r0
float v28; // s16
unsigned int v29; // s15
unsigned int *v30; // r3
unsigned int v31; // r0
unsigned int v32; // r11
char *v33; // r3
void *v34; // r1
size_t v35; // r4
int v36; // r2
unsigned int *v37; // r4
float *v38; // r3
const void *v39; // r0
const void *v40; // t1
void *v41; // r0
void *v42; // r5
float *v43; // r0
float v44; // s18
unsigned int v45; // s15
const void **v46; // [sp+0h] [bp-54h]
int v47; // [sp+0h] [bp-54h]
struct __class_type_info *v48; // [sp+4h] [bp-50h]
struct __class_type_info *v49; // [sp+4h] [bp-50h]
struct __class_type_info *lpstype; // [sp+8h] [bp-4Ch]
struct __class_type_info *lpstypea; // [sp+8h] [bp-4Ch]
cocos2d::CCSize v52; // [sp+18h] [bp-3Ch] BYREF
cocos2d::CCPoint v53; // [sp+20h] [bp-34h] BYREF
void *v54; // [sp+28h] [bp-2Ch] BYREF
void *v55; // [sp+34h] [bp-20h] BYREF
unsigned int *v56; // [sp+38h] [bp-1Ch]
unsigned int *v57; // [sp+3Ch] [bp-18h]
void *p; // [sp+40h] [bp-14h] BYREF
float *v59; // [sp+44h] [bp-10h]
float *v60; // [sp+48h] [bp-Ch]
v3 = 0;
sub_5D4268((int)&v54, (int)a2);
m_pChildren = a1->m_pChildren;
v55 = nullptr;
v56 = nullptr;
v57 = nullptr;
p = nullptr;
v59 = nullptr;
v60 = nullptr;
if ( !m_pChildren || !cocos2d::CCArray::count(m_pChildren) )
{
num = nullptr;
LABEL_4:
v6 = -10;
goto LABEL_5;
}
num = a1->m_pChildren;
if ( !num )
goto LABEL_4;
data = num->data;
num = (cocos2d::CCArray *)data->num;
if ( !data->num )
goto LABEL_4;
arr = data->arr;
v19 = (char *)&num[19173961].m_uID + 3;
num = nullptr;
v20 = NAN;
v47 = 0;
v21 = (struct __class_type_info *)&arr[(_DWORD)v19];
v22 = (struct __class_type_info *)arr;
v6 = -10;
v48 = v21;
while ( v22 <= v48 )
{
v24 = *(const void **)v22;
v22 = (struct __class_type_info *)((char *)v22 + 4);
v23 = v24;
if ( !v24 )
break;
v25 = _dynamic_cast(
v23,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
0);
v26 = v25;
if ( v25 )
{
lpstype = *((struct __class_type_info **)v54 + v47);
v27 = (float *)(*(int (__fastcall **)(void *))(*(_DWORD *)v25 + 156))(v25);
v28 = *v27;
if ( (float)v3 >= *v27 || _isnanf(*v27) )
v29 = (unsigned int)(float)v3;
else
v29 = (unsigned int)v28;
v3 = v29;
num = (cocos2d::CCArray *)((char *)num + 1);
LODWORD(v20) += (int)(float)(*(float *)((*(int (__fastcall **)(void *))(*(_DWORD *)v26 + 156))(v26) + 4) + 5.0);
if ( num >= (cocos2d::CCArray *)lpstype )
{
v30 = v56;
if ( v56 == v57 )
{
v31 = std::vector::_M_check_len(&v55, 1u, (int)"vector::_M_emplace_back_aux");
v32 = v31;
if ( v31 )
{
if ( v31 >= 0x40000000 )
sub_772FB4(v31);
v33 = (char *)operator new(4 * v31);
}
else
{
v33 = nullptr;
}
v34 = v55;
v35 = (char *)v56 - (_BYTE *)v55;
v36 = ((char *)v56 - (_BYTE *)v55) >> 2;
if ( &v33[(char *)v56 - (_BYTE *)v55] )
*(_DWORD *)&v33[v35] = v29;
if ( v36 )
v33 = (char *)memmove(v33, v34, v35);
v37 = (unsigned int *)&v33[v35 + 4];
if ( v55 )
{
lpstypea = (struct __class_type_info *)v33;
operator delete(v55);
v33 = (char *)lpstypea;
}
v55 = v33;
v56 = v37;
v57 = (unsigned int *)&v33[4 * v32];
}
else
{
if ( v56 )
*v56 = v29;
v56 = v30 + 1;
}
v38 = v59;
v53.x = v20;
if ( v59 == v60 )
{
std::vector::_M_emplace_back_aux((const void **)&p, &v53);
}
else
{
if ( v59 )
*v59 = v20;
v59 = v38 + 1;
}
v6 += 10 + v29;
v3 = 0;
num = nullptr;
++v47;
v20 = NAN;
}
}
}
LABEL_5:
v7 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v52, v7);
v8 = a1->m_pChildren;
if ( v8 )
{
if ( cocos2d::CCArray::count(v8) )
{
v9 = a1->m_pChildren;
if ( v9 )
{
v10 = v9->data;
if ( v10->num )
{
v11 = 0.0;
v12 = (const void **)v10->arr;
v13 = (float)(v6 / -2);
v14 = 0;
v15 = 0;
v16 = 0;
v46 = &v12[v10->num] + 0x3FFFFFFF;
while ( v12 <= v46 )
{
v40 = *v12++;
v39 = v40;
if ( !v40 )
break;
v41 = _dynamic_cast(
v39,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
0);
v42 = v41;
if ( v41 )
{
if ( !v15 )
{
v15 = *((_DWORD *)v54 + v16);
v11 = (float)*((unsigned int *)p + v16);
}
v43 = (float *)(*(int (__fastcall **)(void *))(*(_DWORD *)v41 + 156))(v41);
v44 = *v43;
if ( (float)v14 >= *v43 || _isnanf(*v43) )
v45 = (unsigned int)(float)v14;
else
v45 = (unsigned int)v44;
v14 = v45;
num = (cocos2d::CCArray *)((char *)num + 1);
v49 = *(struct __class_type_info **)(*(_DWORD *)v42 + 92);
cocos2d::CCPoint::CCPoint(
&v53,
v13 + (float)(*((_DWORD *)v55 + v16) >> 1),
v11 - (float)(v52.height * 0.5));
((void (__fastcall *)(void *, cocos2d::CCPoint *))v49)(v42, &v53);
v11 = v11 - (float)(*(float *)((*(int (__fastcall **)(void *))(*(_DWORD *)v42 + 156))(v42) + 4) + 10.0);
if ( (unsigned int)num >= v15 )
{
++v16;
v14 = 0;
v15 = 0;
num = nullptr;
v13 = v13 + (float)(v45 + 5);
}
}
}
}
}
}
}
if ( p )
operator delete(p);
if ( v55 )
operator delete(v55);
if ( v54 )
operator delete(v54);
}