//
// sub_100586910 from 0x100586910 to 0x100586abd (429 bytes)
//
// 2 xrefs:
// > PlayLayer::setupHasCompleted @ 0x10007b2d5
// > LevelEditorLayer::rebuildDeathOverlay @ 0x1000adec1
//
// 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:22 +0000
//
__int64 __fastcall sub_100586910(__int64 a1, const std::string *a2, _QWORD *a3)
{
const std::string *v4; // rbx
std::string *v5; // rdi
std::string::size_type v6; // rax
std::string::size_type v7; // r14
unsigned int v8; // r12d
std::string::size_type size; // r12
std::string::pointer data; // rsi
std::string *v11; // r13
size_t v12; // r15
std::string::size_type v13; // rcx
std::string::size_type v14; // rsi
std::string::pointer v15; // rsi
_QWORD *v17; // [rsp+8h] [rbp-48h]
std::string __dst[2]; // [rsp+10h] [rbp-40h] BYREF
v4 = a2;
v5 = (std::string *)a2;
v6 = std::string::find(a2, 124, 0);
v7 = v6;
if ( v6 == -1 )
{
if ( (*(_BYTE *)&a2->__r_.__value_.__s.0 & 1) != 0 )
{
v5 = __dst;
sub_10001AD30(__dst, a2->__r_.__value_.__l.__data_, a2->__r_.__value_.__l.__size_);
}
else
{
__dst[0] = *a2;
}
goto LABEL_19;
}
v8 = (unsigned int)a2->__r_.__value_.__l.0;
if ( (v8 & 1) != 0 )
{
size = a2->__r_.__value_.__l.__size_;
data = a2->__r_.__value_.__l.__data_;
}
else
{
size = v8 >> 1;
data = a2->__r_.__value_.__s.__data_;
}
if ( size >= v6 )
size = v6;
if ( size >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( size >= 0x17 )
{
v17 = a3;
v12 = 26;
if ( (size | 7) != 0x17 )
v12 = (size | 7) + 1;
v11 = (std::string *)operator new(v12);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v11;
__dst[0].__r_.__value_.__r.__words[0] = v12 + 1;
a3 = v17;
__dst[0].__r_.__value_.__l.__size_ = size;
}
else
{
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * size);
v11 = (std::string *)((char *)&__dst[0].__r_.__value_.__l.0 + 1);
if ( !size )
goto LABEL_17;
}
v5 = v11;
memmove(v11, data, size);
LABEL_17:
*((_BYTE *)&v11->__r_.__value_.__s.0 + size) = 0;
LABEL_19:
v13 = 0;
while ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
{
v14 = *(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1;
if ( v13 >= v14 )
goto LABEL_29;
LABEL_25:
v15 = __dst[0].__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v15 = __dst[0].__r_.__value_.__l.__data_;
if ( v15[v13] == 59 )
v15[v13] = 44;
++v13;
}
v14 = __dst[0].__r_.__value_.__l.__size_;
if ( v13 < __dst[0].__r_.__value_.__l.__size_ )
goto LABEL_25;
LABEL_29:
a3[1] = *a3;
if ( v14 )
GJGameLevel::scoreStringToVector((__int64)v5, __dst, a3);
if ( v7 == -1 )
{
LOBYTE(v4) = 1;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_38;
}
else
{
if ( (*(_BYTE *)&v4->__r_.__value_.__s.0 & 1) != 0 )
v4 = (const std::string *)v4->__r_.__value_.__l.__data_;
else
v4 = (const std::string *)((char *)v4 + 1);
LOBYTE(v4) = atoi(&v4->__r_.__value_.__s.__data_[v7]) > 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
LABEL_38:
operator delete(__dst[0].__r_.__value_.__l.__data_);
}
return (unsigned int)v4;
}