//
// sub_1004CAD70 from 0x1004cad70 to 0x1004cae14 (164 bytes)
//
// 1 xrefs:
// > sub_1004D268C @ 0x1004d2798
//
// This function is hookable on this platform (idp: arm, 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:06:25 +0000
//
__int64 __fastcall sub_1004CAD70(__int64 result, __int64 a2)
{
__int64 v3; // x20
__int64 v4; // x0
_QWORD *v5; // x0
__int64 v6; // x21
__int64 v7; // x0
if ( a2 )
{
v3 = result;
v4 = *(_QWORD *)(result + 144);
if ( !v4 )
{
v5 = sub_1002E736C();
*(_QWORD *)(v3 + 144) = v5;
cocos2d::CCObject::retain((__int64)v5);
v4 = *(_QWORD *)(v3 + 144);
}
if ( (unsigned int)sub_1002E757C(v4) )
{
v6 = 0;
while ( 1 )
{
v7 = sub_1002E75A0(*(_QWORD *)(v3 + 144), v6);
if ( v7 )
{
if ( *(_DWORD *)(v7 + 316) == *(_DWORD *)(a2 + 316) )
break;
}
v6 = (unsigned int)(v6 + 1);
if ( (unsigned int)v6 >= (unsigned int)sub_1002E757C(*(_QWORD *)(v3 + 144)) )
return sub_1002E74E0(*(_QWORD *)(v3 + 144));
}
sub_1002E7664(*(_QWORD *)(v3 + 144), v6, 1);
}
return sub_1002E74E0(*(_QWORD *)(v3 + 144));
}
return result;
}