//
// sub_65BAC8 from 0x65bac8 to 0x65bba0 (216 bytes)
//
// 2 xrefs:
// > hashRemapMap @ 0x6639f4
// > hashRemapMap @ 0x663b18
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
_DWORD *__fastcall sub_65BAC8(_DWORD *result, _DWORD *a2)
{
char *v2; // x7
_DWORD *v3; // x8
int v4; // w6
int v5; // w9
__int64 v6; // x3
_DWORD *v7; // x2
int v8; // w4
_DWORD *v9; // x3
int v10; // w3
char *v11; // x2
int v12; // w9
if ( result != a2 )
{
v2 = (char *)(result + 2);
if ( a2 != result + 2 )
{
v3 = result + 4;
do
{
v4 = *(_DWORD *)v2;
if ( *(_DWORD *)v2 >= *result )
{
v10 = *((_DWORD *)v2 - 2);
v11 = v2 - 8;
v12 = *((_DWORD *)v2 + 1);
if ( v4 < v10 )
{
while ( 1 )
{
*((_DWORD *)v11 + 2) = v10;
v10 = *((_DWORD *)v11 - 2);
*((_DWORD *)v11 + 3) = *((_DWORD *)v11 + 1);
if ( v4 >= v10 )
break;
v11 -= 8;
}
*(_DWORD *)v11 = v4;
v9 = v3;
*((_DWORD *)v11 + 1) = v12;
}
else
{
v9 = v3;
*(_DWORD *)v2 = v4;
*((_DWORD *)v2 + 1) = v12;
}
}
else
{
v5 = *((_DWORD *)v2 + 1);
v6 = (v2 - (char *)result) >> 3;
v7 = v3;
if ( v6 > 0 )
{
do
{
v7 -= 2;
v8 = *(v7 - 1);
--v6;
*v7 = *(v7 - 2);
v7[1] = v8;
}
while ( v6 );
}
*result = v4;
v9 = v3;
result[1] = v5;
}
v3 += 2;
v2 += 8;
}
while ( a2 != v9 );
}
}
return result;
}