//
// DeathStatsPopup::showResult from 0xca8454 to 0xca8968 (1300 bytes)
//
// 2 xrefs:
// > DeathStatsPopup::pollFetch @ 0xca8a00
// > ??> @ 0xa56e8
//
// 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 13:06:03 +0000
//
__int64 __fastcall DeathStatsPopup::showResult(DeathStatsPopup *this)
{
GameLevelManager *v2; // x0
__int64 *DeathDisplayData; // x0
GameLevelManager *v4; // x0
GameLevelManager *DeathDataVersion; // x0
unsigned int v6; // w24
GameLevelManager *v7; // x0
int v8; // w22
size_t v9; // x2
const char *v10; // x1
cocos2d::CCString *v11; // x0
const char *CString; // x0
char *v14; // x20
_BYTE *v15; // x0
size_t v16; // x20
int v17; // w3
size_t v18; // x0
unsigned int v19; // w20
char *v20; // x4
unsigned __int64 v21; // x0
int v22; // w1
__int64 v23; // x0
unsigned __int64 v24; // x3
unsigned __int64 v25; // x6
unsigned __int64 v26; // x2
int v27; // w1
unsigned int v28; // w26
__int64 v29; // x0
__int64 v30; // x23
size_t v31; // x22
unsigned __int64 v32; // x0
unsigned __int64 v33; // x27
void *v34; // x3
cocos2d::CCString *v35; // x0
const char *v36; // x0
unsigned __int64 v37; // x0
__int64 v38; // x28
void *v39; // x0
void *v40; // x3
char *v41; // x22
void *v42; // [xsp+68h] [xbp+68h]
void *v43; // [xsp+70h] [xbp+70h]
char *v44; // [xsp+78h] [xbp+78h]
void *v45; // [xsp+78h] [xbp+78h]
__int64 v46; // [xsp+88h] [xbp+88h] BYREF
size_t v47; // [xsp+90h] [xbp+90h]
void *v48; // [xsp+98h] [xbp+98h]
__int64 v49; // [xsp+A0h] [xbp+A0h] BYREF
size_t v50; // [xsp+A8h] [xbp+A8h]
void *v51; // [xsp+B0h] [xbp+B0h]
__int64 v52; // [xsp+B8h] [xbp+B8h] BYREF
unsigned __int64 v53; // [xsp+C0h] [xbp+C0h]
void *v54; // [xsp+C8h] [xbp+C8h]
__int64 v55[2]; // [xsp+D0h] [xbp+D0h] BYREF
char *v56; // [xsp+E0h] [xbp+E0h]
v2 = (GameLevelManager *)GameLevelManager::sharedState(_stack_chk_guard);
DeathDisplayData = GameLevelManager::getDeathDisplayData(&v46, v2, *((_DWORD *)this + 262));
v4 = (GameLevelManager *)GameLevelManager::sharedState((GameLevelManager *)DeathDisplayData);
DeathDataVersion = (GameLevelManager *)GameLevelManager::getDeathDataVersion(v4, *((_DWORD *)this + 262));
v6 = (unsigned int)DeathDataVersion;
v7 = (GameLevelManager *)GameLevelManager::sharedState(DeathDataVersion);
GameLevelManager::evictDeathDataCache(v7, *((_DWORD *)this + 262));
v8 = v46 & 1;
if ( v8 )
{
v9 = v47;
if ( !v47 )
{
LABEL_3:
v10 = (const char *)*((unsigned int *)this + 262);
if ( *((int *)this + 263) <= 0 )
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"No death data for level %d.",
v10);
else
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"No death data for level %d (v%d).",
v10);
CString = (const char *)cocos2d::CCString::getCString(v11);
DeathStatsPopup::setStatus(this, CString);
goto LABEL_6;
}
v14 = (char *)v48;
}
else
{
LODWORD(v9) = (int)(unsigned __int8)v46 >> 1;
if ( !(_DWORD)v9 )
goto LABEL_3;
v9 = (int)v9;
v14 = (char *)&v46 + 1;
}
v15 = memchr(v14, 124, v9);
if ( !v15 || (v16 = v15 - v14, v16 == -1) )
{
v49 = 0;
v50 = 0;
v51 = nullptr;
if ( v8 )
{
std::string::__init(&v49, v48, v47);
}
else
{
v51 = v48;
v49 = v46;
v50 = v47;
}
v52 = 0;
v53 = 0;
v54 = nullptr;
std::string::__init(&v52, &byte_11B8890, 0);
}
else
{
std::string::basic_string(&v49, (__int64)&v46, 0, v16);
std::string::basic_string(&v52, (__int64)&v46, v16 + 1, 0xFFFFFFFFFFFFFFFFLL);
}
v17 = v49 & 1;
v18 = (unsigned __int8)v49 >> 1;
if ( v17 )
v18 = v50;
v19 = 0;
if ( v18 )
{
v20 = (char *)v51;
if ( !v17 )
v20 = (char *)&v49 + 1;
v21 = 0;
v19 = 1;
if ( !v17 )
goto LABEL_28;
while ( v21 < v50 )
{
while ( 1 )
{
v22 = (unsigned __int8)v20[v21++];
if ( v22 == 59 )
++v19;
if ( v17 )
break;
LABEL_28:
if ( v21 >= (unsigned __int8)v49 >> 1 )
goto LABEL_29;
}
}
}
LABEL_29:
v23 = 1;
v24 = 0;
v25 = (unsigned __int8)v52 >> 1;
v26 = 0;
v27 = 0;
if ( (v52 & 1) == 0 )
goto LABEL_34;
LABEL_30:
if ( v24 > v53 )
goto LABEL_41;
if ( v24 == v53 || *((_BYTE *)v54 + v24) == 44 )
goto LABEL_37;
while ( 1 )
{
do
{
++v24;
++v23;
if ( (v52 & 1) != 0 )
goto LABEL_30;
LABEL_34:
if ( v24 > v25 )
{
LABEL_41:
v28 = 0;
goto LABEL_42;
}
}
while ( v24 != v25 && *((_BYTE *)&v52 + v24 + 1) != 44 );
LABEL_37:
if ( v27 == 101 )
break;
++v27;
v26 = v23;
}
std::string::basic_string(v55, (__int64)&v52, v26, v24 - v26);
if ( (v55[0] & 1) != 0 )
{
v41 = v56;
v28 = atoi(v56);
operator delete(v41);
}
else
{
v28 = atoi((const char *)v55 + 1);
}
LABEL_42:
v29 = *((_QWORD *)this + 127);
if ( v29 )
{
v30 = *(_QWORD *)(v29 + 1936);
if ( v30 )
{
*(_DWORD *)(v30 + 1752) = *((_DWORD *)this + 262);
*(_DWORD *)(v30 + 1756) = v6;
if ( &v46 != (__int64 *)(v30 + 1760) )
{
if ( (v46 & 1) != 0 )
{
v44 = (char *)v48;
v31 = v47;
if ( (*(_BYTE *)(v30 + 1760) & 1) != 0 )
goto LABEL_47;
LABEL_59:
if ( v31 > 0x16 )
{
if ( v31 - 22 <= 0xFFFFFFFFFFFFFFD8LL )
{
v33 = 22;
v43 = (void *)(v30 + 1761);
goto LABEL_62;
}
LABEL_79:
sub_6309F8();
}
v34 = (void *)(v30 + 1761);
LABEL_49:
if ( v31 )
v34 = memmove(v34, v44, v31);
*((_BYTE *)v34 + v31) = 0;
if ( (*(_BYTE *)(v30 + 1760) & 1) != 0 )
*(_QWORD *)(v30 + 1768) = v31;
else
*(_BYTE *)(v30 + 1760) = 2 * v31;
}
else
{
v44 = (char *)&v46 + 1;
v31 = (unsigned __int8)v46 >> 1;
if ( (*(_BYTE *)(v30 + 1760) & 1) == 0 )
goto LABEL_59;
LABEL_47:
v32 = *(_QWORD *)(v30 + 1760) & 0xFFFFFFFFFFFFFFFELL;
v33 = v32 - 1;
if ( v31 <= v32 - 1 )
{
v34 = *(void **)(v30 + 1776);
goto LABEL_49;
}
if ( v31 - v33 > -17LL - v32 )
goto LABEL_79;
v43 = *(void **)(v30 + 1776);
if ( v33 <= 0x7FFFFFFFFFFFFFE6LL )
{
LABEL_62:
v37 = 2 * v33;
v38 = 23;
if ( 2 * v33 < v31 )
v37 = v31;
if ( v37 > 0x16 )
v38 = (v37 + 16) & 0xFFFFFFFFFFFFFFF0LL;
}
else
{
v38 = -17;
}
v39 = (void *)operator new(v38);
v40 = v39;
if ( v31 )
{
v42 = v39;
memcpy(v39, v44, v31);
v40 = v42;
}
if ( v33 != 22 )
{
v45 = v40;
operator delete(v43);
v40 = v45;
}
*(_QWORD *)(v30 + 1776) = v40;
*(_QWORD *)(v30 + 1760) = v38 | 1;
*(_QWORD *)(v30 + 1768) = v31;
*((_BYTE *)v40 + v31) = 0;
}
}
LevelEditorLayer::rebuildDeathOverlay(*((LevelEditorLayer **)this + 127));
}
}
v35 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"v%d %d players %d spots",
(const char *)v6,
v28,
v19);
v36 = (const char *)cocos2d::CCString::getCString(v35);
DeathStatsPopup::setStatus(this, v36);
if ( (v52 & 1) != 0 )
operator delete(v54);
if ( (v49 & 1) != 0 )
operator delete(v51);
LABEL_6:
if ( (v46 & 1) != 0 )
operator delete(v48);
return _stack_chk_guard;
}