//
// ThreadViewPopup::sortMessagesByID from 0x75a1d8 to 0x75a31c (324 bytes)
//
// 1 xrefs:
// > ThreadViewPopup::threadMessagesFinished @ 0x75eb0a
//
// 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:58:58 +0000
//
void __fastcall ThreadViewPopup::sortMessagesByID(cocos2d::CCArray **this)
{
signed int v2; // r4
bool (__fastcall *v3)(int, int); // r0
char *v4; // r10
char *v5; // r9
int v6; // r7
int v7; // r5
char *v8; // r0
char *v9; // r4
char *v10; // r0
cocos2d::CCArray *v11; // r5
unsigned int i; // r4
signed int j; // r4
cocos2d::CCArray *v14; // r7
cocos2d::CCObject *v15; // r0
bool (__fastcall *v16)(int, int); // [sp+Ch] [bp+0h] BYREF
void *v17; // [sp+10h] [bp+4h] BYREF
char *v18; // [sp+14h] [bp+8h]
unsigned int v19; // [sp+18h] [bp+Ch]
v2 = 0;
v17 = nullptr;
v18 = nullptr;
v19 = 0;
while ( v2 < cocos2d::CCArray::count(*(this + 142)) )
{
v3 = (bool (__fastcall *)(int, int))cocos2d::CCArray::objectAtIndex(*(this + 142), v2);
v16 = v3;
if ( (unsigned int)v18 >= v19 )
{
std::vector::__push_back_slow_path((int)&v17, &v16);
}
else
{
if ( v18 )
*(_DWORD *)v18 = v3;
v18 += 4;
}
++v2;
}
v4 = (char *)v17;
v5 = v18;
v16 = sub_745016;
v6 = (v18 - (_BYTE *)v17) >> 2;
if ( v6 <= 128 )
{
v7 = 0;
LABEL_16:
v9 = nullptr;
}
else
{
v7 = (v18 - (_BYTE *)v17) >> 2;
while ( 1 )
{
v8 = (char *)operator new(4 * v7, (const std::nothrow_t *)&std::nothrow);
if ( v8 )
break;
v7 >>= 1;
if ( v7 <= 0 )
{
v7 = 0;
goto LABEL_16;
}
}
v9 = v8;
}
v10 = std::__stable_sort>(
v4,
v5,
(int (__fastcall **)(int, _DWORD))&v16,
v6,
v9,
v7);
if ( v9 )
operator delete(v9);
v11 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)v10);
for ( i = 0; i < (v18 - (_BYTE *)v17) >> 2; ++i )
cocos2d::CCArray::addObject(v11, *((cocos2d::CCObject **)v17 + i));
cocos2d::CCArray::removeAllObjects(*(this + 142));
for ( j = 0; j < cocos2d::CCArray::count(v11); ++j )
{
v14 = *(this + 142);
v15 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(v11, j);
cocos2d::CCArray::addObject(v14, v15);
}
if ( v17 )
{
v18 -= 4 * ((unsigned int)(v18 - (_BYTE *)v17) >> 2);
operator delete(v17);
}
}