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