//
// sub_1002AA3F4 from 0x1002aa3f4 to 0x1002aa53c (328 bytes)
//
// 1 xrefs:
// > sub_1002A9824 @ 0x1002a9e48
//
// 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 11:02:17 +0000
//
__int64 *__fastcall sub_1002AA3F4(__int64 *a1, __int64 *a2, __int64 (__fastcall **a3)(__int64 *, __int64 *))
{
__int64 *v4; // x21
__int64 v6; // x23
__int64 (__fastcall *v7)(__int64 *, __int64 *); // x8
__int64 *v8; // x22
__int64 (__fastcall *v9)(__int64 *, __int64 *); // x8
__int64 v10; // t1
__int64 *v11; // x24
__int64 (__fastcall *v12)(__int64 *, __int64 *); // x8
__int64 (__fastcall *v13)(__int64 *, __int64 *); // x8
__int64 v14; // t1
__int64 v15; // x8
__int64 (__fastcall *v16)(__int64 *, __int64 *); // x8
__int64 v17; // t1
__int64 (__fastcall *v18)(__int64 *, __int64 *); // x8
__int64 v19; // t1
__int64 v21; // [xsp+0h] [xbp-40h] BYREF
__int64 v22; // [xsp+8h] [xbp-38h] BYREF
v4 = a2;
v6 = *a1;
v7 = *a3;
v21 = *(a2 - 1);
v22 = v6;
if ( (v7(&v22, &v21) & 1) != 0 )
{
v8 = a1;
do
{
v9 = *a3;
v10 = v8[1];
++v8;
v21 = v10;
v22 = v6;
}
while ( (v9(&v22, &v21) & 1) == 0 );
}
else
{
v11 = a1 + 1;
do
{
v8 = v11;
if ( v11 >= v4 )
break;
v12 = *a3;
++v11;
v21 = *v8;
v22 = v6;
}
while ( (v12(&v22, &v21) & 1) == 0 );
}
if ( v8 < v4 )
{
do
{
v13 = *a3;
v14 = *--v4;
v21 = v14;
v22 = v6;
}
while ( (v13(&v22, &v21) & 1) != 0 );
}
while ( v8 < v4 )
{
v15 = *v8;
*v8 = *v4;
*v4 = v15;
do
{
v16 = *a3;
v17 = v8[1];
++v8;
v21 = v17;
v22 = v6;
}
while ( !(unsigned int)v16(&v22, &v21) );
do
{
v18 = *a3;
v22 = v6;
v19 = *--v4;
v21 = v19;
}
while ( (v18(&v22, &v21) & 1) != 0 );
}
if ( v8 - 1 != a1 )
*a1 = *(v8 - 1);
*(v8 - 1) = v6;
return v8;
}