//
// tk::spline::find_closest from 0xbb2bb8 to 0xbb2c30 (120 bytes)
//
// 3 xrefs:
// > tk::spline::operator @ 0xbb2c54
// > tk::spline::deriv @ 0xbb2d54
// > ??> @ 0xae700
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:02:56 +0000
//
unsigned __int64 __fastcall tk::spline::find_closest(tk::spline *this, double a2)
{
__int64 v2; // x2
__int64 v3; // x5
__int64 i; // x0
__int64 v5; // x1
v2 = *(_QWORD *)this;
v3 = *(_QWORD *)this;
for ( i = (__int64)(*((_QWORD *)this + 1) - *(_QWORD *)this) >> 3; i; i += ~(i / 2) )
{
while ( 1 )
{
v5 = i / 2;
if ( *(double *)(v2 + 8 * (i / 2)) <= a2 )
break;
i /= 2;
if ( !v5 )
return (unsigned __int64)fmax((double)(int)(((v2 - v3) >> 3) - 1), 0.0);
}
v2 += 8 * (i / 2) + 8;
}
return (unsigned __int64)fmax((double)(int)(((v2 - v3) >> 3) - 1), 0.0);
}