//
// std::__ndk1::__stable_sort_move std::__ndk1::__stable_sort std::__ndk1::__stable_sort ??> @ 0xd9678
//
// 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
//
// write access to const memory has been detected, the output may be wrong!
unsigned __int64 __fastcall std::__stable_sort_move>(
unsigned __int64 result,
char *a2,
unsigned __int8 (__fastcall **a3)(__int64, __int64),
__int64 a4,
__int64 *a5)
{
unsigned __int64 *v6; // x21
__int64 *v9; // x22
unsigned __int64 *v10; // x19
__int64 *v11; // x21
__int64 *i; // x24
__int64 *v13; // x19
__int64 *v14; // x20
__int64 v15; // x26
__int64 v16; // x27
unsigned __int64 v17; // x24
v6 = (unsigned __int64 *)result;
v9 = a5;
v10 = (unsigned __int64 *)result;
switch ( a4 )
{
case 1LL:
result = *(_QWORD *)result;
if ( a5 )
*a5 = result;
break;
case 2LL:
result = (*a3)(*((_QWORD *)a2 - 1), *(_QWORD *)result);
if ( (_BYTE)result )
{
if ( v9 )
{
*v9 = *((_QWORD *)a2 - 1);
result = (unsigned __int64)(v9 + 1);
if ( v9 != (__int64 *)-8LL )
v9[1] = *v6;
}
else
{
*(_QWORD *)byte_8 = *v6;
}
}
else if ( v9 )
{
*v9 = *v6;
result = (unsigned __int64)(v9 + 1);
if ( v9 != (__int64 *)-8LL )
v9[1] = *((_QWORD *)a2 - 1);
}
else
{
*(_QWORD *)byte_8 = *((_QWORD *)a2 - 1);
}
break;
case 0LL:
return result;
default:
if ( a4 > 8 )
{
v15 = a4 >> 1;
v16 = 8 * (a4 >> 1);
v17 = result + v16;
std::__stable_sort>(
result,
(char *)(result + v16),
a3,
v15,
a5,
v15);
result = std::__stable_sort>(
v17,
a2,
a3,
a4 - v15,
&v9[(unsigned __int64)v16 / 8],
a4 - v15);
if ( v6 != (unsigned __int64 *)v17 )
{
if ( a2 == (char *)v17 )
{
do
{
LABEL_36:
result = *v10++;
if ( v9 )
*v9 = result;
++v9;
}
while ( (unsigned __int64 *)v17 != v10 );
return result;
}
v6 = (unsigned __int64 *)v17;
while ( 1 )
{
if ( (*a3)(*v6, *v10) )
{
result = *v6;
if ( v9 )
*v9 = result;
++v6;
}
else
{
result = *v10++;
if ( v9 )
*v9 = result;
}
++v9;
if ( (unsigned __int64 *)v17 == v10 )
break;
if ( a2 == (char *)v6 )
goto LABEL_36;
}
}
for ( ; a2 != (char *)v6; ++v9 )
{
result = *v6++;
if ( v9 )
*v9 = result;
}
}
else if ( (char *)result != a2 )
{
result = *(_QWORD *)result;
if ( a5 )
*a5 = result;
v11 = (__int64 *)(v6 + 1);
for ( i = a5; a2 != (char *)v11; ++i )
{
v13 = i;
if ( (*a3)(*v11, *i) )
{
i[1] = *i;
if ( v9 != i )
{
while ( 1 )
{
v14 = v13 - 1;
if ( !(*a3)(*v11, *(v13 - 1)) )
break;
*v13 = *(v13 - 1);
--v13;
if ( v9 == v14 )
{
v13 = v9;
break;
}
}
}
result = *v11;
*v13 = *v11;
}
else
{
result = *v11;
i[1] = *v11;
}
++v11;
}
}
break;
}
return result;
}