//
// GJBaseGameLayer::parseRecording from 0x5b0888 to 0x5b0f68 (1760 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::setupReplay @ 0x5b0fd2
// > GJBaseGameLayer::restoreRecording @ 0x5b1024
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:53:32 +0000
//
unsigned int __fastcall GJBaseGameLayer::parseRecording(int a1, int a2, int a3)
{
const char *v3; // r8
int *v6; // r5
int v7; // r7
int v8; // r2
int v9; // r3
bool v10; // nf
size_t v11; // r0
unsigned int result; // r0
cocos2d::CCString *v13; // r0
const char *CString; // r0
const char *v15; // r8
size_t v16; // r0
unsigned int v17; // r8
int v18; // r6
cocos2d::CCString *v19; // r0
const char *v20; // r0
const char *v21; // r11
size_t v22; // r0
cocos2d::CCArray *v23; // r10
cocos2d::CCString *v24; // r0
const char *v25; // r11
size_t v26; // r0
const char *v27; // r0
int v28; // r0
int v29; // r0
bool v30; // r3
int v31; // r11
char *v32; // r3
int v33; // r3
cocos2d::CCString *v34; // r0
const char *v35; // r0
int v36; // r10
int v37; // r2
cocos2d::CCArray *v38; // r10
cocos2d::CCString *v39; // r0
size_t v40; // r0
_DWORD *v41; // r0
int v42; // r3
const char *v43; // r1
size_t v44; // r0
__int64 v45; // r0
int v46; // r3
_DWORD *v47; // r0
const char *v48; // r0
_DWORD *v49; // r0
const char *v50; // r0
_DWORD *v51; // r0
const char *v52; // r0
_DWORD *v53; // r0
const char *v54; // r0
_DWORD *v55; // r0
const char *v56; // r1
bool v57; // nf
size_t v58; // r0
__int64 v59; // r0
int v60; // r3
unsigned __int8 *v61; // r0
unsigned __int8 *v62; // r0
_DWORD *v63; // lr
int v64; // r1
int v65; // r2
int v66; // r3
cocos2d::CCString *v67; // r0
const char *v68; // r6
size_t v69; // r0
int v70; // r11
__int64 v71; // r6
const char *v72; // r0
int v73; // r5
unsigned __int64 v74; // r2
__int64 v75; // r0
int v76; // r5
cocos2d::CCArray *v77; // [sp+4h] [bp-138h]
cocos2d::CCArray *v78; // [sp+4h] [bp-138h]
cocos2d::CCArray *v79; // [sp+8h] [bp-134h]
unsigned int v80; // [sp+28h] [bp-114h]
const char *v81; // [sp+28h] [bp-114h]
const char *v82; // [sp+28h] [bp-114h]
const char *v83; // [sp+28h] [bp-114h]
int v84; // [sp+2Ch] [bp-110h]
int v85[3]; // [sp+34h] [bp-108h] BYREF
int v86; // [sp+40h] [bp-FCh] BYREF
int v87; // [sp+44h] [bp-F8h]
char *v88; // [sp+48h] [bp-F4h]
int v89[3]; // [sp+4Ch] [bp-F0h] BYREF
_DWORD **v90; // [sp+58h] [bp-E4h] BYREF
_DWORD *v91[2]; // [sp+5Ch] [bp-E0h] BYREF
int v92[3]; // [sp+64h] [bp-D8h] BYREF
int v93[3]; // [sp+70h] [bp-CCh] BYREF
int v94[3]; // [sp+7Ch] [bp-C0h] BYREF
int v95[3]; // [sp+88h] [bp-B4h] BYREF
int v96[3]; // [sp+94h] [bp-A8h] BYREF
int v97[3]; // [sp+A0h] [bp-9Ch] BYREF
int v98[3]; // [sp+ACh] [bp-90h] BYREF
int v99[3]; // [sp+B8h] [bp-84h] BYREF
int v100[3]; // [sp+C4h] [bp-78h] BYREF
int v101; // [sp+D0h] [bp-6Ch] BYREF
int v102; // [sp+D4h] [bp-68h]
int v103; // [sp+D8h] [bp-64h]
int v104; // [sp+DCh] [bp-60h] BYREF
int v105; // [sp+E0h] [bp-5Ch]
int v106; // [sp+E4h] [bp-58h]
int v107[4]; // [sp+E8h] [bp-54h] BYREF
_QWORD v108[7]; // [sp+F8h] [bp-44h] BYREF
if ( a3 )
{
v6 = (int *)(a1 + 11012);
v7 = a1 + 11024;
}
else
{
v6 = (int *)(a1 + 11048);
v7 = a1 + 11060;
}
v8 = *v6;
while ( 1 )
{
v9 = v6[1];
if ( v8 == v9 )
break;
v6[1] = v9 - 16;
}
v10 = (*(_BYTE *)a2 & 1) != 0;
if ( (*(_BYTE *)a2 & 1) == 0 )
v3 = (const char *)(a2 + 1);
LODWORD(v108[0]) = 0;
if ( v10 )
v3 = *(const char **)(a2 + 8);
HIDWORD(v108[0]) = 0;
LODWORD(v108[1]) = 0;
v11 = strlen(v3);
std::string::__init((int *)v108, v3, v11);
v77 = sub_5A09D0(v108, "#");
std::string::~string((int)v108);
result = cocos2d::CCArray::count(v77);
if ( result <= 1 )
return result;
v13 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v77, 0);
CString = (const char *)cocos2d::CCString::getCString(v13);
memset(v108, 0, 12);
v15 = CString;
v16 = strlen(CString);
std::string::__init((int *)v108, v15, v16);
v79 = sub_5A09D0(v108, ";");
std::string::~string((int)v108);
v17 = 0;
v18 = 0;
while ( v17 < cocos2d::CCArray::count(v79) )
{
v19 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v79, v17);
v20 = (const char *)cocos2d::CCString::getCString(v19);
memset(v85, 0, sizeof(v85));
v21 = v20;
v22 = strlen(v20);
std::string::__init(v85, v21, v22);
v23 = sub_5A09D0(v85, ",");
memset(v107, 0, sizeof(v107));
v24 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v23, 0);
v25 = (const char *)cocos2d::CCString::getCString(v24);
v86 = 0;
v87 = 0;
v88 = nullptr;
v26 = strlen(v25);
v27 = (const char *)std::string::__init(&v86, v25, v26);
v84 = v86 & 1;
if ( !v84 )
v27 = (char *)&v86 + 1;
v80 = (unsigned __int8)v86;
if ( (v86 & 1) != 0 )
v27 = v88;
v28 = atoi(v27);
v29 = abs(v28);
v30 = 1;
v107[0] = 1;
v31 = v29;
v18 += v29;
if ( v84 )
{
if ( !v87 )
goto LABEL_24;
v32 = v88;
}
else
{
if ( !(v80 >> 1) )
goto LABEL_24;
v32 = (char *)&v86 + 1;
}
v30 = *v32 != 45;
LABEL_24:
LOBYTE(v107[1]) = v30;
if ( a3 )
v33 = v29;
else
v33 = v18;
v107[2] = v33;
if ( cocos2d::CCArray::count(v23) > 1u )
{
v34 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v23, 1u);
v35 = (const char *)cocos2d::CCString::getCString(v34);
v36 = atoi(v35);
v107[0] = GJBaseGameLayer::buttonIDToButton((GJBaseGameLayer *)a1, v36);
BYTE1(v107[1]) = GJBaseGameLayer::isPlayer2Button((GJBaseGameLayer *)a1, v36);
if ( (unsigned int)(v107[0] - 98) <= 1 )
{
v37 = *(_DWORD *)(a1 + 11044);
*(_DWORD *)(a1 + 11044) = v37 + 1;
v107[3] = v37;
v38 = sub_5A09D0(v85, ":");
if ( cocos2d::CCArray::count(v38) > 1u )
{
v39 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v38, 1u);
v81 = (const char *)cocos2d::CCString::getCString(v39);
memset(v89, 0, sizeof(v89));
v40 = strlen(v81);
std::string::__init(v89, v81, v40);
v91[0] = nullptr;
v91[1] = nullptr;
v90 = v91;
GameToolbox::stringSetupToMap((unsigned __int8 *)v89, ",", (int *)&v90);
memset(v108, 0, sizeof(v108));
memset(v92, 0, sizeof(v92));
LODWORD(v108[0]) = v107[3];
std::string::__init(v92, a1i2r3e45s789g, 1u);
if ( std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__count_unique(
(int)&v90,
(unsigned __int8 *)v92) )
{
memset(v93, 0, sizeof(v93));
std::string::__init(v93, a1i2r3e45s789g, 1u);
v41 = std::map::operator[]((int *)&v90, v93);
v42 = *(unsigned __int8 *)v41;
v43 = (const char *)(v42 << 31);
if ( (v42 & 1) == 0 )
v43 = (char *)v41 + 1;
v94[0] = 0;
if ( (v42 & 1) != 0 )
v43 = (const char *)v41[2];
v94[1] = 0;
v94[2] = 0;
v82 = v43;
v44 = strlen(v43);
std::string::__init(v94, v82, v44);
LODWORD(v45) = std::stoull(v94, 0, 10);
v46 = 1;
}
else
{
v46 = 0;
v45 = 0;
}
v108[1] = v45;
if ( v46 )
{
std::string::~string((int)v94);
std::string::~string((int)v93);
}
std::string::~string((int)v92);
memset(v95, 0, sizeof(v95));
std::string::__init(v95, &a1i2r3e45s789g[4], 1u);
v47 = std::map::operator[]((int *)&v90, v95);
if ( (*(_BYTE *)v47 & 1) != 0 )
v48 = (const char *)v47[2];
else
v48 = (char *)v47 + 1;
LODWORD(v108[2]) = atoi(v48);
std::string::~string((int)v95);
memset(v96, 0, sizeof(v96));
std::string::__init(v96, &a1i2r3e45s789g[6], 1u);
v49 = std::map::operator[]((int *)&v90, v96);
if ( (*(_BYTE *)v49 & 1) != 0 )
v50 = (const char *)v49[2];
else
v50 = (char *)v49 + 1;
HIDWORD(v108[2]) = atoi(v50);
std::string::~string((int)v96);
memset(v97, 0, sizeof(v97));
std::string::__init(v97, &a1i2r3e45s789g[7], 1u);
v51 = std::map::operator[]((int *)&v90, v97);
if ( (*(_BYTE *)v51 & 1) != 0 )
v52 = (const char *)v51[2];
else
v52 = (char *)v51 + 1;
LODWORD(v108[4]) = atoi(v52);
std::string::~string((int)v97);
memset(v98, 0, sizeof(v98));
std::string::__init(v98, "6", 1u);
v53 = std::map::operator[]((int *)&v90, v98);
if ( (*(_BYTE *)v53 & 1) != 0 )
v54 = (const char *)v53[2];
else
v54 = (char *)v53 + 1;
HIDWORD(v108[4]) = atoi(v54);
std::string::~string((int)v98);
v101 = 0;
v102 = 0;
v103 = 0;
std::string::__init(&v101, &a1i2r3e45s789g[9], 1u);
if ( std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__count_unique(
(int)&v90,
(unsigned __int8 *)&v101) )
{
memset(v99, 0, sizeof(v99));
std::string::__init(v99, &a1i2r3e45s789g[9], 1u);
v55 = std::map::operator[]((int *)&v90, v99);
v57 = (*(_BYTE *)v55 & 1) != 0;
if ( (*(_BYTE *)v55 & 1) == 0 )
v56 = (char *)v55 + 1;
v100[0] = 0;
if ( v57 )
v56 = (const char *)v55[2];
v100[1] = 0;
v100[2] = 0;
v83 = v56;
v58 = strlen(v56);
std::string::__init(v100, v83, v58);
LODWORD(v59) = std::stoull(v100, 0, 10);
v60 = 1;
}
else
{
v60 = 0;
v59 = 0;
}
v108[3] = v59;
if ( v60 )
{
std::string::~string((int)v100);
std::string::~string((int)v99);
}
std::string::~string((int)&v101);
v104 = 0;
v105 = 0;
v106 = 0;
std::string::__init(&v104, &a1i2r3e45s789g[10], 1u);
v61 = (unsigned __int8 *)std::map::operator[]((int *)&v90, &v104);
std::string::operator=((unsigned __int8 *)&v108[5], v61);
std::string::~string((int)&v104);
v62 = (unsigned __int8 *)(std::unordered_map::operator[](v7, (unsigned int *)&v107[3])
+ 10);
*((_QWORD *)v62 - 5) = v108[0];
*((_QWORD *)v62 - 4) = v108[1];
*((_QWORD *)v62 - 3) = v108[2];
*((_QWORD *)v62 - 2) = v108[3];
*((_QWORD *)v62 - 1) = v108[4];
std::string::operator=(v62, (unsigned __int8 *)&v108[5]);
v107[2] = v31;
std::string::~string((int)&v108[5]);
v18 = v31;
std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::destroy(
(int)&v90,
v91[0]);
std::string::~string((int)v89);
}
}
}
v63 = (_DWORD *)v6[1];
if ( v63 == (_DWORD *)v6[2] )
{
std::vector::__push_back_slow_path(v6, v107);
}
else
{
if ( v63 )
{
v64 = v107[1];
v65 = v107[2];
v66 = v107[3];
*v63 = v107[0];
v63[1] = v64;
v63[2] = v65;
v63[3] = v66;
}
v6[1] += 16;
}
++v17;
std::string::~string((int)&v86);
std::string::~string((int)v85);
}
memset(v107, 0, 12);
v67 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v77, 1u);
v68 = (const char *)cocos2d::CCString::getCString(v67);
v101 = 0;
v102 = 0;
v103 = 0;
v69 = strlen(v68);
std::string::__init(&v101, v68, v69);
sub_5A0B4C((unsigned __int8 *)&v101, v107);
std::string::~string((int)&v101);
v70 = -1431655765 * ((v107[1] - v107[0]) >> 2);
if ( v70 <= 0 )
{
v71 = 0;
goto LABEL_75;
}
v71 = std::stoull(v107[0], 0, 10);
if ( v70 == 1 )
{
LABEL_75:
v73 = 0;
goto LABEL_76;
}
v78 = (cocos2d::CCArray *)v107[0];
if ( (*(_BYTE *)(v107[0] + 12) & 1) != 0 )
v72 = *(const char **)(v107[0] + 20);
else
v72 = (const char *)(v107[0] + 13);
v73 = atoi(v72);
if ( v70 > 5 )
{
std::string::basic_string(&v104, (int)v78 + 60);
goto LABEL_77;
}
LABEL_76:
v104 = 0;
v105 = 0;
v106 = 0;
std::string::__init(&v104, &unk_B6B226, 0);
LABEL_77:
if ( a3 )
{
*(_QWORD *)(a1 + 10976) = v71;
*(_DWORD *)(a1 + 11132) = v73;
std::string::operator=((unsigned __int8 *)(a1 + 11120), (unsigned __int8 *)&v104);
}
else
{
LODWORD(v74) = 10588;
*(_QWORD *)(a1 + 10984) = v71;
LODWORD(v75) = v71;
if ( v73 <= 1 )
HIDWORD(v74) = 0;
else
HIDWORD(v74) = v73 - 1;
HIDWORD(v75) = HIDWORD(v71);
*(_DWORD *)(a1 + 10588) = HIDWORD(v74);
GameToolbox::fast_srand(v75, v74);
v76 = *(_DWORD *)(a1 + 1524);
std::string::basic_string((int *)v108, (int)&v104);
GJEffectManager::loadPersistentStateString(v76, v108);
std::string::~string((int)v108);
}
std::string::~string((int)&v104);
return std::__vector_base::~__vector_base((int)v107);
}