//
// GJGameLevel::storeNewLocalScore from 0x10055c740 to 0x10055c8f3 (435 bytes)
//
// 3 xrefs:
// > GJGameLevel::handleStatsConflict @ 0x10053cd51
// > GJGameLevel::handleStatsConflict @ 0x10053cfb8
// > GJGameLevel::saveNewScore @ 0x10055c724
//
// 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 __fastcall GJGameLevel::storeNewLocalScore(GJGameLevel *a1, int a2, int a3)
{
std::string *p_m_localBestPoints; // rbx
std::vector *v5; // rsi
std::__vector_base::pointer begin; // r15
std::__vector_base::pointer end; // r13
int *v8; // rax
int *v9; // r14
signed __int64 v10; // r13
signed __int64 v11; // rsi
unsigned __int64 v12; // r14
int *v13; // rax
int *v14; // r12
__int128 v15; // [rsp+0h] [rbp-70h] BYREF
char *v16; // [rsp+10h] [rbp-60h]
__int64 v17; // [rsp+18h] [rbp-58h]
std::vector __src; // [rsp+20h] [rbp-50h] BYREF
int v19; // [rsp+44h] [rbp-2Ch]
p_m_localBestPoints = &a1->m_localBestPoints;
v19 = a3;
if ( a3 != 1 )
p_m_localBestPoints = &a1->m_localBestTimes;
memset(&__src, 0, sizeof(__src));
v5 = (std::vector *)p_m_localBestPoints;
GJGameLevel::scoreStringToVector(a1, p_m_localBestPoints, &__src);
begin = __src.__begin_;
end = __src.__end_;
v8 = __src.__begin_;
if ( __src.__begin_ != __src.__end_ )
{
v8 = __src.__begin_;
while ( *v8 != a2 )
{
if ( ++v8 == __src.__end_ )
goto LABEL_11;
}
}
if ( v8 == __src.__end_ )
{
LABEL_11:
if ( __src.__end_ >= __src.__end_cap_.__value_ )
{
v10 = (char *)__src.__end_ - (char *)__src.__begin_;
v11 = __src.__end_ - __src.__begin_;
if ( (unsigned __int64)(v11 + 1) >> 62 )
sub_1000C40D0();
v12 = ((char *)__src.__end_cap_.__value_ - (char *)__src.__begin_) >> 1;
if ( v12 <= __src.__end_ - __src.__begin_ + 1 )
v12 = (v10 >> 2) + 1;
if ( (int *)((char *)__src.__end_cap_.__value_ - (char *)__src.__begin_) >= (int *)0x7FFFFFFFFFFFFFFCLL )
v12 = 0x3FFFFFFFFFFFFFFFLL;
if ( v12 )
{
v17 = v10 >> 2;
if ( v12 > 0x3FFFFFFFFFFFFFFFLL )
sub_100054850();
v13 = (int *)operator new(4 * v12);
v11 = v17;
}
else
{
v13 = nullptr;
}
v17 = (__int64)&v13[v12];
v13[v11] = a2;
v9 = &v13[v11 + 1];
v14 = v13;
v5 = (std::vector *)begin;
memcpy(v13, begin, v10);
__src.__begin_ = v14;
__src.__end_cap_.__value_ = (int *)v17;
if ( begin )
operator delete(begin);
}
else
{
*__src.__end_ = a2;
v9 = end + 1;
}
__src.__end_ = v9;
GJGameLevel::scoreVectorToString((size_t *)&v15, v5, (unsigned int **)&__src, v19);
if ( (p_m_localBestPoints->m_data.m_short.sizex2 & 1) != 0 )
operator delete(p_m_localBestPoints->m_data.m_long.longStorage);
p_m_localBestPoints->m_data.m_long.longStorage = v16;
*(_OWORD *)&p_m_localBestPoints->m_data.m_short.sizex2 = v15;
begin = __src.__begin_;
if ( __src.__begin_ )
goto LABEL_10;
}
else if ( __src.__begin_ )
{
LABEL_10:
operator delete(begin);
}
}