//
// sub_1000D65AC from 0x1000d65ac to 0x1000d67e8 (572 bytes)
//
// 2 xrefs:
// > sub_1000D6540 @ 0x1000d655c
// > LevelListLayer::updateResultArray @ 0x1002e38b4
//
// 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 10:58:56 +0000
//
__int64 __fastcall sub_1000D65AC(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // x19
unsigned int *v3; // x9
__int64 v4; // x8
__int64 *v5; // x21
unsigned __int64 v6; // x22
__int64 v7; // x24
__int64 v8; // x20
int *v9; // x21
int *v10; // x26
int v11; // w27
__int64 v12; // x25
__int64 v13; // x23
char *ListSnapshot; // x24
__int64 v15; // x0
__int64 SavedLevel; // x24
__int64 v17; // x23
char *v18; // x23
int v20; // w24
float v21; // s0
std::string __str; // [xsp+8h] [xbp-B8h] BYREF
void *__p[2]; // [xsp+20h] [xbp-A0h] BYREF
char v25; // [xsp+37h] [xbp-89h]
int v26; // [xsp+3Ch] [xbp-84h] BYREF
_QWORD v27[4]; // [xsp+40h] [xbp-80h] BYREF
int v28; // [xsp+60h] [xbp-60h]
v2 = a1;
memset(v27, 0, sizeof(v27));
v28 = 1065353216;
if ( a2 )
{
v3 = *(unsigned int **)(a2 + 56);
v4 = *v3;
if ( (_DWORD)v4 )
{
v5 = *((__int64 **)v3 + 2);
v6 = (unsigned __int64)&v5[v4 - 1];
do
{
v7 = *v5;
if ( !*v5 )
break;
v26 = *(_DWORD *)(v7 + 328) - *(_DWORD *)(v7 + 332);
__p[0] = &v26;
a1 = sub_10001A978((unsigned __int64)v27, &v26, (__int64)&unk_10075DB65, (_DWORD **)__p);
a1[3] = v7;
++v5;
}
while ( (unsigned __int64)v5 <= v6 );
}
}
v8 = sub_1002E736C(a1);
v9 = (int *)v2[40];
v10 = (int *)v2[41];
if ( v9 != v10 )
{
v11 = 1;
do
{
if ( sub_100019268(v27, v9) )
{
__p[0] = v9;
v12 = sub_10001A978((unsigned __int64)v27, v9, (__int64)&unk_10075DB65, (_DWORD **)__p)[3];
v13 = v2[67];
ListSnapshot = GJGameLevel::getListSnapshot(v12);
GameToolbox::intToString((unsigned int)(*(_DWORD *)(v12 + 328) - *(_DWORD *)(v12 + 332)), __p);
cocos2d::CCDictionary::setObject(v13, ListSnapshot, __p);
if ( v25 < 0 )
operator delete(__p[0]);
}
v15 = GameLevelManager::sharedState();
SavedLevel = GameLevelManager::getSavedLevel(v15, *v9);
v17 = v2[67];
GameToolbox::intToString((unsigned int)*v9, __p);
v18 = (char *)cocos2d::CCDictionary::objectForKey(v17, __p);
if ( v25 < 0 )
{
operator delete(__p[0]);
if ( !SavedLevel )
{
LABEL_20:
if ( !v18 )
{
v18 = (char *)GJGameLevel::create_1();
v20 = *v9;
*((_DWORD *)v18 + 84) = *v9;
v21 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
*((_DWORD *)v18 + 83) = (int)v21;
*((_DWORD *)v18 + 82) = v20 + (int)v21;
GameToolbox::intToString((unsigned int)*v9, &__str);
std::string::operator=((std::string *)(v18 + 344), &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}
goto LABEL_23;
}
}
else if ( !SavedLevel )
{
goto LABEL_20;
}
if ( *(_BYTE *)(SavedLevel + 1105) != 1 || v18 == nullptr )
v18 = (char *)SavedLevel;
LABEL_23:
*((_DWORD *)v18 + 309) = v11;
sub_1002E74E0(v8, v18);
++v11;
++v9;
}
while ( v9 != v10 );
}
sub_1000184EC((__int64)v27);
return v8;
}