//
// GJTransformControl::snapToNearestVertex from 0x1401a8440 to 0x1401a877b (827 bytes)
//
// 3 xrefs:
// > GJTransformControl::ccTouchBegan @ 0x1401a73c7
// > GJTransformControl::ccTouchMoved @ 0x1401a7594
// > ??> @ 0x140919c94
//
// 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:27:51 +0000
//
// Hidden C++ exception states: #wind=1
cocos2d::CCPoint *__fastcall GJTransformControl::snapToNearestVertex(
__int64 a1,
cocos2d::CCPoint *a2,
const struct cocos2d::CCPoint *a3)
{
const struct cocos2d::CCPoint *v3; // r14
cocos2d::CCPoint *v6; // rbx
__int64 v7; // r15
__int64 v8; // rdi
struct cocos2d::CCObject *v9; // rax
__int64 v10; // rax
struct cocos2d::CCObject *v11; // rax
__int64 v12; // rax
struct cocos2d::CCObject *v13; // rax
__int64 v14; // rax
struct cocos2d::CCObject *v15; // rax
__int64 v16; // rax
struct cocos2d::CCObject *v17; // rax
__int64 v18; // rax
struct cocos2d::CCObject *v19; // rax
__int64 v20; // rax
struct cocos2d::CCObject *v21; // rax
__int64 v22; // rax
struct cocos2d::CCObject *v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rax
float v27; // xmm6_4
int v28; // r12d
int *v29; // rbx
_BYTE *v30; // rdi
__int64 v31; // rax
const struct cocos2d::CCPoint *v32; // r8
float v33; // xmm0_4
int v34; // r14d
__int64 v36; // [rsp+28h] [rbp-99h] BYREF
void *v37; // [rsp+30h] [rbp-91h] BYREF
const struct cocos2d::CCPoint *v38; // [rsp+38h] [rbp-89h]
_OWORD v39[2]; // [rsp+40h] [rbp-81h] BYREF
int v40; // [rsp+60h] [rbp-61h]
_BYTE v41[8]; // [rsp+68h] [rbp-59h] BYREF
_BYTE v42[8]; // [rsp+70h] [rbp-51h] BYREF
_BYTE v43[8]; // [rsp+78h] [rbp-49h] BYREF
_BYTE v44[8]; // [rsp+80h] [rbp-41h] BYREF
_BYTE v45[8]; // [rsp+88h] [rbp-39h] BYREF
_BYTE v46[8]; // [rsp+90h] [rbp-31h] BYREF
_BYTE v47[8]; // [rsp+98h] [rbp-29h] BYREF
_BYTE v48[8]; // [rsp+A0h] [rbp-21h] BYREF
_BYTE v49[16]; // [rsp+A8h] [rbp-19h] BYREF
v3 = a3;
v38 = a3;
v39[0] = _mm_load_si128((const __m128i *)&xmmword_140836810);
v39[1] = _mm_load_si128((const __m128i *)&xmmword_1408367C0);
v40 = 1;
v6 = (cocos2d::CCPoint *)v41;
v7 = 9;
v8 = 9;
do
{
cocos2d::CCPoint::CCPoint(v6);
v6 = (cocos2d::CCPoint *)((char *)v6 + 8);
--v8;
}
while ( v8 );
v9 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 512), 5u);
v10 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v9 + 200LL))(v9);
cocos2d::CCPoint::operator=(v41, v10);
v11 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 512), 6u);
v12 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v11 + 200LL))(v11);
cocos2d::CCPoint::operator=(v42, v12);
v13 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 512), 7u);
v14 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v13 + 200LL))(v13);
cocos2d::CCPoint::operator=(v43, v14);
v15 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 512), 8u);
v16 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v15 + 200LL))(v15);
cocos2d::CCPoint::operator=(v44, v16);
v17 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 512), 1u);
v18 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v17 + 200LL))(v17);
cocos2d::CCPoint::operator=(v45, v18);
v19 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 512), 2u);
v20 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v19 + 200LL))(v19);
cocos2d::CCPoint::operator=(v46, v20);
v21 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 512), 3u);
v22 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v21 + 200LL))(v21);
cocos2d::CCPoint::operator=(v47, v22);
v23 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 512), 4u);
v24 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v23 + 200LL))(v23);
cocos2d::CCPoint::operator=(v48, v24);
cocos2d::CCPoint::operator+(v41, &v37, v44);
cocos2d::CCPoint::operator/(v25, &v36);
cocos2d::CCPoint::operator=(v49, &v36);
cocos2d::CCPoint::CCPoint(a2, v3);
v26 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v37 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v37);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v26 = qword_14090BFD0;
}
v27 = 8.0
/ (*(float (__fastcall **)(_QWORD))(**(_QWORD **)(*(_QWORD *)(v26 + 568) + 4296LL) + 168LL))(*(_QWORD *)(*(_QWORD *)(v26 + 568) + 4296LL));
v28 = 0;
v29 = (int *)v39;
v30 = v41;
do
{
cocos2d::CCNode::convertToWorldSpace(*(_QWORD *)(a1 + 408), &v37, v30);
cocos2d::CCNode::convertToNodeSpace(a1, &v36, v31);
v33 = cocos2d::ccpDistance(v3, (const struct cocos2d::CCPoint *)&v36, v32);
v34 = *v29;
if ( *v29 == *(_DWORD *)(a1 + 632) )
v33 = v33 / 1.5;
if ( v27 > v33 )
{
v27 = v33;
cocos2d::CCPoint::operator=(a2, &v36);
v28 = v34;
}
v30 += 8;
++v29;
--v7;
v3 = v38;
}
while ( v7 );
*(_DWORD *)(a1 + 632) = v28;
return a2;
}