//
// GJGameLevel::storeNewLocalScore from 0x739080 to 0x7392cc (588 bytes)
//
// 2 xrefs:
// > GJGameLevel::saveNewScore @ 0x739338
// > ??> @ 0x7c650
//
// 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::storeNewLocalScore(GJGameLevel *a1, int a2, int a3)
{
std::string *p_m_localBestTimes; // x20
int *v5; // x0
int *m_finish; // x2
void *v7; // x0
unsigned int *v8; // x2
int v9; // w1
int *m_start; // x0
size_t v11; // x22
unsigned __int64 v12; // x1
unsigned __int64 v13; // x2
unsigned __int64 v14; // x25
char *v15; // x26
int *v16; // x22
int v17; // [xsp+5Ch] [xbp+5Ch] BYREF
__int64 v18; // [xsp+68h] [xbp+68h] BYREF
std::vector p; // [xsp+70h] [xbp+70h] BYREF
p_m_localBestTimes = &a1->m_localBestTimes;
if ( a3 == 1 )
p_m_localBestTimes = &a1->m_localBestPoints;
v17 = a2;
memset(&p, 0, sizeof(p));
GJGameLevel::scoreStringToVector(a1, p_m_localBestTimes, &p);
v5 = std::__find_if<__gnu_cxx::__normal_iterator>,__gnu_cxx::__ops::_Iter_equals_val>(
p.m_start,
(__int64)p.m_finish,
&v17);
m_finish = p.m_finish;
if ( p.m_finish == v5 )
{
if ( p.m_finish != p.m_reserveEnd )
{
if ( p.m_finish )
*p.m_finish = v17;
p.m_finish = m_finish + 1;
LABEL_11:
GJGameLevel::scoreVectorToString((char **)&p, (std::vector *)(unsigned int)a3, (__int64)&v18);
sub_D163D4(p_m_localBestTimes, &v18);
v7 = (void *)(v18 - 24);
if ( (__int64 *)(v18 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(v18 - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *(_DWORD *)(v18 - 8);
*(_DWORD *)(v18 - 8) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v7);
}
goto LABEL_4;
}
m_start = p.m_start;
v11 = (char *)p.m_finish - (char *)p.m_start;
v12 = p.m_finish - p.m_start;
if ( v12 )
{
v13 = 2 * v12;
v14 = -4;
if ( v12 <= 2 * v12 && v13 <= 0x3FFFFFFFFFFFFFFFLL )
{
v14 = 8 * v12;
v15 = nullptr;
if ( !v13 )
goto LABEL_20;
}
}
else
{
v14 = 4;
}
v15 = (char *)operator new(v14);
m_start = p.m_start;
v11 = (char *)p.m_finish - (char *)p.m_start;
v12 = p.m_finish - p.m_start;
LABEL_20:
if ( &v15[v11] )
*(_DWORD *)&v15[v11] = v17;
if ( v12 )
{
memmove(v15, m_start, v11);
m_start = p.m_start;
}
v16 = (int *)&v15[v11 + 4];
if ( m_start )
operator delete(m_start);
p.m_start = (int *)v15;
p.m_finish = v16;
p.m_reserveEnd = (int *)&v15[v14];
goto LABEL_11;
}
LABEL_4:
if ( p.m_start )
operator delete(p.m_start);
}