//
// tk::spline::find_closest from 0xa7d5d8 to 0xa7d66c (148 bytes)
//
// 3 xrefs:
// > tk::spline::operator @ 0xa7d690
// > tk::spline::deriv @ 0xa7d790
// > ??> @ 0x833b8
//
// 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 tk::spline::find_closest(double **this, double a2)
{
double *v2; // x3
double *v3; // x5
__int64 i; // x2
__int64 v5; // x1
double *v6; // x4
__int64 v8; // x0
v2 = *this;
v3 = *this;
for ( i = *(this + 1) - *this; i > 0; i = v5 - v8 - 1 )
{
v5 = i >> 1;
v6 = &v2[i >> 1];
if ( a2 < *v6 )
{
while ( 1 )
{
v8 = v5 >> 1;
if ( !v5 )
return (unsigned __int64)fmax((double)(int)(v2 - v3 - 1), 0.0);
v6 = &v2[v8];
if ( *v6 <= a2 )
goto LABEL_9;
v5 >>= 1;
}
}
v8 = i >> 1;
v5 = i;
LABEL_9:
v2 = v6 + 1;
}
return (unsigned __int64)fmax((double)(int)(v2 - v3 - 1), 0.0);
}