//
// std::__ndk1::__buffered_inplace_merge std::__ndk1::__inplace_merge ??> @ 0x55258
//
// 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:31 +0000
//
unsigned __int64 __fastcall std::__buffered_inplace_merge(
unsigned __int64 *a1,
unsigned __int64 *a2,
unsigned __int64 *a3,
unsigned __int8 (__fastcall **a4)(unsigned __int64, unsigned __int64, __int64),
__int64 a5,
__int64 a6,
unsigned __int64 *a7)
{
unsigned __int64 *v7; // x23
unsigned __int64 *v8; // x19
unsigned __int64 *v9; // x21
unsigned __int64 *v11; // x20
unsigned __int64 result; // x0
__int64 v13; // x2
char *v14; // x22
unsigned __int64 v15; // t1
unsigned __int64 v16; // t1
bool v17; // zf
unsigned __int64 *v18; // x1
__int64 v19; // x2
unsigned __int64 *v20; // x22
unsigned __int8 (__fastcall *v21)(unsigned __int64, unsigned __int64, __int64); // x25
char *v22; // x24
unsigned __int64 v23; // t1
unsigned __int64 v24; // t1
char *v25; // x3
char *v26; // x2
char *v27; // x1
unsigned __int64 v28; // x0
unsigned __int64 v29; // x5
unsigned __int64 v30; // x20
__int128 v31; // q0
char *v32; // x22
unsigned __int64 *v33; // x21
unsigned __int64 *v34; // x21
char *v35; // x22
char *v36; // x3
v7 = a1;
v8 = a2;
v9 = a3;
v11 = a7;
if ( a5 <= a6 )
{
v17 = a1 == a2;
v18 = a1;
result = (unsigned __int64)a7;
if ( !v17 )
{
do
{
v19 = *v18++;
if ( result )
*(_QWORD *)result = v19;
result += 8LL;
}
while ( v8 != v18 );
v20 = v7 + 1;
v21 = *a4;
v22 = (char *)a7 + (((char *)v8 - (char *)(v7 + 1)) & 0xFFFFFFFFFFFFFFF8LL) + 8;
if ( a7 != (unsigned __int64 *)v22 )
{
if ( v8 == v9 )
{
LABEL_35:
result = (v22 - (char *)v11) >> 3;
if ( result )
return (unsigned __int64)memmove(v7, v11, v22 - (char *)v11);
}
else
{
while ( 1 )
{
if ( v21(*v8, *v11, v19) )
{
v23 = *v8++;
result = v23;
}
else
{
v24 = *v11++;
result = v24;
}
*v7 = result;
v7 = v20++;
if ( v22 == (char *)v11 )
break;
if ( v9 == v8 )
goto LABEL_35;
}
}
}
}
}
else
{
result = (unsigned __int64)a7;
if ( a2 != a3 )
{
do
{
v13 = *a2++;
if ( result )
*(_QWORD *)result = v13;
result += 8LL;
}
while ( v9 != a2 );
v14 = (char *)a7 + (((char *)v9 - (char *)(v8 + 1)) & 0xFFFFFFFFFFFFFFF8LL) + 8;
if ( a7 != (unsigned __int64 *)v14 )
{
while ( v7 != v8 )
{
if ( ((unsigned __int8 (__fastcall *)(_QWORD, _QWORD))*a4)(*(v8 - 1), *((_QWORD *)v14 - 1)) )
{
v16 = *((_QWORD *)v14 - 1);
v14 -= 8;
result = v16;
*--v9 = v16;
if ( v11 == (unsigned __int64 *)v14 )
return result;
}
else
{
v15 = *--v8;
result = v15;
*--v9 = v15;
if ( v11 == (unsigned __int64 *)v14 )
return result;
}
}
v25 = v14 - 8;
v26 = v14 - 16;
v27 = (char *)(v9 - 2);
v28 = (unsigned __int64)(v14 - 8 - (char *)v11) >> 3;
v29 = v28 + 1;
if ( v28 + 1 > 0xA && (v14 <= v27 || v9 <= (unsigned __int64 *)v26) )
{
v30 = ((v28 - 1) >> 1) + 1;
result = 0;
do
{
v31 = *(_OWORD *)v26;
++result;
v26 -= 16;
*(_OWORD *)v27 = v31;
v27 -= 16;
}
while ( result < v30 );
v32 = &v14[-16 * v30];
v33 = &v9[-2 * v30];
if ( 2 * v30 != v29 )
{
result = *((_QWORD *)v32 - 1);
*(v33 - 1) = result;
}
}
else
{
do
{
result = *((_QWORD *)v14 - 1);
v17 = v11 == (unsigned __int64 *)v25;
*(v9 - 1) = result;
v34 = v9 - 1;
v35 = v25;
v36 = v25 - 8;
if ( v17 )
break;
result = *((_QWORD *)v35 - 1);
v17 = v11 == (unsigned __int64 *)v36;
*(v34 - 1) = result;
v9 = v34 - 1;
v14 = v36;
v25 = v36 - 8;
}
while ( !v17 );
}
}
}
}
return result;
}