//
// GJGameLevel::handleStatsConflict from 0x100551010 to 0x100551c31 (3105 bytes)
//
// 5 xrefs:
// > GameLevelManager::dataLoaded @ 0x10054fb44
// > GameLevelManager::dataLoaded @ 0x10054fd82
// > GameLevelManager::dataLoaded @ 0x10054ffd2
// > GameLevelManager::dataLoaded @ 0x100550202
// > LocalLevelManager::dataLoaded @ 0x1006cb637
//
// 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:03 +0000
//
int __fastcall GJGameLevel::handleStatsConflict(__int64 a1, __int64 a2)
{
int v4; // r15d
float v5; // xmm0_4
int v6; // r15d
float v7; // xmm0_4
int v8; // r15d
float v9; // xmm0_4
int v10; // r15d
float v11; // xmm0_4
int v12; // r15d
float v13; // xmm0_4
__m128i si128; // xmm1
int v15; // r12d
unsigned __int64 v16; // rdx
const void *v17; // rsi
int v18; // r15d
int v19; // eax
int v20; // eax
char v21; // r13
__m128i v22; // xmm1
unsigned __int64 v23; // rdx
const void *v24; // rsi
__int64 v25; // rsi
int v26; // eax
int v27; // eax
char v28; // r13
int v29; // eax
int v30; // r15d
int v31; // eax
int v32; // r15d
float v33; // xmm0_4
int v34; // ecx
int v35; // eax
int v36; // edx
int v37; // ecx
int v38; // eax
unsigned int v39; // r15d
unsigned int v40; // r12d
size_t v41; // r12
const void *v42; // rdi
size_t v43; // r15
const void *v44; // rsi
size_t v45; // rdx
unsigned int v46; // eax
unsigned int v47; // eax
unsigned int v48; // eax
unsigned int v49; // eax
unsigned int v50; // eax
unsigned int v51; // eax
unsigned int v52; // eax
__int64 v53; // rax
unsigned int v54; // eax
unsigned int v55; // r15d
unsigned int v56; // r12d
size_t v57; // r12
const void *v58; // rdi
size_t v59; // r15
const void *v60; // rsi
size_t v61; // rdx
std::string __str; // [rsp+0h] [rbp-A0h] BYREF
std::string v64; // [rsp+20h] [rbp-80h] BYREF
std::string v65; // [rsp+40h] [rbp-60h] BYREF
int v66; // [rsp+5Ch] [rbp-44h]
__m128i v67[4]; // [rsp+60h] [rbp-40h] BYREF
v4 = *(_DWORD *)(a2 + 796) - *(_DWORD *)(a2 + 800);
if ( *(_DWORD *)(a1 + 796) - *(_DWORD *)(a1 + 800) > v4 )
v4 = *(_DWORD *)(a1 + 796) - *(_DWORD *)(a1 + 800);
*(_DWORD *)(a1 + 804) = v4;
v5 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
*(_DWORD *)(a1 + 800) = (int)v5;
*(_DWORD *)(a1 + 796) = (int)v5 + v4;
v6 = *(_DWORD *)(a2 + 808) - *(_DWORD *)(a2 + 812);
if ( *(_DWORD *)(a1 + 808) - *(_DWORD *)(a1 + 812) > v6 )
v6 = *(_DWORD *)(a1 + 808) - *(_DWORD *)(a1 + 812);
*(_DWORD *)(a1 + 816) = v6;
v7 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
*(_DWORD *)(a1 + 812) = (int)v7;
*(_DWORD *)(a1 + 808) = (int)v7 + v6;
v8 = *(_DWORD *)(a2 + 820) - *(_DWORD *)(a2 + 824);
if ( *(_DWORD *)(a1 + 820) - *(_DWORD *)(a1 + 824) > v8 )
v8 = *(_DWORD *)(a1 + 820) - *(_DWORD *)(a1 + 824);
*(_DWORD *)(a1 + 828) = v8;
v9 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
*(_DWORD *)(a1 + 824) = (int)v9;
*(_DWORD *)(a1 + 820) = (int)v9 + v8;
v10 = *(_DWORD *)(a2 + 860) - *(_DWORD *)(a2 + 856);
if ( *(_DWORD *)(a1 + 860) - *(_DWORD *)(a1 + 856) > v10 )
v10 = *(_DWORD *)(a1 + 860) - *(_DWORD *)(a1 + 856);
*(_DWORD *)(a1 + 852) = v10;
v11 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
*(_DWORD *)(a1 + 856) = (int)v11;
*(_DWORD *)(a1 + 860) = (int)v11 + v10;
v12 = *(_DWORD *)(a2 + 864) - *(_DWORD *)(a2 + 868);
if ( *(_DWORD *)(a1 + 864) - *(_DWORD *)(a1 + 868) > v12 )
v12 = *(_DWORD *)(a1 + 864) - *(_DWORD *)(a1 + 868);
*(_DWORD *)(a1 + 872) = v12;
v13 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
*(_DWORD *)(a1 + 868) = (int)v13;
*(_DWORD *)(a1 + 864) = (int)v13 + v12;
v66 = *(_DWORD *)(a1 + 876) - *(_DWORD *)(a1 + 880);
si128 = _mm_loadu_si128((const __m128i *)(a2 + 1296));
v15 = *(_DWORD *)(a2 + 876) - *(_DWORD *)(a2 + 880);
if ( (*(_BYTE *)(a2 + 1312) & 1) != 0 )
{
v16 = *(_QWORD *)(a2 + 1320);
v17 = *(const void **)(a2 + 1328);
v67[0] = si128;
sub_10001AD30(&__str, v17, v16);
si128 = _mm_load_si128(v67);
}
else
{
__str = *(std::string *)(a2 + 1312);
}
v67[0].i64[0] = (__int64)&__str.__r_.__value_.__l.__data_;
v18 = _mm_cvtsi128_si32(si128);
if ( v18 <= 0 || *(_DWORD *)(a1 + 1296) != 0 && *(_DWORD *)(a1 + 1296) <= v18 )
{
v21 = 0;
}
else
{
*(__m128i *)(a1 + 1296) = si128;
v19 = -*(_DWORD *)(a1 + 1336);
if ( *(int *)(a1 + 1336) > 0 )
v19 = *(_DWORD *)(a1 + 1336);
v20 = (int)(63 * (374 * (*(_DWORD *)(a1 + 1344) + _mm_extract_epi32(si128, 2)) % 18477)
+ 967 * ((v19 + 3456) % 0x13435u)
+ 601 * ((v18 + 7890) % 0x8707u)
+ 27 * (125 * (*(_DWORD *)(a1 + 1340) + _mm_extract_epi32(si128, 1)) % 28452)
+ 87 * (7284 * (*(_DWORD *)(a1 + 1348) + _mm_extract_epi32(si128, 3)) % 62374)
+ 94819)
% 94433;
*(_DWORD *)(a1 + 1376) = 829 * (v20 ^ (v20 >> 16)) % 77849;
std::string::operator=((std::string *)(a1 + 1312), &__str);
*(_BYTE *)(a1 + 1432) = 1;
v21 = 1;
}
GJGameLevel::storeNewLocalScore(a1, (unsigned int)v18, 0);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) == 0 )
{
if ( v21 )
goto LABEL_22;
LABEL_25:
v22 = _mm_loadu_si128((const __m128i *)(a2 + 1336));
if ( (*(_BYTE *)(a2 + 1352) & 1) != 0 )
goto LABEL_23;
LABEL_26:
v64 = *(std::string *)(a2 + 1352);
goto LABEL_27;
}
operator delete(__str.__r_.__value_.__l.__data_);
if ( !v21 )
goto LABEL_25;
LABEL_22:
*(_BYTE *)(a1 + 1432) = *(_BYTE *)(a2 + 1432);
v22 = _mm_loadu_si128((const __m128i *)(a2 + 1336));
if ( (*(_BYTE *)(a2 + 1352) & 1) == 0 )
goto LABEL_26;
LABEL_23:
v23 = *(_QWORD *)(a2 + 1360);
v24 = *(const void **)(a2 + 1368);
v67[0] = v22;
sub_10001AD30(&v64, v24, v23);
v22 = _mm_load_si128(v67);
LABEL_27:
v67[0].i64[0] = (__int64)&v64.__r_.__value_.__l.__data_;
v25 = (unsigned int)_mm_cvtsi128_si32(v22);
if ( !(_DWORD)v25 || *(_DWORD *)(a1 + 1336) != 0 && *(_DWORD *)(a1 + 1336) >= (int)v25 )
{
v28 = 0;
}
else
{
*(__m128i *)(a1 + 1336) = v22;
v26 = -(int)v25;
if ( (int)v25 > 0 )
v26 = v25;
v27 = (int)(63 * (374 * (*(_DWORD *)(a1 + 1304) + _mm_extract_epi32(v22, 2)) % 18477)
+ 967 * ((v26 + 3456) % 0x13435u)
+ 601 * (*(_DWORD *)(a1 + 1296) - 34567 * ((*(_DWORD *)(a1 + 1296) + 7890) / 34567) + 7890)
+ 27 * (125 * (*(_DWORD *)(a1 + 1300) + _mm_extract_epi32(v22, 1)) % 28452)
+ 87 * (7284 * (*(_DWORD *)(a1 + 1308) + _mm_extract_epi32(v22, 3)) % 62374)
+ 94819)
% 94433;
*(_DWORD *)(a1 + 1376) = 829 * (v27 ^ (v27 >> 16)) % 77849;
std::string::operator=((std::string *)(a1 + 1352), &v64);
*(_BYTE *)(a1 + 1433) = 1;
v28 = 1;
v25 = (unsigned int)v25;
}
GJGameLevel::storeNewLocalScore(a1, v25, 1);
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) == 0 )
{
if ( v28 )
goto LABEL_35;
LABEL_38:
if ( v15 <= v66 )
goto LABEL_45;
goto LABEL_39;
}
operator delete(v64.__r_.__value_.__l.__data_);
if ( !v28 )
goto LABEL_38;
LABEL_35:
*(_BYTE *)(a1 + 1433) = *(_BYTE *)(a2 + 1433);
if ( v15 <= v66 )
goto LABEL_45;
LABEL_39:
*(_DWORD *)(a1 + 884) = v15;
v29 = (int)(float)((float)((float)rand() * 4.6566129e-10) * 1000.0);
*(_DWORD *)(a1 + 880) = v29;
*(_DWORD *)(a1 + 876) = v29 + v15;
v30 = *(_DWORD *)(a2 + 820) - *(_DWORD *)(a2 + 824);
*(_DWORD *)(a1 + 828) = v30;
v31 = (int)(float)((float)((float)rand() * 4.6566129e-10) * 1000.0);
*(_DWORD *)(a1 + 824) = v31;
*(_DWORD *)(a1 + 820) = v31 + v30;
v32 = *(_DWORD *)(a2 + 832) - *(_DWORD *)(a2 + 836);
*(_DWORD *)(a1 + 840) = v32;
v33 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
*(_DWORD *)(a1 + 836) = (int)v33;
*(_DWORD *)(a1 + 832) = (int)v33 + v32;
*(_DWORD *)(a1 + 844) = *(_DWORD *)(a2 + 844);
if ( (*(_BYTE *)(a2 + 1208) & 1) != 0 )
sub_10001AD30(&v65, *(const void **)(a2 + 1224), *(_QWORD *)(a2 + 1216));
else
v65 = *(std::string *)(a2 + 1208);
std::string::operator=((std::string *)(a1 + 1208), &v65);
if ( (*(_BYTE *)&v65.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v65.__r_.__value_.__l.__data_);
*(_BYTE *)(a1 + 848) = *(_BYTE *)(a2 + 848);
LABEL_45:
v34 = *(_DWORD *)(a2 + 888);
if ( *(_DWORD *)(a1 + 888) > v34 )
v34 = *(_DWORD *)(a1 + 888);
v35 = *(_DWORD *)(a1 + 632);
*(_DWORD *)(a1 + 888) = v34;
v36 = *(_DWORD *)(a2 + 1532);
if ( *(_DWORD *)(a1 + 1532) > v36 )
v36 = *(_DWORD *)(a1 + 1532);
*(_DWORD *)(a1 + 1532) = v36;
v37 = *(_DWORD *)(a2 + 632);
if ( v35 > v37 )
v37 = v35;
*(_DWORD *)(a1 + 632) = v37;
if ( *(_BYTE *)(a2 + 912) == 1 )
*(_BYTE *)(a1 + 912) = 1;
v38 = *(_DWORD *)(a2 + 1536);
if ( v38 <= 0 || *(_DWORD *)(a1 + 1536) && *(_DWORD *)(a2 + 1644) <= *(_DWORD *)(a1 + 1644) )
goto LABEL_68;
*(_DWORD *)(a1 + 1536) = v38;
std::string::operator=((std::string *)(a1 + 1544), (const std::string *)(a2 + 1544));
std::string::operator=((std::string *)(a1 + 1568), (const std::string *)(a2 + 1568));
std::string::operator=((std::string *)(a1 + 1592), (const std::string *)(a2 + 1592));
std::string::operator=((std::string *)(a1 + 1616), (const std::string *)(a2 + 1616));
*(_OWORD *)(a1 + 1640) = *(_OWORD *)(a2 + 1640);
*(_DWORD *)(a1 + 1656) = *(_DWORD *)(a2 + 1656);
std::string::operator=((std::string *)(a1 + 1664), (const std::string *)(a2 + 1664));
std::string::operator=((std::string *)(a1 + 1688), (const std::string *)(a2 + 1688));
*(_BYTE *)(a1 + 1712) = *(_BYTE *)(a2 + 1712);
if ( *(_DWORD *)(a2 + 788) != *(_DWORD *)(a1 + 788) )
goto LABEL_68;
if ( *(_DWORD *)(a1 + 1140) != 2 )
{
LABEL_67:
std::string::operator=((std::string *)(a1 + 1720), (const std::string *)(a2 + 1720));
*(_BYTE *)(a1 + 1744) = *(_BYTE *)(a2 + 1744);
goto LABEL_68;
}
v39 = *(unsigned __int8 *)(a2 + 392);
v40 = *(unsigned __int8 *)(a1 + 392);
if ( (v40 & 1) != 0 )
{
v41 = *(_QWORD *)(a1 + 400);
v42 = *(const void **)(a1 + 408);
if ( (v39 & 1) == 0 )
{
LABEL_60:
v43 = v39 >> 1;
v44 = (const void *)(a2 + 393);
goto LABEL_63;
}
}
else
{
v41 = v40 >> 1;
v42 = (const void *)(a1 + 393);
if ( (v39 & 1) == 0 )
goto LABEL_60;
}
v43 = *(_QWORD *)(a2 + 400);
v44 = *(const void **)(a2 + 408);
LABEL_63:
v45 = v41;
if ( v43 < v41 )
v45 = v43;
if ( !memcmp(v42, v44, v45) && v43 == v41 )
goto LABEL_67;
LABEL_68:
v46 = *(unsigned __int8 *)(a1 + 1760);
if ( (v46 & 1) != 0 )
{
if ( *(_QWORD *)(a1 + 1768) )
goto LABEL_77;
}
else if ( v46 >> 1 )
{
goto LABEL_77;
}
v47 = *(unsigned __int8 *)(a2 + 1760);
if ( (v47 & 1) != 0 )
{
if ( !*(_QWORD *)(a2 + 1768) )
goto LABEL_77;
goto LABEL_76;
}
if ( v47 >> 1 )
{
LABEL_76:
std::string::operator=((std::string *)(a1 + 1760), (const std::string *)(a2 + 1760));
*(_QWORD *)(a1 + 1752) = *(_QWORD *)(a2 + 1752);
}
LABEL_77:
v48 = *(unsigned __int8 *)(a1 + 1816);
if ( (v48 & 1) != 0 )
{
if ( *(_QWORD *)(a1 + 1824) )
goto LABEL_86;
}
else if ( v48 >> 1 )
{
goto LABEL_86;
}
v49 = *(unsigned __int8 *)(a2 + 1816);
if ( (v49 & 1) != 0 )
{
if ( !*(_QWORD *)(a2 + 1824) )
goto LABEL_86;
goto LABEL_85;
}
if ( v49 >> 1 )
{
LABEL_85:
std::string::operator=((std::string *)(a1 + 1816), (const std::string *)(a2 + 1816));
*(_DWORD *)(a1 + 1840) = *(_DWORD *)(a2 + 1840);
*(_BYTE *)(a1 + 1844) = *(_BYTE *)(a2 + 1844);
*(_DWORD *)(a1 + 1848) = *(_DWORD *)(a2 + 1848);
}
LABEL_86:
v50 = *(unsigned __int8 *)(a1 + 1784);
if ( (v50 & 1) != 0 )
{
if ( *(_QWORD *)(a1 + 1792) )
goto LABEL_95;
}
else if ( v50 >> 1 )
{
goto LABEL_95;
}
v51 = *(unsigned __int8 *)(a2 + 1784);
if ( (v51 & 1) != 0 )
{
if ( !*(_QWORD *)(a2 + 1792) )
goto LABEL_95;
goto LABEL_94;
}
if ( v51 >> 1 )
{
LABEL_94:
std::string::operator=((std::string *)(a1 + 1784), (const std::string *)(a2 + 1784));
*(_DWORD *)(a1 + 1808) = *(_DWORD *)(a2 + 1808);
}
LABEL_95:
v52 = *(unsigned __int8 *)(a1 + 1472);
if ( (v52 & 1) != 0 )
{
v53 = *(_QWORD *)(a1 + 1480);
if ( v53 )
return v53;
}
else
{
v53 = v52 >> 1;
if ( v53 )
return v53;
}
v54 = *(unsigned __int8 *)(a2 + 1472);
if ( (v54 & 1) != 0 )
{
v53 = *(_QWORD *)(a2 + 1480);
if ( !v53 )
return v53;
}
else
{
v53 = v54 >> 1;
if ( !v53 )
return v53;
}
LODWORD(v53) = *(_DWORD *)(a2 + 1520);
if ( (_DWORD)v53 != *(_DWORD *)(a1 + 788) )
return v53;
if ( *(_DWORD *)(a1 + 1140) != 2 )
{
LABEL_114:
std::string::operator=((std::string *)(a1 + 1472), (const std::string *)(a2 + 1472));
*(_QWORD *)(a1 + 1520) = *(_QWORD *)(a2 + 1520);
std::string::operator=((std::string *)(a1 + 1496), (const std::string *)(a2 + 1496));
LODWORD(v53) = *(unsigned __int8 *)(a2 + 769);
*(_BYTE *)(a1 + 769) = v53;
return v53;
}
v55 = *(unsigned __int8 *)(a2 + 392);
v56 = *(unsigned __int8 *)(a1 + 392);
if ( (v56 & 1) != 0 )
{
v57 = *(_QWORD *)(a1 + 400);
v58 = *(const void **)(a1 + 408);
if ( (v55 & 1) == 0 )
{
LABEL_107:
v59 = v55 >> 1;
v60 = (const void *)(a2 + 393);
goto LABEL_110;
}
}
else
{
v57 = v56 >> 1;
v58 = (const void *)(a1 + 393);
if ( (v55 & 1) == 0 )
goto LABEL_107;
}
v59 = *(_QWORD *)(a2 + 400);
v60 = *(const void **)(a2 + 408);
LABEL_110:
v61 = v57;
if ( v59 < v57 )
v61 = v59;
LODWORD(v53) = memcmp(v58, v60, v61);
if ( !(_DWORD)v53 && v59 == v57 )
goto LABEL_114;
return v53;
}