//
// ThreadViewPopup::sortMessagesByID from 0xc83928 to 0xc83b7c (596 bytes)
//
// 2 xrefs:
// > ThreadViewPopup::threadMessagesFinished @ 0xc8ab78
// > ??> @ 0xb4250
//
// 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:05:40 +0000
//
__int64 __fastcall ThreadViewPopup::sortMessagesByID(cocos2d::CCArray **this)
{
signed int v2; // w19
unsigned __int8 (__fastcall *v3)(__int64, __int64); // x0
char *v4; // x1
_BYTE *v5; // x25
char *v6; // x24
__int64 v7; // x19
__int64 *v8; // x21
cocos2d::CCArray *v9; // x0
cocos2d::CCArray *v10; // x21
cocos2d::CCObject **v11; // x1
unsigned __int64 i; // x19
signed int j; // w19
cocos2d::CCArray *v14; // x23
cocos2d::CCObject *v15; // x0
bool (__fastcall *v17)(__int64, __int64); // [xsp+58h] [xbp+58h] BYREF
void *v18; // [xsp+60h] [xbp+60h] BYREF
char *v19; // [xsp+68h] [xbp+68h]
unsigned __int64 v20; // [xsp+70h] [xbp+70h]
v18 = nullptr;
v2 = 0;
v19 = nullptr;
v20 = 0;
while ( v2 < (int)cocos2d::CCArray::count(*(this + 95)) )
{
v3 = (unsigned __int8 (__fastcall *)(__int64, __int64))cocos2d::CCArray::objectAtIndex(*(this + 95), v2);
v4 = v19;
v17 = (bool (__fastcall *)(__int64, __int64))v3;
if ( (unsigned __int64)v19 >= v20 )
{
std::vector::__push_back_slow_path((__int64)&v18, &v17);
++v2;
}
else
{
if ( v19 )
{
*(_QWORD *)v19 = v3;
v4 = v19;
}
++v2;
v19 = v4 + 8;
}
}
v5 = v18;
v6 = v19;
v17 = sub_C616E8;
if ( (v19 - (_BYTE *)v18) >> 3 > 128 )
{
v7 = (v19 - (_BYTE *)v18) >> 3;
while ( 1 )
{
v8 = (__int64 *)operator new(8 * v7, (const std::nothrow_t *)&std::nothrow);
if ( v8 )
break;
v7 >>= 1;
if ( v7 <= 0 )
{
v7 = 0;
break;
}
}
}
else
{
v7 = 0;
v8 = nullptr;
}
v9 = (cocos2d::CCArray *)std::__stable_sort>(
(unsigned __int64)v5,
v6,
(unsigned __int8 (__fastcall **)(__int64, __int64))&v17,
(v6 - v5) >> 3,
v8,
v7);
if ( v8 )
operator delete(v8);
v10 = (cocos2d::CCArray *)cocos2d::CCArray::create(v9);
v11 = (cocos2d::CCObject **)v18;
for ( i = 0; i < (v19 - (_BYTE *)v18) >> 3; ++i )
{
cocos2d::CCArray::addObject(v10, v11[i]);
v11 = (cocos2d::CCObject **)v18;
}
cocos2d::CCArray::removeAllObjects(*(this + 95));
for ( j = 0; j < (int)cocos2d::CCArray::count(v10); ++j )
{
v14 = *(this + 95);
v15 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(v10, j);
cocos2d::CCArray::addObject(v14, v15);
}
if ( v18 )
{
if ( v18 != v19 )
v19 += 8 * ~((unsigned __int64)(v19 - 8 - (_BYTE *)v18) >> 3);
operator delete(v18);
}
return _stack_chk_guard;
}