//
// sub_602004 from 0x602004 to 0x60204e (74 bytes)
//
// 6 xrefs:
// > sub_602054 @ 0x602064
// > sub_602054 @ 0x602070
// > sub_6020B8 @ 0x6020ca
// > sub_6020B8 @ 0x6020d6
// > sub_6022A8 @ 0x6022de
// > sub_6022A8 @ 0x602396
//
// 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
//
_DWORD *__fastcall sub_602004(_DWORD *result, int a2)
{
int v2; // r2
_DWORD *v3; // r3
int v4; // r2
int v5; // r1
int v6; // r2
int v7; // r1
v2 = *(unsigned __int16 *)(a2 - 2);
v3 = (_DWORD *)(-28 - *(unsigned __int16 *)(a2 - 4) + a2);
if ( !*(_WORD *)(a2 - 2) )
v2 = v3[4];
if ( v3 == (_DWORD *)*result )
v3[4] = result[1];
v4 = v2 + v3[5];
v5 = v3[4];
v3[5] = v4;
if ( v4 == v5 )
{
v6 = v3[3];
if ( v6 )
{
v7 = v3[2];
*(_DWORD *)(v7 + 12) = v6;
*(_DWORD *)(v3[3] + 8) = v7;
return (_DWORD *)off_ABAE70(v3[1]);
}
else
{
v3[5] = 0;
v3[4] = 0;
result[1] = 0;
}
}
return result;
}