//
// FriendsProfilePage::filterUsersWithQuery from 0xa52374 to 0xa52634 (704 bytes)
//
// 6 xrefs:
// > FriendsProfilePage::onToggleSort @ 0xa52678
// > FriendsProfilePage::onToggleSortDir @ 0xa5270c
// > FriendsProfilePage::getUserListFinished @ 0xa52974
// > FriendsProfilePage::textChanged @ 0xa52a88
// > FriendsProfilePage::onClearSearch @ 0xa52c28
// > ??> @ 0x71ed8
//
// 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:00:05 +0000
//
__int64 __fastcall FriendsProfilePage::filterUsersWithQuery(__int64 a1, __int64 a2)
{
cocos2d::CCObject *v4; // x0
cocos2d::CCArray *v5; // x0
__int64 v7; // x1
__int64 *v8; // x0
cocos2d::CCObject *v9; // x0
__int64 v10; // x0
unsigned int *v11; // x1
__int64 *v12; // x21
__int64 *v13; // x25
__int64 i; // x22
char v15; // w0
__int64 v16; // x0
__int64 v17; // x1
int v18; // w3
char *v19; // x7
__int64 v20; // x1
unsigned __int8 *v21; // x8
__int64 v22; // x0
char *v23; // x1
char *v24; // x11
char *v25; // x9
unsigned __int8 *v26; // x0
char *v27; // x10
char *v28; // x12
unsigned __int8 *v29; // x2
char *v30; // x4
int v31; // t1
__int64 v32[2]; // [xsp+60h] [xbp+60h] BYREF
void *v33; // [xsp+70h] [xbp+70h]
__int64 v34[2]; // [xsp+78h] [xbp+78h] BYREF
void *v35; // [xsp+88h] [xbp+88h]
__int64 v36; // [xsp+90h] [xbp+90h] BYREF
__int64 v37; // [xsp+98h] [xbp+98h]
void *v38; // [xsp+A0h] [xbp+A0h]
v4 = *(cocos2d::CCObject **)(a1 + 864);
if ( v4 )
{
cocos2d::CCObject::release(v4);
*(_QWORD *)(a1 + 864) = 0;
}
v5 = *(cocos2d::CCArray **)(a1 + 856);
if ( v5 && (unsigned int)cocos2d::CCArray::count(v5) )
{
v7 = *(_BYTE *)a2 >> 1;
if ( (*(_BYTE *)a2 & 1) != 0 )
v7 = *(_QWORD *)(a2 + 8);
if ( v7 )
{
v8 = sub_A517F8(a2, v32);
v9 = (cocos2d::CCObject *)cocos2d::CCArray::create((cocos2d::CCArray *)v8);
*(_QWORD *)(a1 + 864) = v9;
cocos2d::CCObject::retain(v9);
v10 = *(_QWORD *)(a1 + 856);
if ( v10 )
{
v11 = *(unsigned int **)(v10 + 56);
if ( *v11 )
{
v12 = *((__int64 **)v11 + 2);
v13 = &v12[*v11 - 1];
if ( v12 <= v13 )
{
for ( i = *v12; *v12; i = *v12 )
{
v15 = *(_BYTE *)(i + 320);
v36 = 0;
v37 = 0;
v38 = nullptr;
if ( (v15 & 1) != 0 )
{
std::string::__init(&v36, *(void **)(i + 336), *(_QWORD *)(i + 328));
}
else
{
v16 = *(_QWORD *)(i + 320);
v17 = *(_QWORD *)(i + 328);
v38 = *(void **)(i + 336);
v36 = v16;
v37 = v17;
}
sub_A517F8((__int64)&v36, v34);
if ( (v36 & 1) != 0 )
operator delete(v38);
v18 = v34[0] & 1;
if ( (v34[0] & 1) != 0 )
{
v19 = (char *)v35;
v20 = v34[1];
}
else
{
v20 = LOBYTE(v34[0]) >> 1;
v19 = (char *)v34 + 1;
}
if ( (v32[0] & 1) != 0 )
{
v21 = (unsigned __int8 *)v33;
v22 = v32[1];
}
else
{
v22 = LOBYTE(v32[0]) >> 1;
v21 = (unsigned __int8 *)v32 + 1;
}
if ( v20 >= (unsigned __int64)v22 )
{
if ( !v22 )
goto LABEL_23;
if ( v22 <= v20 )
{
v23 = &v19[v20];
v24 = &v23[1 - v22];
if ( v24 != v19 )
{
v25 = v19 + 1;
v26 = &v21[v22];
while ( 1 )
{
v27 = v25 - 1;
v28 = v25;
if ( (unsigned __int8)*(v25 - 1) == *v21 )
break;
LABEL_43:
++v25;
if ( v28 == v24 )
goto LABEL_24;
}
v29 = v21;
v30 = v25 - 1;
while ( ++v29 != v26 )
{
v31 = (unsigned __int8)*++v30;
if ( v31 != *v29 )
goto LABEL_43;
}
if ( v23 != v27 && v27 - v19 != -1 )
{
LABEL_23:
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 864), (cocos2d::CCObject *)i);
v18 = v34[0] & 1;
}
}
}
}
LABEL_24:
if ( v18 )
operator delete(v35);
if ( v13 < ++v12 )
break;
}
}
}
}
if ( (v32[0] & 1) != 0 )
operator delete(v33);
}
}
return _stack_chk_guard;
}