//
// cocos2d::CCMenu::itemForTouch from 0x100875450 to 0x100875691 (577 bytes)
//
// 8 xrefs:
// > cocos2d::CCMenu::ccTouchBegan @ 0x100873dd9
// > cocos2d::CCMenu::ccTouchBegan @ 0x100873df8
// > cocos2d::CCMenu::itemForTouch_1 @ 0x100873e4f
// > cocos2d::CCMenu::itemForTouch_1 @ 0x100873e6d
// > cocos2d::CCMenu::ccTouchMoved @ 0x100873f8f
// > cocos2d::CCMenu::ccTouchMoved @ 0x100873fb2
// > sub_100874000 @ 0x10087401c
// > sub_100874000 @ 0x10087403c
//
// 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 12:36:52 +0000
//
__int64 __fastcall cocos2d::CCMenu::itemForTouch(__int64 a1, __int64 a2, char a3)
{
__int64 v5; // rdi
__int64 v6; // rax
unsigned int *v7; // rax
const void **v8; // r12
unsigned __int64 v9; // r13
void *v10; // rax
__int64 v11; // rbx
void *v12; // rax
__m128 v13; // xmm0
__m128d v14; // xmm1
unsigned int v16; // [rsp+8h] [rbp-48h] BYREF
__m128d v17; // [rsp+10h] [rbp-40h] BYREF
double v18[6]; // [rsp+20h] [rbp-30h] BYREF
cocos2d::CCTouch::getLocation((__int64)&v16, a2);
v5 = *(_QWORD *)(a1 + 208);
if ( v5 )
{
if ( (unsigned int)sub_1007FEF90(v5) )
{
v6 = *(_QWORD *)(a1 + 208);
if ( v6 )
{
v7 = *(unsigned int **)(v6 + 56);
if ( *v7 )
{
v8 = *((const void ***)v7 + 2);
v9 = (unsigned __int64)&v8[*v7 - 1];
if ( a3 )
{
while ( *v8 )
{
v12 = __dynamic_cast(
*v8,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCMenuItem,
0);
if ( v12 )
{
v11 = (__int64)v12;
if ( (*(unsigned __int8 (__fastcall **)(void *))(*(_QWORD *)v12 + 352LL))(v12) )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)v11 + 1048LL))(v11) )
{
cocos2d::CCNode::convertToNodeSpace(v18, v11, &v16);
cocos2d::CCMenuItem::rect((__int64)&v17, (float *)v11);
sub_100278300(&v17, &qword_100BE6AA8);
v13 = (__m128)*(unsigned int *)(v11 + 372);
if ( v13.f32[0] > 1.0 )
{
v14 = 0;
v14.f64[0] = v13.f32[0] + -1.0;
v17 = _mm_unpacklo_pd(
(__m128d)_mm_cvtpd_ps(
_mm_add_pd(
_mm_mul_pd(
_mm_mul_pd(
_mm_movedup_pd(v14),
_mm_cvtps_pd((__m128)*(unsigned __int64 *)&v17.f64[1])),
(__m128d)xmmword_100A10780),
_mm_cvtps_pd(*(__m64 *)&v17.f64[0]))),
(__m128d)_mm_mul_ps(_mm_moveldup_ps(v13), (__m128)*(unsigned __int64 *)&v17.f64[1]));
}
if ( sub_100278940((float *)&v17, (float *)v18) )
return v11;
}
}
}
if ( (unsigned __int64)++v8 > v9 )
return 0;
}
}
else
{
while ( *v8 )
{
v10 = __dynamic_cast(
*v8,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCMenuItem,
0);
if ( v10 )
{
v11 = (__int64)v10;
if ( (*(unsigned __int8 (__fastcall **)(void *))(*(_QWORD *)v10 + 352LL))(v10) )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)v11 + 1048LL))(v11) )
{
cocos2d::CCNode::convertToNodeSpace(v18, v11, &v16);
cocos2d::CCMenuItem::rect((__int64)&v17, (float *)v11);
sub_100278300(&v17, &qword_100BE6AA8);
if ( sub_100278940((float *)&v17, (float *)v18) )
return v11;
}
}
}
if ( (unsigned __int64)++v8 > v9 )
return 0;
}
}
}
}
}
}
return 0;
}