//
// GameToolbox::getRelativeOffset from 0x1004ef040 to 0x1004ef26a (554 bytes)
//
// 13 xrefs:
// > EditorUI::onCreateObject @ 0x100034dde
// > EditorUI::onCreateObject @ 0x100034fb1
// > EditorUI::onCreateObject @ 0x100035015
// > EditorUI::getRelativeOffset @ 0x10003a3db
// > EditorUI::removeOffset @ 0x10003a594
// > EditorUI::applyOffset @ 0x10003a614
// > EditorUI::transformObject @ 0x10004b97d
// > EditorUI::transformObject @ 0x10004be20
// > EditorUI::positionWithoutOffset @ 0x10004e1d4
// > EditorUI::findSnapObject_1 @ 0x10004e84a
// > EditorUI::findSnapObject_1 @ 0x10004ea79
// > LevelEditorLayer::getObjectRect @ 0x1000e18e0
// > LevelEditorLayer::getRelativeOffset @ 0x1000e1eac
//
// 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!
cocos2d::CCPoint __fastcall GameToolbox::getRelativeOffset(GameObject *a1, cocos2d::CCPoint a2)
{
float *v2; // rdx
__int64 v3; // rsi
unsigned __int64 *v4; // r14
unsigned __int8 v5; // r15
unsigned __int8 v6; // r12
float v7; // xmm1_4
__m128 v8; // xmm1
float v9; // xmm1_4
unsigned __int8 v10; // r15
float *v11; // rax
cocos2d::CCPoint result; // 0:xmm0_8.8
v4 = (unsigned __int64 *)v2;
if ( !sub_10028CDB0(v2, flt_1009A2430) )
{
v5 = (*(__int64 (__fastcall **)(__int64, double))(*(_QWORD *)v3 + 1416LL))(v3, *(double *)&a2);
v6 = (*(__int64 (__fastcall **)())(*(_QWORD *)v3 + 1408LL))();
*(double *)&a2 = (*(double (__fastcall **)())(*(_QWORD *)v3 + 352LL))();
v7 = fabs(a2.x);
if ( v7 == 90.0 || v7 == 270.0 )
_mm_storel_ps((double *)v4, _mm_shuffle_ps((__m128)*v4, (__m128)*v4, 225));
v8 = _mm_cmplt_ss(*(__m128 *)&a2.x, (__m128)0LL);
LODWORD(v9) = _mm_andnot_ps(v8, *(__m128 *)&a2.x).u32[0] | COERCE_UNSIGNED_INT(a2.x + 360.0) & v8.i32[0];
if ( ((v5 | v6) & 1) != 0 )
{
if ( ((v5 | v6 ^ 1) & 1) != 0 )
{
v10 = v5 ^ 1;
if ( ((v10 | v6) & 1) != 0 )
{
if ( ((v10 | v6 ^ 1) & 1) == 0 )
{
if ( v9 == 0.0 || v9 == 90.0 )
*(float *)v4 = -*(float *)v4;
if ( v9 == 0.0 || v9 == 270.0 )
{
LABEL_32:
v11 = (float *)v4 + 1;
LABEL_33:
*v11 = -*v11;
}
}
}
else
{
if ( v9 == 90.0 || v9 == 180.0 )
*(float *)v4 = -*(float *)v4;
if ( v9 == 0.0 || v9 == 90.0 )
goto LABEL_32;
}
}
else
{
if ( v9 == 0.0 || v9 == 270.0 )
*(float *)v4 = -*(float *)v4;
if ( v9 == 270.0 || v9 == 180.0 )
goto LABEL_32;
}
}
else
{
if ( v9 == 90.0 || v9 == 180.0 )
*((float *)v4 + 1) = -*((float *)v4 + 1);
v11 = (float *)v4;
if ( v9 == 180.0 )
goto LABEL_33;
v11 = (float *)v4;
if ( v9 == 270.0 )
goto LABEL_33;
}
}
*(double *)&result = sub_10028CC60(a1, (double *)v4);
return result;
}