//
// sub_BA2E0C from 0xba2e0c to 0xba2f00 (244 bytes)
//
// 3 xrefs:
// > sub_B9B94C @ 0xb9bb68
// > sub_B9D6EC @ 0xb9d8d0
// > sub_B9D9F4 @ 0xb9db60
//
// 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_BA2E0C(__int64 *a1, __int64 a2, __int64 **a3, __int64 *a4)
{
__int64 **v7; // x1
__int64 *v8; // x0
__int64 *v9; // x2
__int64 *v11; // x4
if ( !a4 )
return a3;
if ( !a3 )
{
a4[1] = 0;
*a4 = 0;
goto LABEL_7;
}
v7 = sub_BA2CF0(a1, a2, a3);
v8 = v7[3];
if ( v8 != a1 )
{
if ( (__int64)v8 > (__int64)a1 )
goto LABEL_6;
if ( (__int64)v8 < (__int64)a1 )
{
LABEL_11:
a4[1] = (__int64)v7[1];
*a4 = (__int64)v7;
v7[1] = nullptr;
goto LABEL_7;
}
v9 = v7[4];
LABEL_5:
if ( a2 < (__int64)v9 )
{
LABEL_6:
*a4 = (__int64)*v7;
a4[1] = (__int64)v7;
*v7 = nullptr;
LABEL_7:
a4[3] = (__int64)a1;
a4[4] = a2;
a4[2] = 0;
return (__int64 **)a4;
}
goto LABEL_11;
}
v9 = v7[4];
if ( v9 != (__int64 *)a2 )
goto LABEL_5;
a4[3] = (__int64)v8;
a4[4] = (__int64)v9;
a4[2] = (__int64)v7;
v11 = *v7;
a4[1] = (__int64)v7[1];
*a4 = (__int64)v11;
*v7 = a4;
v7[3] = (__int64 *)-1LL;
v7[4] = (__int64 *)-1LL;
return (__int64 **)a4;
}