//
// sub_10003047C from 0x10003047c to 0x100030588 (268 bytes)
//
// 1 xrefs:
// > sub_10002FB2C @ 0x10002ffb8
//
// 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
//
__int64 *__fastcall sub_10003047C(__int64 *a1, __int64 *a2, __int64 (__fastcall **a3)(__int64, __int64))
{
__int64 *v4; // x22
__int64 v6; // x19
__int64 *v7; // x23
__int64 v8; // t1
__int64 *v9; // x24
__int64 v10; // t1
__int64 v11; // x8
__int64 v12; // t1
__int64 v13; // t1
v4 = a2;
v6 = *a1;
if ( ((*a3)(*a1, *(a2 - 1)) & 1) != 0 )
{
v7 = a1;
do
{
v8 = v7[1];
++v7;
}
while ( ((*a3)(v6, v8) & 1) == 0 );
}
else
{
v9 = a1 + 1;
do
{
v7 = v9;
if ( v9 >= v4 )
break;
++v9;
}
while ( !(unsigned int)(*a3)(v6, *v7) );
}
if ( v7 < v4 )
{
do
v10 = *--v4;
while ( ((*a3)(v6, v10) & 1) != 0 );
}
while ( v7 < v4 )
{
v11 = *v7;
*v7 = *v4;
*v4 = v11;
do
{
v12 = v7[1];
++v7;
}
while ( !(unsigned int)(*a3)(v6, v12) );
do
v13 = *--v4;
while ( ((*a3)(v6, v13) & 1) != 0 );
}
if ( v7 - 1 != a1 )
*a1 = *(v7 - 1);
*(v7 - 1) = v6;
return v7;
}