//
// GJGameLevel::storeNewLocalScore from 0x14016d400 to 0x14016d67d (637 bytes)
//
// 2 xrefs:
// > GJGameLevel::saveNewScore @ 0x14016d3d0
// > ??> @ 0x1406cae0c
//
// 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=2
void GJGameLevel::storeNewLocalScore(GJGameLevel *a1, int a2, int a3)
{
__int64 v5; // r15
std::string *v6; // r15
std::_Vector_val>::pointer Mylast; // rdi
std::_Vector_val>::pointer Myfirst; // rsi
std::_Simple_types::value_type *v9; // rdi
__int64 v10; // r8
unsigned __int64 v11; // rcx
std::_Simple_types::value_type *v12; // rbx
std::_Simple_types::value_type *v13; // r14
int v14; // edi
unsigned __int64 v15; // r14
unsigned int *v16; // rbx
_BYTE *v17; // rax
size_t v18; // r8
void *v19; // rcx
std::_Vector_val>::pointer v20; // rax
unsigned __int8 v21; // [rsp+20h] [rbp-E0h]
int v22; // [rsp+28h] [rbp-D8h] BYREF
std::vector v23; // [rsp+30h] [rbp-D0h] BYREF
const char *v24; // [rsp+50h] [rbp-B0h]
__int64 v25; // [rsp+58h] [rbp-A8h]
__int128 v26; // [rsp+60h] [rbp-A0h] BYREF
void *Block[2]; // [rsp+70h] [rbp-90h] BYREF
__int128 v28; // [rsp+80h] [rbp-80h]
_BYTE v29[528]; // [rsp+90h] [rbp-70h] BYREF
v22 = a2;
v5 = 1440;
if ( a3 != 1 )
v5 = 1408;
v6 = (std::string *)((char *)a1 + v5);
memset(&v23, 0, sizeof(v23));
GJGameLevel::scoreStringToVector(a1, v6, &v23);
Mylast = v23._Mypair._Myval2._Mylast;
Myfirst = v23._Mypair._Myval2._Myfirst;
if ( (std::_Vector_val>::pointer)unknown_libname_3(
v23._Mypair._Myval2._Myfirst,
v23._Mypair._Myval2._Mylast,
(unsigned int)a2) == Mylast )
{
if ( Mylast == v23._Mypair._Myval2._Myend )
{
sub_140063270((const void **)&v23._Mypair._Myval2._Myfirst, Mylast, &v22);
v9 = v23._Mypair._Myval2._Mylast;
Myfirst = v23._Mypair._Myval2._Myfirst;
}
else
{
*Mylast = a2;
v9 = Mylast + 1;
v23._Mypair._Myval2._Mylast = v9;
}
v10 = v9 - Myfirst;
if ( a3 == 1 )
sub_140179CA0(Myfirst, v9, v10, v21);
else
sub_14017A300(Myfirst, v9, v10, 0);
v11 = v9 - Myfirst;
if ( v11 > 0xA )
v23._Mypair._Myval2._Mylast = v9 - 1;
v12 = v9 - 1;
if ( v11 <= 0xA )
v12 = v9;
v13 = v9 - 1;
if ( v11 <= 0xA )
v13 = v9;
fmt::BasicWriter::BasicWriter(v29);
v14 = 0;
if ( v12 - Myfirst )
{
v15 = v13 - Myfirst;
v16 = (unsigned int *)Myfirst;
do
{
if ( v14 > 0 )
{
v24 = ",";
v25 = 0;
v26 = (unsigned __int64)",";
fmt::BasicWriter::operator<<(v29, &v26);
}
fmt::BasicWriter::operator<<(v29, *v16);
++v14;
++v16;
}
while ( v14 < v15 );
}
v17 = (_BYTE *)fmt::BasicWriter::c_str(v29);
*(_OWORD *)Block = 0;
v28 = 0;
v18 = -1;
do
++v18;
while ( v17[v18] );
sub_14003A930(Block, v17, v18);
fmt::BasicWriter::~BasicWriter(v29);
sub_140051590((__int64)v6, (__int64)Block);
if ( *((_QWORD *)&v28 + 1) > 0xFu )
{
v19 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v28 + 1) + 1LL) >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v19);
}
}
if ( Myfirst )
{
v20 = Myfirst;
if ( (((char *)v23._Mypair._Myval2._Myend - (char *)Myfirst) & 0xFFFFFFFFFFFFFFFCuLL) >= 0x1000 )
{
Myfirst = *((std::_Vector_val>::pointer *)Myfirst - 1);
if ( (unsigned __int64)((char *)v20 - (char *)Myfirst - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(Myfirst);
}
}