//
// sub_1404C6350 from 0x1404c6350 to 0x1404c63f1 (161 bytes)
//
// 2 xrefs:
// > sub_1404C6400 @ 0x1404c6420
// > ??> @ 0x1406dd130
//
// 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
//
unsigned __int64 __fastcall sub_1404C6350(__int64 *a1, double a2)
{
__int64 v2; // r8
unsigned __int64 v3; // rdx
double v4; // xmm0_8
unsigned __int64 v5; // rcx
v2 = *a1;
v3 = (a1[1] - *a1) >> 3;
while ( (__int64)v3 > 0 )
{
if ( *(double *)(v2 + 8 * (v3 >> 1)) <= a2 )
{
v2 += 8 * (v3 >> 1) + 8;
v3 += -1LL - (v3 >> 1);
}
else
{
v3 >>= 1;
}
}
v4 = fmax((double)(int)(((v2 - *a1) >> 3) - 1), 0.0);
v5 = 0;
if ( v4 >= 9.223372036854776e18 )
{
v4 = v4 - 9.223372036854776e18;
if ( v4 < 9.223372036854776e18 )
v5 = 0x8000000000000000uLL;
}
return v5 + (unsigned int)(int)v4;
}