//
// sub_B58E0 from 0xb58e0 to 0xb5954 (116 bytes)
//
// 1 xrefs:
// > sub_B4A0C @ 0xb4a0c
//
// 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_B58E0(__int64 a1, float *a2)
{
int v3; // w9
float v4; // s0
__int64 result; // x0
int v6; // w9
int v7; // w11
float v8; // s1
int v9; // w12
v3 = *(_DWORD *)(a1 + 8);
v4 = *a2;
result = 0;
v6 = v3 - 1;
while ( (int)result <= v6 )
{
if ( *(float *)(*(_QWORD *)a1 + 4LL * v6) < v4 )
return (unsigned int)(v6 + 1);
v7 = ((int)result + v6) / 2;
v8 = *(float *)(*(_QWORD *)a1 + 4LL * v7);
v9 = v4 < v8;
if ( v8 < v4 )
v9 = -1;
if ( !v9 )
return (unsigned int)v7;
if ( v9 <= 0 )
{
result = (unsigned int)(v7 + 1);
}
else
{
v6 = v7 - 1;
result = (unsigned int)result;
}
}
return result;
}