//
// GJBaseGameLayer::sortGroups from 0x5a9798 to 0x5a9a04 (620 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::updateSpecialGroupData @ 0x5c1508
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:53:23 +0000
//
int __fastcall GJBaseGameLayer::sortGroups(GJBaseGameLayer *this)
{
int v2; // r2
int v3; // r3
_DWORD *v4; // r3
_BYTE *v5; // r10
_DWORD *v6; // r8
_DWORD *v7; // r3
_DWORD *v8; // t1
_DWORD *i; // r4
size_t **Group; // r5
int v12; // r2
unsigned int v13; // r7
unsigned int v14; // r4
unsigned int v15; // r11
int v16; // r5
_DWORD *v17; // r3
unsigned int v18; // r0
int v19; // r1
float v20; // s15
bool v21; // r5
unsigned int v22; // r5
unsigned int v23; // r1
_DWORD *v24; // r3
unsigned int v25; // r0
int v26; // r1
_DWORD *v27; // r2
int v28; // [sp+4h] [bp-40h]
_DWORD *v29; // [sp+8h] [bp-3Ch]
unsigned int v30; // [sp+18h] [bp-2Ch] BYREF
void *v31[3]; // [sp+1Ch] [bp-28h] BYREF
int v32; // [sp+28h] [bp-1Ch] BYREF
unsigned int v33; // [sp+2Ch] [bp-18h]
_DWORD *v34; // [sp+30h] [bp-14h] BYREF
int v35; // [sp+34h] [bp-10h]
float v36; // [sp+38h] [bp-Ch]
v32 = 0;
v33 = 0;
v34 = nullptr;
v35 = 0;
v36 = 1.0;
v2 = *((_DWORD *)this + 521);
if ( v2 )
v28 = *(unsigned __int8 *)(v2 + 374);
else
v28 = 0;
v3 = *((_DWORD *)this + 522);
if ( v3 )
{
v4 = *(_DWORD **)(v3 + 52);
if ( *v4 )
{
v5 = (char *)this + 10612;
v6 = (_DWORD *)v4[3];
v29 = &v6[*v4 - 1];
while ( 1 )
{
do
{
while ( 1 )
{
LABEL_9:
if ( v6 > v29 )
goto LABEL_5;
v8 = (_DWORD *)*v6++;
v7 = v8;
if ( !v8 )
goto LABEL_5;
v12 = v7[223];
if ( v12 == 1268 )
break;
if ( v12 == 3607 && !*v5 )
{
v27 = *((_DWORD **)this + 2694);
v31[0] = v7;
if ( (unsigned int)v27 >= *((_DWORD *)this + 2695) )
{
std::vector::__push_back_slow_path(
(int)this + 10772,
v31);
}
else
{
if ( v27 )
*v27 = v7;
*((_DWORD *)this + 2694) += 4;
}
}
}
}
while ( v28 );
v13 = v7[321];
v14 = v33;
v30 = v13;
if ( v33 )
{
v15 = v33 - 1;
if ( ((v33 - 1) & v33) != 0 )
v16 = v13 % v33;
else
v16 = v13 & v15;
v17 = *(_DWORD **)(v32 + 4 * v16);
if ( v17 )
{
while ( 1 )
{
v17 = (_DWORD *)*v17;
if ( !v17 )
break;
v18 = v17[1];
v19 = ((v33 - 1) & v33) != 0 ? v18 % v33 : v15 & v18;
if ( v19 != v16 )
break;
if ( v17[2] == v13 )
goto LABEL_9;
}
}
}
else
{
v16 = 0;
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)v31,
(int)&v32,
v13,
&v30);
v20 = (float)(unsigned int)(v35 + 1);
if ( v20 > (float)((float)v14 * v36) )
{
v21 = v14 > 2 && ((v14 - 1) & v14) == 0;
}
else
{
if ( v14 )
goto LABEL_40;
v21 = 0;
}
v22 = 2 * v14 + !v21;
v23 = (unsigned int)ceilf(v20 / v36);
if ( v23 < v22 )
v23 = v22;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)&v32, v23);
v14 = v33;
if ( ((v33 - 1) & v33) != 0 )
v16 = v13 % v33;
else
v16 = (v33 - 1) & v13;
LABEL_40:
v24 = *(_DWORD **)(v32 + 4 * v16);
if ( v24 )
{
*(_DWORD *)v31[0] = *v24;
*v24 = v31[0];
}
else
{
*(_DWORD *)v31[0] = v34;
v34 = v31[0];
*(_DWORD *)(v32 + 4 * v16) = &v34;
if ( *(_DWORD *)v31[0] )
{
v25 = *(_DWORD *)(*(_DWORD *)v31[0] + 4);
if ( ((v14 - 1) & v14) != 0 )
v26 = v25 % v14;
else
v26 = (v14 - 1) & v25;
*(void **)(v32 + 4 * v26) = v31[0];
}
}
++v35;
}
}
}
LABEL_5:
if ( v28 )
{
GJBaseGameLayer::sortAllGroupsX(this);
}
else
{
for ( i = v34; i; i = (_DWORD *)*i )
{
Group = (size_t **)GJBaseGameLayer::getGroup(this, i[2]);
if ( cocos2d::CCArray::count((cocos2d::CCArray *)Group) > 1u )
qsort((void *)Group[13][3], *Group[13], 4u, (int (*)(const void *, const void *))xCompPosition);
}
}
return std::__hash_table,std::equal_to,std::allocator>::~__hash_table((int)&v32);
}