//
// sub_1004B8DD4 from 0x1004b8dd4 to 0x1004b90d0 (764 bytes)
//
// 1 xrefs:
// > sub_1004B8D30 @ 0x1004b8d7c
//
// This function is hookable on this platform (idp: arm, 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 11:06:15 +0000
//
void __fastcall sub_1004B8DD4(__int64 a1)
{
__int64 v2; // x0
__int64 v3; // x0
unsigned int v4; // w20
__int64 v5; // x0
std::string::size_type size; // x8
std::string::size_type v7; // x0
std::string::size_type v8; // x21
int v9; // w9
void *v10; // x0
__int64 v11; // x1
__int64 v12; // x0
std::string::size_type v13; // x8
std::string *p_dst; // x9
int v15; // w23
int v16; // t1
int v17; // w8
std::string::size_type v18; // x2
std::string *p_a; // x11
std::string::size_type i; // x3
std::string::size_type v21; // x13
std::string::size_type v22; // x14
int v23; // w21
__int64 v24; // x8
__int64 v25; // x8
void *v26; // x0
__int64 CString; // x1
__int64 v28; // x0
void *v29; // x22
std::string v30; // [xsp+20h] [xbp-A0h] BYREF
std::string __a; // [xsp+38h] [xbp-88h] BYREF
std::string __dst; // [xsp+50h] [xbp-70h] BYREF
std::string __str; // [xsp+70h] [xbp-50h] BYREF
std::allocator v34; // [xsp+8Fh] [xbp-31h] BYREF
v2 = GameLevelManager::sharedState();
sub_1000B3478(v2, *(_DWORD *)(a1 + 1048), &__str);
v3 = GameLevelManager::sharedState();
v4 = (unsigned int)sub_1000B4264(v3, *(_DWORD *)(a1 + 1048));
v5 = GameLevelManager::sharedState();
sub_1000A6BD4(v5, *(_DWORD *)(a1 + 1048));
size = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = __str.__r_.__value_.__l.__size_;
if ( size )
{
v7 = std::string::find(&__str, 124, 0);
if ( v7 == -1 )
{
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__dst, __str.__r_.__value_.__l.__data_, __str.__r_.__value_.__l.__size_);
else
__dst = __str;
sub_100009900(&__a, "");
}
else
{
v8 = v7;
std::string::basic_string(&__dst, &__str, 0, v7, (std::allocator *)&__a);
std::string::basic_string(&__a, &__str, v8 + 1, 0xFFFFFFFFFFFFFFFFLL, (std::allocator *)&v30);
}
v13 = HIBYTE(__dst.__r_.__value_.__r.__words[2]);
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v13 = __dst.__r_.__value_.__l.__size_;
if ( v13 )
{
p_dst = &__dst;
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
p_dst = (std::string *)__dst.__r_.__value_.__r.__words[0];
v15 = 1;
do
{
v16 = (unsigned __int8)p_dst->__r_.__value_.__s.__data_[0];
p_dst = (std::string *)((char *)p_dst + 1);
if ( v16 == 59 )
++v15;
--v13;
}
while ( v13 );
}
else
{
v15 = 0;
}
v17 = 0;
v18 = 0;
p_a = &__a;
if ( (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
p_a = (std::string *)__a.__r_.__value_.__r.__words[0];
while ( 2 )
{
for ( i = 0; ; ++i )
{
v21 = v18 + i;
if ( (*((_BYTE *)&__a.__r_.__value_.__s + 23) & 0x80) != 0 )
{
v22 = __a.__r_.__value_.__l.__size_;
if ( v21 > __a.__r_.__value_.__l.__size_ )
{
LABEL_38:
v23 = 0;
goto LABEL_39;
}
}
else
{
v22 = HIBYTE(__a.__r_.__value_.__r.__words[2]);
if ( v21 > HIBYTE(__a.__r_.__value_.__r.__words[2]) )
goto LABEL_38;
}
if ( v21 == v22 || p_a->__r_.__value_.__s.__data_[v18 + i] == 44 )
break;
}
if ( v17 != 101 )
{
++v17;
v18 += i + 1;
continue;
}
break;
}
std::string::basic_string(&v30, &__a, v18, i, &v34);
if ( SHIBYTE(v30.__r_.__value_.__r.__words[2]) < 0 )
{
v29 = (void *)v30.__r_.__value_.__r.__words[0];
v23 = atoi(v30.__r_.__value_.__l.__data_);
operator delete(v29);
}
else
{
v23 = atoi((const char *)&v30);
}
LABEL_39:
v24 = *(_QWORD *)(a1 + 1016);
if ( v24 )
{
v25 = *(_QWORD *)(v24 + 1936);
if ( v25 )
{
*(_DWORD *)(v25 + 1752) = *(_DWORD *)(a1 + 1048);
*(_DWORD *)(v25 + 1756) = v4;
std::string::operator=((std::string *)(v25 + 1760), &__str);
sub_1003F8ECC(*(_QWORD *)(a1 + 1016));
}
}
v26 = sub_1003065B0("v%d %d players %d spots", v4, v23, v15);
CString = cocos2d::CCString::getCString((__int64)v26);
v28 = *(_QWORD *)(a1 + 1040);
if ( v28 )
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v28 + 928LL))(v28, CString);
if ( SHIBYTE(__a.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__a.__r_.__value_.__l.__data_);
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
}
else
{
v9 = *(_DWORD *)(a1 + 1052);
if ( v9 < 1 )
v10 = sub_1003065B0("No death data for level %d.", *(_DWORD *)(a1 + 1048));
else
v10 = sub_1003065B0("No death data for level %d (v%d).", *(_DWORD *)(a1 + 1048), v9);
v11 = cocos2d::CCString::getCString((__int64)v10);
v12 = *(_QWORD *)(a1 + 1040);
if ( v12 )
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v12 + 928LL))(v12, v11);
}
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}