//
// GJBaseGameLayer::convertToClosestDirection from 0x1403373e0 to 0x14033747b (155 bytes)
//
// 9 xrefs:
// > GJBaseGameLayer::teleportPlayer @ 0x140316836
// > sub_140326AB0 @ 0x140326d8b
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x140338772
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x140338c95
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x140338d1a
// > GJBaseGameLayer::updateScreenRotation @ 0x14033eca3
// > GJBaseGameLayer::updateScreenRotation @ 0x14033ecb7
// > PlayerObject::redirectPlayerForce @ 0x1404fe12a
// > ??> @ 0x14091f9b8
//
// This function is hookable on this platform (idp: pc, 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 11:30:35 +0000
//
// local variable allocation has failed, the output may be wrong!
double __fastcall GJBaseGameLayer::convertToClosestDirection(double result, float a2)
{
__int128 v2; // xmm6
float v3; // xmm0_4
v2 = *(_OWORD *)&result;
if ( (float)-a2 <= *(float *)&result )
{
if ( *(float *)&result > a2 )
{
v3 = floorf(fabs(*(float *)&result) / a2);
*(float *)&v2 = *(float *)&v2 - (float)(ceilf(v3 * 0.5) * (float)(a2 + a2));
*(_OWORD *)&result = v2;
}
}
else
{
*(__m128 *)&result = _mm_and_ps(*(__m128 *)&result, (__m128)xmmword_140836C90);
*(float *)&result = floorf(*(float *)&result / a2);
*(float *)&result = (float)(ceilf(*(float *)&result * 0.5) * (float)(a2 + a2)) + *(float *)&v2;
}
return result;
}