//
// LevelInfoLayer::setupPlatformerStats from 0x1402fa2d0 to 0x1402fa6f9 (1065 bytes)
//
// 2 xrefs:
// > LevelInfoLayer::init @ 0x1402f8130
// > ??> @ 0x1406d4160
//
// 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
//
// Hidden C++ exception states: #wind=4
void LevelInfoLayer::setupPlatformerStats(LevelInfoLayer *a1)
{
cocos2d::CCDirector *v2; // rax
unsigned __int64 v3; // rdx
int m_bestTime; // r8d
int v5; // r9d
int v6; // r8d
int v7; // r11d
int v8; // r10d
cocos2d::CCString *v9; // rax
char *CString; // rax
size_t v11; // rbx
size_t v12; // r8
cocos2d::CCString *v13; // rax
cocos2d::CCString *v14; // rax
void **v15; // rdx
cocos2d::CCString *v16; // rax
char *v17; // rax
void **v18; // rcx
struct cocos2d::CCLabelBMFont *v19; // rsi
float v20; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v21; // rbx
const cocos2d::CCPoint *v22; // rax
signed int m_bestPoints; // edx
char **v24; // rax
__int64 v25; // rdx
char **v26; // rax
void **v27; // rcx
cocos2d::CCLabelBMFont *v28; // rdi
float v29; // xmm0_4
__int64 v30; // rax
void *v31; // rcx
void *v32; // rcx
float v33; // [rsp+38h] [rbp-49h]
cocos2d::CCPoint v34; // [rsp+40h] [rbp-41h] BYREF
void *v35[2]; // [rsp+50h] [rbp-31h] BYREF
__int64 v36; // [rsp+60h] [rbp-21h]
unsigned __int64 v37; // [rsp+68h] [rbp-19h]
void *Block[2]; // [rsp+70h] [rbp-11h] BYREF
__int128 v39; // [rsp+80h] [rbp-1h]
__m128i v40[2]; // [rsp+90h] [rbp+Fh] BYREF
v2 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v2);
v36 = 12;
v3 = 15;
v37 = 15;
strcpy((char *)v35, "No Best Time");
BYTE5(v35[1]) = 0;
HIWORD(v35[1]) = 0;
m_bestTime = a1->m_level->m_bestTime;
if ( m_bestTime > 0 )
{
v5 = m_bestTime / 1000;
v6 = m_bestTime % 1000;
v7 = v5 % 60;
v8 = v5 / 60 % 60;
if ( v5 / 3600 )
{
v14 = cocos2d::CCString::createWithFormat("%02d:%02d:%02d.%03d", v5 / 3600, v8, v7, v6);
CString = (char *)cocos2d::CCString::getCString(v14);
v11 = -1;
v12 = -1;
do
++v12;
while ( CString[v12] );
}
else if ( v8 )
{
v13 = cocos2d::CCString::createWithFormat("%02d:%02d.%03d", v8, v7, v6);
CString = (char *)cocos2d::CCString::getCString(v13);
v11 = -1;
v12 = -1;
do
++v12;
while ( CString[v12] );
}
else
{
v9 = cocos2d::CCString::createWithFormat("%i.%03d", v7, v6);
CString = (char *)cocos2d::CCString::getCString(v9);
v11 = -1;
v12 = -1;
do
++v12;
while ( CString[v12] );
}
sub_14003CCE0(v35, CString, v12);
v15 = v35;
if ( v37 > 0xF )
v15 = (void **)v35[0];
v16 = cocos2d::CCString::createWithFormat("Best Time: %s", (const char *)v15);
v17 = (char *)cocos2d::CCString::getCString(v16);
do
++v11;
while ( v17[v11] );
sub_14003CCE0(v35, v17, v11);
v3 = v37;
}
v18 = v35;
if ( v3 > 0xF )
v18 = (void **)v35[0];
v19 = cocos2d::CCLabelBMFont::create((const char *)v18, "goldFont.fnt");
v20 = ((float (__fastcall *)(LevelInfoLayer *, struct cocos2d::CCLabelBMFont *, __int64))a1->addChild_0)(a1, v19, 3);
v21 = v19->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v20, v33 * 0.5);
v21->setPosition_0(v19, v22);
cocos2d::CCLabelBMFont::limitLabelWidth(v19, 200.0, 0.60000002, 0.0);
m_bestPoints = a1->m_level->m_bestPoints;
if ( m_bestPoints )
{
v24 = (char **)GameToolbox::pointsToString(v40, m_bestPoints);
v26 = sub_140137610(v24, v25, "Best Points: ", 0xDu);
*(_OWORD *)Block = 0;
v39 = 0;
*(_OWORD *)Block = *(_OWORD *)v26;
v39 = *((_OWORD *)v26 + 1);
v26[2] = nullptr;
v26[3] = (char *)15;
*(_BYTE *)v26 = 0;
sub_14003A830((__int64)v40);
v27 = Block;
if ( *((_QWORD *)&v39 + 1) > 0xFu )
v27 = (void **)Block[0];
v28 = cocos2d::CCLabelBMFont::create((const char *)v27, "goldFont.fnt");
v29 = ((float (__fastcall *)(LevelInfoLayer *, cocos2d::CCLabelBMFont *, __int64))a1->addChild_0)(a1, v28, 3);
cocos2d::CCPoint::CCPoint(v29, 0.0);
v30 = (__int64)v19->getPosition_0(v19);
cocos2d::CCPoint::operator+(v30, &v34);
v28->setPosition_0(v28, &v34);
cocos2d::CCLabelBMFont::limitLabelWidth(v28, 200.0, 0.60000002, 0.0);
if ( *((_QWORD *)&v39 + 1) > 0xFu )
{
v31 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v39 + 1) + 1LL) >= 0x1000 )
{
v31 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v31 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v31);
}
}
if ( v37 > 0xF )
{
v32 = v35[0];
if ( v37 + 1 >= 0x1000 )
{
v32 = *((void **)v35[0] - 1);
if ( (unsigned __int64)((char *)v35[0] - (char *)v32 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v32);
}
}