//
// GJGameLevel::handleStatsConflict from 0x739428 to 0x7398f4 (1228 bytes)
//
// 6 xrefs:
// > GameLevelManager::dataLoaded @ 0x7399d0
// > GameLevelManager::dataLoaded @ 0x739b18
// > GameLevelManager::dataLoaded @ 0x739cc0
// > GameLevelManager::dataLoaded @ 0x739e40
// > LocalLevelManager::dataLoaded @ 0x7e9aac
// > ??> @ 0xc6f18
//
// 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
//
void GJGameLevel::handleStatsConflict(GJGameLevel *a1)
{
GJGameLevel *v1; // x1
GJGameLevel *v3; // x20
int v4; // w21
int v5; // w0
__int64 v6; // x0
int v7; // w0
int v8; // w1
float v9; // s0
int v10; // w21
int v11; // w0
int v12; // w1
float v13; // s0
int v14; // w21
int v15; // w1
int NormalPercent; // w21
int v17; // w0
int v18; // w21
int v19; // w0
int v20; // w24
int m_bestTime; // w25
float v22; // s0
int v23; // w21
int v24; // w26
void *v25; // x0
int m_bestPoints; // w26
int v27; // w26
void *v28; // x0
int m_practicePercent; // w0
int m_levelIndex; // w1
int v31; // w0
float v32; // s0
int v33; // w21
float v34; // s0
int v35; // w21
float v36; // s8
void *v37; // x23
unsigned int *v38; // x1
int v39; // w2
unsigned int *v40; // x1
int v41; // w2
unsigned int *v42; // x21
int v43; // w0
int m_ticksTime; // [xsp+68h] [xbp+68h]
int m_ticksPoints; // [xsp+68h] [xbp+68h]
int m_clicksTime; // [xsp+70h] [xbp+70h]
int m_clicksPoints; // [xsp+70h] [xbp+70h]
int m_coinsTime; // [xsp+78h] [xbp+78h]
int m_coinsPoints; // [xsp+78h] [xbp+78h]
_QWORD v50[2]; // [xsp+90h] [xbp+90h] BYREF
v3 = v1;
v4 = v1->m_attempts.random - v1->m_attempts.seed;
v5 = a1->m_attempts.random - a1->m_attempts.seed;
if ( v5 >= v4 )
v4 = v5;
v6 = _stack_chk_guard;
a1->m_attempts.value = v4;
v50[1] = v6;
v7 = rand();
v8 = a1->m_jumps.random - a1->m_jumps.seed;
v9 = (float)((float)v7 * 4.6566e-10) * 1000.0;
a1->m_attempts.seed = (int)v9;
a1->m_attempts.random = (int)v9 + v4;
v10 = v3->m_jumps.random - v3->m_jumps.seed;
if ( v8 >= v10 )
v10 = v8;
a1->m_jumps.value = v10;
v11 = rand();
v12 = a1->m_clicks.random - a1->m_clicks.seed;
v13 = (float)((float)v11 * 4.6566e-10) * 1000.0;
a1->m_jumps.seed = (int)v13;
a1->m_jumps.random = (int)v13 + v10;
v14 = v3->m_clicks.random - v3->m_clicks.seed;
if ( v12 >= v14 )
v14 = v12;
a1->m_clicks.value = v14;
v15 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
a1->m_clicks.seed = v15;
a1->m_clicks.random = v15 + v14;
NormalPercent = GJGameLevel::getNormalPercent(a1);
if ( NormalPercent >= GJGameLevel::getNormalPercent(v3) )
v17 = GJGameLevel::getNormalPercent(a1);
else
v17 = GJGameLevel::getNormalPercent(v3);
GJGameLevel::setNormalPercent(a1, v17);
v18 = a1->m_orbCompletion.random - a1->m_orbCompletion.seed;
if ( v18 < v3->m_orbCompletion.random - v3->m_orbCompletion.seed )
v18 = v3->m_orbCompletion.random - v3->m_orbCompletion.seed;
a1->m_orbCompletion.value = v18;
v19 = rand();
v20 = a1->m_newNormalPercent2.random - a1->m_newNormalPercent2.seed;
m_bestTime = v3->m_bestTime;
m_ticksTime = v3->m_ticksTime;
m_clicksTime = v3->m_clicksTime;
m_coinsTime = v3->m_coinsTime;
v22 = (float)((float)v19 * 4.6566e-10) * 1000.0;
a1->m_orbCompletion.seed = (int)v22;
a1->m_orbCompletion.random = (int)v22 + v18;
v23 = v3->m_newNormalPercent2.random - v3->m_newNormalPercent2.seed;
sub_D18D28(v50);
v24 = (unsigned __int8)GJGameLevel::saveNewScore(
a1,
m_bestTime,
0,
m_ticksTime,
m_clicksTime,
m_coinsTime,
(__int64)v50,
0);
v25 = (void *)(v50[0] - 24LL);
if ( (__int64 *)(v50[0] - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v40 = (unsigned int *)(v50[0] - 8LL);
do
v41 = __ldaxr(v40);
while ( __stlxr(v41 - 1, v40) );
}
else
{
v41 = *(_DWORD *)(v50[0] - 8LL);
*(_DWORD *)(v50[0] - 8LL) = v41 - 1;
}
if ( v41 <= 0 )
operator delete(v25);
}
if ( v24 )
a1->m_savedTime = v3->m_savedTime;
m_bestPoints = v3->m_bestPoints;
m_ticksPoints = v3->m_ticksPoints;
m_clicksPoints = v3->m_clicksPoints;
m_coinsPoints = v3->m_coinsPoints;
sub_D18D28(v50);
v27 = (unsigned __int8)GJGameLevel::saveNewScore(
a1,
m_bestPoints,
1,
m_ticksPoints,
m_clicksPoints,
m_coinsPoints,
(__int64)v50,
0);
v28 = (void *)(v50[0] - 24LL);
if ( (__int64 *)(v50[0] - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v38 = (unsigned int *)(v50[0] - 8LL);
do
v39 = __ldaxr(v38);
while ( __stlxr(v39 - 1, v38) );
}
else
{
v39 = *(_DWORD *)(v50[0] - 8LL);
*(_DWORD *)(v50[0] - 8LL) = v39 - 1;
}
if ( v39 <= 0 )
operator delete(v28);
}
if ( v27 )
a1->m_savedPoints = v3->m_savedPoints;
if ( v20 < v23 )
{
a1->m_newNormalPercent2.value = v23;
v32 = (float)((float)rand() * 4.6566e-10) * 1000.0;
a1->m_newNormalPercent2.seed = (int)v32;
a1->m_newNormalPercent2.random = v23 + (int)v32;
v33 = v3->m_clicks.random - v3->m_clicks.seed;
a1->m_clicks.value = v33;
v34 = (float)((float)rand() * 4.6566e-10) * 1000.0;
a1->m_clicks.seed = (int)v34;
a1->m_clicks.random = v33 + (int)v34;
v35 = v3->m_attemptTime.random - v3->m_attemptTime.seed;
a1->m_attemptTime.value = v35;
v36 = (float)((float)rand() * 4.6566e-10) * 1000.0;
a1->m_attemptTime.seed = (int)v36;
a1->m_attemptTime.random = v35 + (int)v36;
a1->m_chk = v3->m_chk;
sub_D18D28(v50);
sub_D18EA8(&a1->m_personalBests, v50);
v37 = (void *)(v50[0] - 24LL);
if ( (__int64 *)(v50[0] - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v42 = (unsigned int *)(v50[0] - 8LL);
do
v43 = __ldaxr(v42);
while ( __stlxr(v43 - 1, v42) );
}
else
{
v43 = *(_DWORD *)(v50[0] - 8LL);
*(_DWORD *)(v50[0] - 8LL) = v43 - 1;
}
if ( v43 <= 0 )
operator delete(v37);
}
a1->m_isChkValid = v3->m_isChkValid;
}
m_practicePercent = v3->m_practicePercent;
m_levelIndex = a1->m_levelIndex;
if ( m_practicePercent < a1->m_practicePercent )
m_practicePercent = a1->m_practicePercent;
a1->m_practicePercent = m_practicePercent;
v31 = v3->m_levelIndex;
if ( v31 < m_levelIndex )
v31 = m_levelIndex;
a1->m_levelIndex = v31;
}