//
// sub_14017A730 from 0x14017a730 to 0x14017a89a (362 bytes)
//
// 2 xrefs:
// > sub_14017A300 @ 0x14017a358
// > ??> @ 0x1406cb2a4
//
// 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
//
char **__fastcall sub_14017A730(char **a1, char *a2, char *a3)
{
char *v6; // rdx
char *v7; // r9
int v8; // ecx
int v9; // eax
char *v10; // r8
int v11; // ecx
char *v12; // r8
char *v13; // r10
int v14; // ecx
int v15; // eax
bool v16; // zf
char *v17; // rcx
int v18; // r11d
int v19; // eax
int v20; // ecx
int v21; // ecx
int v22; // ecx
int v23; // eax
int v24; // ecx
int v25; // ecx
sub_14017A8A0(a2, &a2[4 * ((a3 - a2) >> 3)], a3 - 4);
v7 = v6 + 4;
if ( a2 < v6 )
{
v8 = *(_DWORD *)v6;
do
{
v9 = *((_DWORD *)v6 - 1);
v10 = v6 - 4;
if ( v9 < v8 )
break;
if ( v9 > v8 )
break;
v6 -= 4;
v8 = v9;
}
while ( a2 < v10 );
}
if ( v7 < a3 )
{
v11 = *(_DWORD *)v6;
do
{
if ( *(_DWORD *)v7 < v11 )
break;
if ( *(_DWORD *)v7 > v11 )
break;
v7 += 4;
}
while ( v7 < a3 );
}
v12 = v7;
v13 = v6;
while ( 1 )
{
while ( 1 )
{
for ( ; v12 < a3; v12 += 4 )
{
v14 = *(_DWORD *)v12;
if ( *(_DWORD *)v6 >= *(_DWORD *)v12 )
{
if ( *(_DWORD *)v6 > v14 )
break;
if ( v7 != v12 )
{
v15 = *(_DWORD *)v7;
*(_DWORD *)v7 = v14;
*(_DWORD *)v12 = v15;
}
v7 += 4;
}
}
v16 = v13 == a2;
if ( v13 > a2 )
{
v17 = v13 - 4;
do
{
v18 = *(_DWORD *)v17;
if ( *(_DWORD *)v17 >= *(_DWORD *)v6 )
{
if ( v18 > *(_DWORD *)v6 )
break;
v6 -= 4;
if ( v6 != v17 )
{
v19 = *(_DWORD *)v6;
*(_DWORD *)v6 = v18;
*(_DWORD *)v17 = v19;
}
}
v13 -= 4;
v17 -= 4;
}
while ( a2 < v13 );
v16 = v13 == a2;
}
if ( v16 )
break;
v13 -= 4;
if ( v12 == a3 )
{
v6 -= 4;
if ( v13 != v6 )
{
v22 = *(_DWORD *)v13;
*(_DWORD *)v13 = *(_DWORD *)v6;
*(_DWORD *)v6 = v22;
}
v23 = *((_DWORD *)v7 - 1);
v7 -= 4;
v24 = *(_DWORD *)v6;
*(_DWORD *)v6 = v23;
*(_DWORD *)v7 = v24;
}
else
{
v25 = *(_DWORD *)v12;
*(_DWORD *)v12 = *(_DWORD *)v13;
v12 += 4;
*(_DWORD *)v13 = v25;
}
}
if ( v12 == a3 )
break;
if ( v7 != v12 )
{
v20 = *(_DWORD *)v6;
*(_DWORD *)v6 = *(_DWORD *)v7;
*(_DWORD *)v7 = v20;
}
v21 = *(_DWORD *)v6;
v7 += 4;
*(_DWORD *)v6 = *(_DWORD *)v12;
v6 += 4;
*(_DWORD *)v12 = v21;
v12 += 4;
}
*a1 = v6;
a1[1] = v7;
return a1;
}