//
// cocos2d::CCMenu::alignItemsInRowsWithArray from 0xd64964 to 0xd64df4 (1168 bytes)
//
// 2 xrefs:
// > cocos2d::CCMenu::alignItemsInRows @ 0xd64ec0
// > ??> @ 0xc5740
//
// 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:07:53 +0000
//
__int64 __fastcall cocos2d::CCMenu::alignItemsInRowsWithArray(cocos2d::CCMenu *this, cocos2d::CCArray *a2)
{
unsigned __int64 v3; // x0
int v4; // w20
unsigned int v5; // w19
cocos2d::CCDirector *v6; // x0
cocos2d::CCArray *v7; // x0
unsigned int *v9; // x1
unsigned __int64 *v10; // x21
unsigned int v11; // w27
int v12; // w22
int v13; // w20
void *v14; // x0
void *v15; // x23
unsigned int v16; // w28
float *v17; // x0
float v18; // s8
float v19; // s9
int v20; // w0
unsigned int v21; // w2
unsigned int *v22; // x0
int *v23; // x0
unsigned int v24; // w0
__int64 v25; // x0
unsigned int *v26; // x1
const void **v27; // x24
const void *v28; // x0
float v29; // s11
unsigned int v30; // w21
float v31; // s10
unsigned int v32; // w20
void *v33; // x23
float *v34; // x0
float v35; // s8
float v36; // s9
int v37; // w0
unsigned int v38; // w1
void (__fastcall *v39)(void *, int *); // x28
unsigned int v40; // w0
unsigned __int64 v41; // [xsp+B8h] [xbp+B8h]
const void **v42; // [xsp+B8h] [xbp+B8h]
unsigned int v43; // [xsp+CCh] [xbp+CCh] BYREF
__int64 v44; // [xsp+D0h] [xbp+D0h] BYREF
int v45; // [xsp+D8h] [xbp+D8h] BYREF
void *v46; // [xsp+E0h] [xbp+E0h] BYREF
char *v47; // [xsp+E8h] [xbp+E8h]
void *v48; // [xsp+F8h] [xbp+F8h] BYREF
unsigned int *v49; // [xsp+100h] [xbp+100h]
unsigned int *v50; // [xsp+108h] [xbp+108h]
void *v51; // [xsp+110h] [xbp+110h] BYREF
int *v52; // [xsp+118h] [xbp+118h]
unsigned __int64 v53; // [xsp+120h] [xbp+120h]
sub_D64268((__int64)a2, (__int64)&v46);
v48 = nullptr;
v3 = *((_QWORD *)this + 26);
v49 = nullptr;
v50 = nullptr;
v51 = nullptr;
v52 = nullptr;
v53 = 0;
v43 = 0;
if ( !v3 )
goto LABEL_3;
v3 = cocos2d::CCArray::count((cocos2d::CCArray *)v3);
if ( !(_DWORD)v3 )
goto LABEL_3;
v3 = *((_QWORD *)this + 26);
if ( v3
&& (v9 = *(unsigned int **)(v3 + 56), v3 = *v9, (_DWORD)v3)
&& (v10 = *((unsigned __int64 **)v9 + 2),
v3 = (unsigned __int64)&v10[(unsigned int)v3 - 1],
v41 = v3,
(unsigned __int64)v10 <= v3)
&& (v3 = *v10) != 0 )
{
v5 = 0;
v11 = 0;
v12 = -5;
v13 = -10;
do
{
v14 = _dynamic_cast(
(const void *)v3,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
0);
v15 = v14;
if ( v14 )
{
v16 = *((_DWORD *)v46 + v11);
v17 = (float *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)v14 + 328LL))(v14);
v18 = *v17;
v19 = (float)v43;
if ( *v17 <= (float)v43 || (v20 = __isnanf(v18), v21 = (unsigned int)v18, v20) )
v21 = (unsigned int)v19;
v43 = v21;
++v5;
v12 += (int)(float)(*(float *)((*(__int64 (__fastcall **)(void *))(*(_QWORD *)v15 + 328LL))(v15) + 4) + 5.0);
if ( v16 <= v5 )
{
v22 = v49;
if ( v49 == v50 )
{
std::vector::__push_back_slow_path(&v48, &v43);
}
else
{
if ( v49 )
{
*v49 = v43;
v22 = v49;
}
v49 = v22 + 1;
}
v45 = v12;
v23 = v52;
if ( (unsigned __int64)v52 >= v53 )
{
std::vector::__push_back_slow_path(&v51, &v45);
}
else
{
if ( v52 )
{
*v52 = v12;
v23 = v52;
}
v52 = v23 + 1;
}
v24 = v43;
++v11;
v43 = 0;
v5 = 0;
v12 = -5;
v13 += v24 + 10;
}
}
v3 = v41;
if ( v41 < (unsigned __int64)++v10 )
break;
v3 = *v10;
}
while ( *v10 );
v4 = v13 / -2;
}
else
{
LABEL_3:
v4 = 5;
v5 = 0;
}
v6 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)v3);
cocos2d::CCDirector::getWinSize(&v44, v6);
v43 = 0;
v7 = *((cocos2d::CCArray **)this + 26);
if ( v7 )
{
if ( (unsigned int)cocos2d::CCArray::count(v7) )
{
v25 = *((_QWORD *)this + 26);
if ( v25 )
{
v26 = *(unsigned int **)(v25 + 56);
if ( *v26 )
{
v27 = *((const void ***)v26 + 2);
v42 = &v27[*v26 - 1];
if ( v27 <= v42 )
{
v28 = *v27;
if ( *v27 )
{
v29 = 0.0;
v30 = 0;
v31 = (float)v4;
v32 = 0;
do
{
v33 = _dynamic_cast(
v28,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
0);
if ( v33 )
{
if ( !v30 )
{
v30 = *((_DWORD *)v46 + v32);
v29 = (float)*((unsigned int *)v51 + v32);
}
v34 = (float *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)v33 + 328LL))(v33);
v35 = *v34;
v36 = (float)v43;
if ( *v34 <= (float)v43 || (v37 = __isnanf(v35), v38 = (unsigned int)v35, v37) )
v38 = (unsigned int)v36;
v43 = v38;
++v5;
v39 = *(void (__fastcall **)(void *, int *))(*(_QWORD *)v33 + 184LL);
cocos2d::CCPoint::CCPoint(
(float *)&v45,
(float)(*((_DWORD *)v48 + v32) >> 1) + v31,
v29 - (float)(*((float *)&v44 + 1) * 0.5));
v39(v33, &v45);
v29 = v29
- (float)(*(float *)((*(__int64 (__fastcall **)(void *))(*(_QWORD *)v33 + 328LL))(v33) + 4) + 10.0);
if ( v30 <= v5 )
{
v40 = v43;
++v32;
v43 = 0;
v30 = 0;
v5 = 0;
v31 = v31 + (float)(v40 + 5);
}
}
if ( v42 < ++v27 )
break;
v28 = *v27;
}
while ( *v27 );
}
}
}
}
}
}
if ( v51 )
{
if ( v51 != v52 )
v52 += ~((unsigned __int64)((char *)(v52 - 1) - (_BYTE *)v51) >> 2);
operator delete(v51);
}
if ( v48 )
{
if ( v48 != v49 )
v49 += ~((unsigned __int64)((char *)(v49 - 1) - (_BYTE *)v48) >> 2);
operator delete(v48);
}
if ( v46 )
{
if ( v46 != v47 )
v47 += 4 * ~((unsigned __int64)(v47 - 4 - (_BYTE *)v46) >> 2);
operator delete(v46);
}
return _stack_chk_guard;
}