//
// PlayerObject::convertToClosestRotation from 0x100402a70 to 0x100402b87 (279 bytes)
//
// 1 xrefs:
// > PlayerObject::updateRotation_1 @ 0x10040cd55
//
// 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
//
// local variable allocation has failed, the output may be wrong!
float __fastcall PlayerObject::convertToClosestRotation(PlayerObject *a1, float a2)
{
int v2; // eax
__m128 v3; // xmm4
signed int v4; // eax
__m128 v5; // xmm1
__m128 v6; // xmm2
__m128 v7; // xmm2
__m128 v8; // [rsp-18h] [rbp-18h]
if ( !a1->m_isShip
&& !a1->m_isBird
&& !a1->m_isDart
&& !a1->m_isSwing
&& !a1->m_isRobot
&& !a1->m_isSpider
&& !a1->m_isDashing )
{
v8 = *(__m128 *)&a2;
v2 = (int)((float (__fastcall *)(PlayerObject *))a1->getRotation)(a1);
if ( v2 < 0 )
v4 = 360 * (-v2 / 0x168u) + v2;
else
v4 = v2 % 0x168u;
*(__m128 *)&a2 = v8;
v3.f32[0] = (float)v4;
if ( v8.f32[0] <= (float)v4 )
{
if ( v3.f32[0] <= v8.f32[0] )
{
v5 = v8;
}
else
{
do
{
v5 = *(__m128 *)&a2;
a2 = a2 + 90.0;
}
while ( v3.f32[0] > a2 );
}
}
else
{
do
{
v5 = *(__m128 *)&a2;
a2 = a2 + -90.0;
}
while ( a2 > v3.f32[0] );
}
v6 = v3;
v6.f32[0] = v3.f32[0] - a2;
v3.f32[0] = v3.f32[0] - v5.f32[0];
v7 = _mm_cmplt_ss(_mm_and_ps(v6, (__m128)xmmword_100815500), _mm_and_ps(v3, (__m128)xmmword_100815500));
LODWORD(a2) = LODWORD(a2) & v7.i32[0] | _mm_andnot_ps(v7, v5).u32[0];
}
return a2;
}