//
// GJRobotSprite::init from 0xa3cec8 to 0xa3d464 (1436 bytes)
//
// 3 xrefs:
// > GJRobotSprite::init @ 0xa3d4bc
// > GJSpiderSprite::init @ 0xa3d688
// > ??> @ 0x4d770
//
// 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 12:59:54 +0000
//
__int64 __fastcall GJRobotSprite::init(__int64 a1, signed int a2, __int64 a3)
{
GameManager *v6; // x0
GameManager *IconRequestID; // x0
__int64 **v8; // x0
cocos2d::CCSpriteFrameCache *Icon; // x28
char *v10; // x1
SpriteAnimationManager *v12; // x0
unsigned int v13; // w21
void (__fastcall *v14)(__int64, _BYTE *); // x23
__int64 v15; // x23
__int64 (__fastcall *v16)(__int64, _BYTE *); // x24
__int64 v17; // x0
cocos2d::CCArray *v18; // x0
cocos2d::CCObject *v19; // x0
cocos2d::CCArray *v20; // x0
cocos2d::CCObject *v21; // x0
cocos2d::CCSprite *v22; // x0
__int64 v23; // x0
int v24; // w23
int v25; // w0
cocos2d::CCArray *v26; // x24
int v27; // w0
_BYTE *v28; // x19
char v29; // w0
__int64 v30; // x0
unsigned __int64 v31; // x1
unsigned __int64 v32; // x2
unsigned int v33; // w26
const cocos2d::CCRect *v34; // x2
cocos2d::CCObject *v35; // x23
float v36; // s8
__int64 v37; // x0
const cocos2d::CCRect *v38; // x2
cocos2d::CCNode *v39; // x23
cocos2d::CCTexture2D *v40; // x1
__int64 v41; // x1
char *v42; // x3
size_t v43; // x2
char *v44; // x1
void *v45; // x23
__int64 v46; // x0
__int64 v47; // x3
__int64 v48; // x19
void (__fastcall *v49)(__int64, _BYTE *); // x23
float v50; // s8
__int64 v51; // x0
unsigned __int8 v53; // [xsp+7Fh] [xbp+7Fh]
int v54; // [xsp+80h] [xbp+80h]
int v55; // [xsp+84h] [xbp+84h]
void (__fastcall *v56)(cocos2d::CCObject *, _BYTE *); // [xsp+88h] [xbp+88h]
float v57; // [xsp+90h] [xbp+90h]
_BYTE v58[8]; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v59; // [xsp+A8h] [xbp+A8h] BYREF
unsigned __int64 v60; // [xsp+B0h] [xbp+B0h]
void *v61; // [xsp+B8h] [xbp+B8h]
__int64 v62; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v63; // [xsp+C8h] [xbp+C8h]
void *v64; // [xsp+D0h] [xbp+D0h]
v6 = (GameManager *)GameManager::sharedState(_stack_chk_guard);
IconRequestID = (GameManager *)GameManager::getIconRequestID(v6);
*(_DWORD *)(a1 + 764) = (_DWORD)IconRequestID;
v8 = (__int64 **)GameManager::sharedState(IconRequestID);
Icon = GameManager::loadIcon(v8, a2, *(_DWORD *)(a1 + 760), *(_DWORD *)(a1 + 764));
v10 = (char *)(a3 + 1);
if ( (*(_BYTE *)a3 & 1) != 0 )
v10 = *(char **)(a3 + 16);
v53 = CCAnimatedSprite::initWithType((CCAnimatedSprite *)a1, v10, Icon, 1u);
if ( v53 )
{
v12 = *(SpriteAnimationManager **)(a1 + 648);
*(_BYTE *)(a1 + 559) = 1;
SpriteAnimationManager::stopAnimations(v12);
v13 = 0;
v14 = *(void (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)a1 + 320LL);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v58, 30.0, 30.0);
v14(a1, v58);
v15 = *(_QWORD *)(a1 + 672);
v16 = *(__int64 (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)v15 + 184LL);
v57 = *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 328LL))(a1) * 0.5;
v17 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 328LL))(a1);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v58, v57, *(float *)(v17 + 4) * 0.5);
v18 = (cocos2d::CCArray *)v16(v15, v58);
v19 = (cocos2d::CCObject *)cocos2d::CCArray::create(v18);
*(_QWORD *)(a1 + 736) = v19;
v20 = (cocos2d::CCArray *)cocos2d::CCObject::retain(v19);
v21 = (cocos2d::CCObject *)cocos2d::CCArray::create(v20);
*(_QWORD *)(a1 + 720) = v21;
v22 = (cocos2d::CCSprite *)cocos2d::CCObject::retain(v21);
v23 = cocos2d::CCSprite::create(v22);
*(_QWORD *)(a1 + 744) = v23;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 672) + 464LL))(
*(_QWORD *)(a1 + 672),
v23,
0xFFFFFFFFLL);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 744) + 344LL))(*(_QWORD *)(a1 + 744), 0);
*(_BYTE *)(*(_QWORD *)(a1 + 744) + 559LL) = 1;
v24 = *(_DWORD *)(a1 + 760);
if ( v24 == 6 )
v25 = 10;
else
v25 = 9;
v54 = v25;
v26 = *(cocos2d::CCArray **)(*(_QWORD *)(a1 + 672) + 632LL);
if ( v24 == 6 )
v27 = 12;
else
v27 = 11;
v55 = v27;
if ( !(unsigned int)cocos2d::CCArray::count(v26) )
{
LABEL_26:
GJRobotSprite::updateFrame((GJRobotSprite *)a1, a2);
v62 = 0;
v63 = 0;
v64 = nullptr;
std::string::__init(&v62, "idle", 4u);
CCAnimatedSprite::runAnimation(a1, (char *)&v62);
if ( (v62 & 1) != 0 )
operator delete(v64);
return v53;
}
while ( 1 )
{
v28 = (_BYTE *)cocos2d::CCArray::objectAtIndex(v26, v13);
v29 = v28[624];
v59 = 0;
v60 = 0;
v28[618] = 1;
v61 = nullptr;
if ( (v29 & 1) != 0 )
{
std::string::__init(&v59, *((void **)v28 + 80), *((_QWORD *)v28 + 79));
}
else
{
v30 = *((_QWORD *)v28 + 78);
v31 = *((_QWORD *)v28 + 79);
v61 = *((void **)v28 + 80);
v59 = v30;
v60 = v31;
}
if ( (v59 & 1) != 0 )
{
v32 = v60;
if ( !v60 )
goto LABEL_33;
if ( v60 < v55 )
goto LABEL_17;
v41 = v54;
v42 = (char *)v61;
v62 = 0;
v63 = 0;
v64 = nullptr;
}
else
{
LODWORD(v32) = (int)(unsigned __int8)v59 >> 1;
if ( !(_DWORD)v32 )
goto LABEL_24;
v32 = (int)v32;
if ( (int)v32 < (unsigned __int64)v55 )
{
LABEL_17:
v33 = -1;
goto LABEL_18;
}
v41 = v54;
v62 = 0;
v42 = (char *)&v59 + 1;
v63 = 0;
v64 = nullptr;
}
v43 = v32 - v41;
v44 = &v42[v41];
if ( v43 != 1 )
v43 = 2;
std::string::__init(&v62, v44, v43);
if ( (v62 & 1) != 0 )
{
v45 = v64;
v33 = atoi((const char *)v64);
operator delete(v45);
}
else
{
v33 = atoi((const char *)&v62 + 1);
}
LABEL_18:
(*(void (__fastcall **)(_BYTE *, _QWORD))(*(_QWORD *)v28 + 72LL))(v28, v33);
v35 = (cocos2d::CCObject *)cocos2d::CCSprite::createWithTexture(Icon, (cocos2d::CCTexture2D *)&unk_155D3D8, v34);
(*(void (__fastcall **)(_BYTE *, cocos2d::CCObject *, __int64))(*(_QWORD *)v28 + 464LL))(v28, v35, 0xFFFFFFFFLL);
v56 = *(void (__fastcall **)(cocos2d::CCObject *, _BYTE *))(*(_QWORD *)v35 + 184LL);
v36 = *(float *)(*(__int64 (__fastcall **)(_BYTE *))(*(_QWORD *)v28 + 328LL))(v28);
v37 = (*(__int64 (__fastcall **)(_BYTE *))(*(_QWORD *)v28 + 328LL))(v28);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v58, v36 * 0.5, *(float *)(v37 + 4) * 0.5);
v56(v35, v58);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 736), v35);
v39 = (cocos2d::CCNode *)cocos2d::CCSprite::createWithTexture(Icon, (cocos2d::CCTexture2D *)&unk_155D3D8, v38);
(*(void (__fastcall **)(_QWORD, cocos2d::CCNode *, __int64))(**(_QWORD **)(a1 + 744) + 464LL))(
*(_QWORD *)(a1 + 744),
v39,
0xFFFFFFFFLL);
CCSpritePlus::addFollower((CCSpritePlus *)v28, v39);
v28[617] = 1;
if ( v13 == 6 && *(_DWORD *)(a1 + 760) == 5 )
*(_QWORD *)(a1 + 776) = v28;
if ( v33 == 1 )
{
*(_QWORD *)(a1 + 768) = v28;
}
else if ( v28 != *(_BYTE **)(a1 + 768) )
{
goto LABEL_23;
}
if ( !*(_QWORD *)(a1 + 752) )
{
v46 = cocos2d::CCSprite::createWithTexture(Icon, v40);
v47 = *(_QWORD *)(a1 + 768);
*(_QWORD *)(a1 + 752) = v46;
*(_BYTE *)(a1 + 728) = 0;
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v47 + 464LL))(v47, v46, 2);
v48 = *(_QWORD *)(a1 + 752);
v49 = *(void (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)v48 + 184LL);
v50 = *(float *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 768) + 328LL))(*(_QWORD *)(a1 + 768));
v51 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 768) + 328LL))(*(_QWORD *)(a1 + 768));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v58, v50 * 0.5, *(float *)(v51 + 4) * 0.5);
v49(v48, v58);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 752) + 344LL))(
*(_QWORD *)(a1 + 752),
*(unsigned __int8 *)(a1 + 728));
}
LABEL_23:
if ( (v59 & 1) != 0 )
{
LABEL_33:
++v13;
operator delete(v61);
goto LABEL_25;
}
LABEL_24:
++v13;
LABEL_25:
if ( v13 >= (unsigned int)cocos2d::CCArray::count(v26) )
goto LABEL_26;
}
}
return v53;
}