//
// GameLevelManager::writePlatformerSaveJournal from 0x10054c550 to 0x10054c969 (1049 bytes)
//
// 1 xrefs:
// > PlayLayer::onQuit @ 0x10008048d
//
// This function is hookable on this platform (idp: pc, 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:32:01 +0000
//
void __fastcall GameLevelManager::writePlatformerSaveJournal(__int64 a1, __int64 a2)
{
unsigned int v3; // r12d
unsigned int v4; // eax
std::mutex *v5; // rbx
_QWORD *v6; // r14
void *v7; // rdi
_BYTE *v8; // r13
const char *v9; // rsi
char *v10; // rsi
unsigned __int8 v11; // al
__int128 *v12; // r12
__int64 v13; // rax
int v14; // edx
unsigned __int64 v15; // rcx
int v16; // edx
unsigned __int64 v17; // rax
__int64 v18; // rsi
unsigned __int64 v19; // rcx
_BYTE *v20; // r13
__int64 i; // rcx
void *v22; // rdi
std::string v23; // [rsp+8h] [rbp-78h] BYREF
__int128 v24; // [rsp+20h] [rbp-60h] BYREF
void *__p; // [rsp+30h] [rbp-50h]
unsigned __int8 v26; // [rsp+40h] [rbp-40h] BYREF
_BYTE v27[7]; // [rsp+41h] [rbp-3Fh] BYREF
unsigned __int64 v28; // [rsp+48h] [rbp-38h]
void *v29; // [rsp+50h] [rbp-30h]
if ( !a2 )
return;
v3 = *(_DWORD *)(a2 + 1140);
if ( v3 - 4 < 0xFFFFFFFE || v3 != 2 && *(_DWORD *)(a2 + 328) <= *(_DWORD *)(a2 + 332) )
return;
v4 = *(unsigned __int8 *)(a2 + 1472);
if ( (v4 & 1) != 0 )
{
if ( !*(_QWORD *)(a2 + 1480) )
return;
}
else if ( !(v4 >> 1) )
{
return;
}
v5 = qword_100BE5588;
std::mutex::lock(qword_100BE5588);
v6 = operator new(0xF0u);
sub_100158EB0((__int64)v6);
if ( !(unsigned __int8)sub_10054C9E0(v6) )
{
v7 = (void *)v6[26];
if ( v7 )
{
v6[27] = v7;
operator delete(v7);
}
pugi::xml_document::dxml_document(v6);
operator delete(v6);
v6 = operator new(0xF0u);
sub_100158EB0((__int64)v6);
}
sub_10054CB00(&v26, a2);
v8 = v27;
v9 = v27;
if ( (v26 & 1) != 0 )
v9 = (const char *)v29;
DS_Dictionary::removeKey_1((__int64)v6, v9);
v10 = v27;
if ( (v26 & 1) != 0 )
v10 = (char *)v29;
DS_Dictionary::setSubDictForKey((__int64)v6, v10, 0, 1);
DS_Dictionary::setIntegerForKey_1((__int64)v6, (__int64)"t", v3);
DS_Dictionary::setIntegerForKey_1(
(__int64)v6,
(__int64)"id",
(unsigned int)(*(_DWORD *)(a2 + 328) - *(_DWORD *)(a2 + 332)));
DS_Dictionary::setIntegerForKey_1(
(__int64)v6,
(__int64)"did",
(unsigned int)(*(_DWORD *)(a2 + 920) - *(_DWORD *)(a2 + 924)));
DS_Dictionary::setBoolForKey_1((__int64)v6, (__int64)"g", *(unsigned __int8 *)(a2 + 649));
if ( v3 != 2 )
{
LOWORD(v24) = 0;
goto LABEL_28;
}
v11 = *(_BYTE *)(a2 + 1440);
if ( (v11 & 1) != 0 )
{
v12 = (__int128 *)(a2 + 1440);
if ( *(_QWORD *)(a2 + 1448) )
{
LABEL_20:
if ( (v11 & 1) == 0 )
{
LABEL_21:
__p = *((void **)v12 + 2);
v24 = *v12;
goto LABEL_28;
}
goto LABEL_27;
}
}
else
{
v12 = (__int128 *)(a2 + 1440);
if ( v11 >> 1 )
goto LABEL_20;
}
sub_1004EF000(&v23, 16);
if ( (*(_BYTE *)v12 & 1) != 0 )
operator delete(*(void **)(a2 + 1456));
*(std::string *)v12 = v23;
if ( (*(_BYTE *)v12 & 1) == 0 )
goto LABEL_21;
LABEL_27:
sub_10001AD30(&v24, *(const void **)(a2 + 1456), *(_QWORD *)(a2 + 1448));
LABEL_28:
DS_Dictionary::setStringForKey_1((__int64)v6, (__int64)"uid", (__int64)&v24);
if ( (v24 & 1) != 0 )
operator delete(__p);
DS_Dictionary::setStringForKey_1((__int64)v6, (__int64)"cs", a2 + 1472);
DS_Dictionary::setIntegerForKey_1((__int64)v6, (__int64)"cv", *(unsigned int *)(a2 + 1520));
DS_Dictionary::setIntegerForKey_1((__int64)v6, (__int64)"fv", *(unsigned int *)(a2 + 1524));
DS_Dictionary::setStringForKey_1((__int64)v6, (__int64)"rs", a2 + 1496);
DS_Dictionary::setBoolForKey_1((__int64)v6, (__int64)"ps", *(unsigned __int8 *)(a2 + 1528));
DS_Dictionary::setIntegerForKey_1((__int64)v6, (__int64)"sq", (unsigned int)++dword_100BE5590);
v13 = GJAccountManager::sharedState((__int64)v6, (__int64)"sq");
v14 = *(_DWORD *)(v13 + 352) - *(_DWORD *)(v13 + 356);
if ( (v26 & 1) != 0 )
{
v15 = v28;
v16 = -1640531535 * v14;
if ( !v28 )
goto LABEL_43;
LABEL_34:
if ( (v26 & 1) != 0 )
v8 = v29;
v17 = v15 & 3;
if ( v15 >= 4 )
{
v19 = v15 & 0xFFFFFFFFFFFFFFFCLL;
v18 = 0;
do
{
v16 = 16777619
* ((16777619
* ((16777619 * ((16777619 * (v16 ^ (unsigned __int8)v8[v18])) ^ (unsigned __int8)v8[v18 + 1]))
^ (unsigned __int8)v8[v18 + 2]))
^ (unsigned __int8)v8[v18 + 3]);
v18 += 4;
}
while ( v19 != v18 );
}
else
{
v18 = 0;
}
if ( v17 )
{
v20 = &v8[v18];
for ( i = 0; i != v17; ++i )
v16 = 16777619 * (v16 ^ (unsigned __int8)v20[i]);
}
goto LABEL_43;
}
v15 = v26 >> 1;
v16 = -1640531535 * v14;
if ( v26 >> 1 )
goto LABEL_34;
LABEL_43:
DS_Dictionary::setIntegerForKey_1((__int64)v6, (__int64)"ow", v16 & 0x7FFFFFFF);
DS_Dictionary::stepOutOfSubDict((__int64)v6);
sub_10054CEA0(v6);
v22 = (void *)v6[26];
if ( v22 )
{
v6[27] = v22;
operator delete(v22);
}
pugi::xml_document::dxml_document(v6);
operator delete(v6);
if ( (v26 & 1) != 0 )
operator delete(v29);
std::mutex::unlock(v5);
}