//
// cocos2d::CCMenu::itemForTouch from 0x100794a50 to 0x100794c91 (577 bytes)
//
// 10 xrefs:
// > cocos2d::CCMenu::ccTouchBegan @ 0x10079333c
// > cocos2d::CCMenu::ccTouchBegan @ 0x10079335d
// > cocos2d::CCMenu::itemForTouch_1 @ 0x1007933af
// > cocos2d::CCMenu::itemForTouch_1 @ 0x1007933cd
// > sub_1007933E0 @ 0x100793443
// > sub_1007933E0 @ 0x100793461
// > cocos2d::CCMenu::ccTouchMoved @ 0x10079358f
// > cocos2d::CCMenu::ccTouchMoved @ 0x1007935b2
// > sub_100793600 @ 0x10079361c
// > sub_100793600 @ 0x10079363c
//
// 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
//
cocos2d::CCMenuItem *__fastcall cocos2d::CCMenu::itemForTouch(cocos2d::CCMenu *a1, cocos2d::CCTouch *a2, bool a3)
{
__m128d y_low; // xmm0
cocos2d::CCArray *m_pChildren; // rdi
cocos2d::CCArray *v7; // rax
cocos2d::ccArray *data; // rax
const void **arr; // r12
unsigned __int64 v10; // r13
cocos2d::CCPoint *v11; // rax
cocos2d::CCPoint *v12; // rbx
cocos2d::CCPoint *v13; // rax
__m128d v14; // xmm1
__m128d v16; // xmm1
char v17; // [rsp+8h] [rbp-48h] BYREF
cocos2d::CCRect v18; // [rsp+10h] [rbp-40h] BYREF
float v19[12]; // [rsp+20h] [rbp-30h] BYREF
double size; // 0:xmm1_8.8
*(cocos2d::CCPoint *)&y_low.f64[0] = cocos2d::CCTouch::getLocation((cocos2d::CCTouch *)&v17);
m_pChildren = a1->m_pChildren;
if ( m_pChildren )
{
if ( (unsigned int)sub_100720070((__int64)m_pChildren) )
{
v7 = a1->m_pChildren;
if ( v7 )
{
data = v7->data;
if ( data->num )
{
arr = (const void **)data->arr;
v10 = (unsigned __int64)&arr[data->num - 1];
if ( a3 )
{
while ( *arr )
{
v13 = (cocos2d::CCPoint *)__dynamic_cast(
*arr,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCMenuItem,
0);
if ( v13 )
{
v12 = v13;
if ( (*(unsigned __int8 (__fastcall **)(cocos2d::CCPoint *, double))(*(_QWORD *)v13 + 336LL))(
v13,
y_low.f64[0]) )
{
if ( (*(unsigned __int8 (__fastcall **)(cocos2d::CCPoint *))(*(_QWORD *)v12 + 1032LL))(v12) )
{
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v19, v12);
v16.f64[0] = (unsigned __int64)cocos2d::CCMenuItem::rect((cocos2d::CCMenuItem *)&v18).size;
sub_10028CC90(&v18, &dbl_1009A3B18);
y_low = (__m128d)LODWORD(v12[46].y);
if ( *(float *)y_low.f64 > 1.0 )
{
v14 = 0;
v14.f64[0] = *(float *)y_low.f64 + -1.0;
y_low = (__m128d)_mm_mul_ps(_mm_moveldup_ps((__m128)y_low), (__m128)(unsigned __int64)v18.size);
v16 = _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)v18.size)),
(__m128d)xmmword_1008218A0),
_mm_cvtps_pd((__m64)v18.origin))),
y_low);
v18 = (cocos2d::CCRect)v16;
}
if ( sub_10028D2D0((float *)&v18.origin, y_low.f64[0], v16.f64[0], v19) )
return (cocos2d::CCMenuItem *)v12;
}
}
}
if ( (unsigned __int64)++arr > v10 )
return nullptr;
}
}
else
{
while ( *arr )
{
v11 = (cocos2d::CCPoint *)__dynamic_cast(
*arr,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCMenuItem,
0);
if ( v11 )
{
v12 = v11;
if ( (*(unsigned __int8 (__fastcall **)(cocos2d::CCPoint *, double))(*(_QWORD *)v11 + 336LL))(
v11,
y_low.f64[0]) )
{
if ( (*(unsigned __int8 (__fastcall **)(cocos2d::CCPoint *))(*(_QWORD *)v12 + 1032LL))(v12) )
{
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v19, v12);
size = (unsigned __int64)cocos2d::CCMenuItem::rect((cocos2d::CCMenuItem *)&v18).size;
y_low.f64[0] = sub_10028CC90(&v18, &dbl_1009A3B18);
if ( sub_10028D2D0((float *)&v18.origin, y_low.f64[0], size, v19) )
return (cocos2d::CCMenuItem *)v12;
}
}
}
if ( (unsigned __int64)++arr > v10 )
return nullptr;
}
}
}
}
}
}
return nullptr;
}