//
// sub_FD1E0 from 0xfd1e0 to 0xfd314 (308 bytes)
//
// 1 xrefs:
// > sub_FCE54 @ 0xfd140
//
// 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 12:15:10 +0000
//
char *__fastcall sub_FD1E0(char *result, __int64 a2, unsigned __int16 a3)
{
unsigned int v3; // w10
unsigned __int64 v4; // x8
char *v5; // x11
int v6; // w12
char *v7; // x14
int v8; // w13
char *v9; // x9
int v10; // w14
unsigned __int64 v11; // x16
unsigned __int64 v12; // x2
__int64 v13; // x15
int v14; // w17
bool v15; // cc
__int64 v16; // x3
__int64 v17; // x7
unsigned int v18; // w5
unsigned int v19; // w6
char v20; // w3
__int64 v21; // x4
__int64 i; // x16
char v23; // w17
__int64 v24; // x2
unsigned __int64 j; // x13
char v26; // t1
__int64 vars0; // [xsp+0h] [xbp+0h] BYREF
v3 = a3;
v4 = a3;
v5 = (char *)&vars0 - ((a3 + 15) & 0x1FFF0);
LOWORD(v6) = 1;
v7 = result;
while ( 1 )
{
v8 = (unsigned __int16)v6;
v9 = v7;
if ( (unsigned __int16)v6 >= v3 )
break;
v10 = 0;
v6 = 2 * (unsigned __int16)v6;
while ( 1 )
{
v11 = v8 + (unsigned int)(unsigned __int16)v10;
if ( (unsigned int)v11 >= v3 )
break;
LODWORD(v12) = (unsigned __int16)v10;
LODWORD(v13) = v6 + (unsigned __int16)v10;
if ( (unsigned int)v13 >= v3 )
v13 = v3;
else
v13 = (unsigned int)v13;
v14 = v8 + (unsigned __int16)v10;
while ( 1 )
{
v15 = (unsigned int)v12 < (unsigned int)v11 && v14 < (int)v13;
v12 = (unsigned int)v12;
if ( !v15 )
break;
v16 = (unsigned __int8)v9[(unsigned int)v12];
v17 = (unsigned __int16)v10++;
v18 = *(unsigned __int16 *)(a2 + 2 * v16);
v19 = *(unsigned __int16 *)(a2 + 2LL * (unsigned __int8)v9[v14]);
if ( v18 < v19 )
LODWORD(v12) = v12 + 1;
else
LOBYTE(v16) = v9[v14];
if ( v18 >= v19 )
++v14;
v5[v17] = v16;
}
while ( v12 < v11 )
{
v20 = v9[v12++];
v21 = (unsigned __int16)v10++;
v5[v21] = v20;
}
for ( i = v14; i < v13; ++i )
{
v23 = v9[i];
v24 = (unsigned __int16)v10++;
v5[v24] = v23;
}
}
for ( j = (unsigned __int16)v10; j < v4; ++j )
v5[j] = v9[j];
v7 = v5;
v5 = v9;
}
if ( v5 == result )
{
while ( v4 )
{
v26 = *v9++;
--v4;
*result++ = v26;
}
}
return result;
}