//
// cocos2d::CCMenu::alignItemsInColumnsWithArray from 0x180058340 to 0x18005874a (1034 bytes)
//
// 3 xrefs:
// > cocos2d::CCMenu::alignItemsInColumns @ 0x180058304
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b2a48
//
// 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
//
// Hidden C++ exception states: #wind=1
void __fastcall cocos2d::CCMenu::alignItemsInColumnsWithArray(cocos2d::CCMenu *this, struct cocos2d::CCArray *a2)
{
_BYTE *v3; // rdi
cocos2d::ccArray *data; // rbx
__int64 num; // rax
cocos2d::CCObject **arr; // rbx
cocos2d::CCObject **v7; // rsi
_BYTE *v8; // rdx
int v9; // ecx
int v10; // r15d
__int64 v11; // r14
int v12; // ebp
unsigned int v13; // esi
cocos2d::CCArray *m_pChildren; // rcx
char *v15; // r13
cocos2d::CCArray *v16; // rax
cocos2d::ccArray *v17; // rbx
__int64 v18; // rax
cocos2d::CCObject **v19; // rbx
__int64 v20; // rax
unsigned int v21; // r12d
float v22; // xmm6_4
cocos2d::CCDirector *v23; // rax
int v24; // ebx
int v25; // r12d
unsigned int v26; // ebp
float v27; // xmm7_4
float v28; // xmm10_4
float v29; // xmm9_4
cocos2d::CCArray *v30; // rcx
cocos2d::CCArray *v31; // rax
cocos2d::ccArray *v32; // r14
__int64 v33; // rax
cocos2d::CCObject **v34; // r14
__int64 v35; // rax
__int64 v36; // r15
float v37; // xmm6_4
__int64 v38; // rbx
__int64 v39; // rax
float *v40; // rax
char *v41; // rax
float v42; // [rsp+30h] [rbp-C8h] BYREF
void *Block[2]; // [rsp+38h] [rbp-C0h] BYREF
_BYTE *v44; // [rsp+48h] [rbp-B0h]
cocos2d::CCObject **j; // [rsp+100h] [rbp+8h]
cocos2d::CCObject **i; // [rsp+108h] [rbp+10h] BYREF
int v48; // [rsp+110h] [rbp+18h]
float v49; // [rsp+118h] [rbp+20h]
*(_OWORD *)Block = 0;
v3 = nullptr;
v44 = nullptr;
v48 = 1;
if ( a2 )
{
data = a2->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v7 = &arr[num - 1];
if ( arr <= v7 )
{
v8 = Block[1];
do
{
if ( !*arr )
break;
v9 = (int)(*arr)[1].__vftable;
LODWORD(i) = v9;
if ( v8 == v3 )
{
sub_180030780((const void **)Block, v8, &i);
v3 = v44;
v8 = Block[1];
}
else
{
*(_DWORD *)v8 = v9;
v8 += 4;
Block[1] = v8;
}
++arr;
}
while ( arr <= v7 );
}
}
}
v10 = -5;
v11 = 0;
v12 = 0;
v13 = 0;
m_pChildren = this->m_pChildren;
v15 = (char *)Block[0];
if ( m_pChildren )
{
if ( (unsigned int)cocos2d::CCArray::count(m_pChildren) )
{
v16 = this->m_pChildren;
if ( v16 )
{
v17 = v16->data;
v18 = v17->num;
if ( (_DWORD)v18 )
{
v19 = v17->arr;
for ( i = &v19[v18 - 1]; v19 <= i; ++v19 )
{
if ( !*v19 )
break;
v20 = _RTDynamicCast(
*v19,
0,
&cocos2d::CCObject `RTTI Type Descriptor',
&cocos2d::CCNode `RTTI Type Descriptor',
0);
if ( v20 )
{
v21 = *(_DWORD *)&v15[4 * v11];
v22 = *(float *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v20 + 304LL))(v20) + 4);
if ( (float)v12 >= v22 || isnan(v22) )
v22 = (float)v12;
v12 = (int)v22;
if ( ++v13 >= v21 )
{
v10 += v12 + 5;
v13 = 0;
v12 = 0;
v11 = (unsigned int)(v11 + 1);
}
}
}
}
}
}
}
v23 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v23);
v24 = 0;
LODWORD(i) = 0;
v25 = 0;
v26 = 0;
v27 = 0.0;
v28 = 0.0;
v29 = (float)(v10 / 2);
v30 = this->m_pChildren;
if ( v30 )
{
if ( (unsigned int)cocos2d::CCArray::count(v30) )
{
v31 = this->m_pChildren;
if ( v31 )
{
v32 = v31->data;
v33 = v32->num;
if ( (_DWORD)v33 )
{
v34 = v32->arr;
for ( j = &v34[v33 - 1]; v34 <= j; ++v34 )
{
if ( !*v34 )
break;
v35 = _RTDynamicCast(
*v34,
0,
&cocos2d::CCObject `RTTI Type Descriptor',
&cocos2d::CCNode `RTTI Type Descriptor',
0);
v36 = v35;
if ( v35 )
{
if ( !v26 )
{
v26 = *(_DWORD *)&v15[4 * v24];
v27 = v49 / (float)(int)(v26 + 1);
v28 = v27;
}
v37 = *(float *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v35 + 304LL))(v35) + 4);
if ( (float)v25 >= v37 || isnan(v37) )
v37 = (float)v25;
v25 = (int)v37;
v38 = *(_QWORD *)v36;
v39 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v36 + 304LL))(v36);
v40 = kmVec2Fill(&v42, v28 - (float)(v49 * 0.5), v29 - (float)(*(float *)(v39 + 4) * 0.5));
(*(void (__fastcall **)(__int64, float *))(v38 + 184))(v36, v40);
v28 = v28 + v27;
++v13;
v24 = (int)i;
if ( v13 >= v26 )
{
v29 = v29 - (float)(v25 + 5);
v13 = 0;
v26 = 0;
v25 = 0;
v24 = (_DWORD)i + 1;
LODWORD(i) = (_DWORD)i + 1;
}
}
}
}
}
}
}
if ( v15 )
{
v41 = v15;
if ( ((v3 - v15) & 0xFFFFFFFFFFFFFFFCuLL) >= 0x1000 )
{
v15 = *((char **)v15 - 1);
if ( (unsigned __int64)(v41 - v15 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v15);
}
}