//
// sub_1000A6658 from 0x1000a6658 to 0x1000a69b4 (860 bytes)
//
// 1 xrefs:
// > GJGameLevel::copyLevelInfo @ 0x1000d160c
//
// 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 10:58:34 +0000
//
__n128 __usercall sub_1000A6658@(std::string *__s@, std::string::reference a2@, __int64 a3@)
{
std::string::size_type v5; // x21
__int64 i; // x22
std::string::size_type size; // x8
__int64 v8; // x8
unsigned __int64 v9; // x27
__int64 v10; // x0
__int64 AllLevelsInDict; // x21
std::string::size_type v12; // x3
std::string *v13; // x0
int v14; // w22
int v15; // w24
__int64 v16; // x0
char *v17; // x0
std::string::size_type v18; // x8
std::string::size_type v19; // x2
unsigned __int64 v20; // x8
std::string::size_type v21; // x26
std::string *v22; // x1
std::string::size_type v23; // x8
std::string *v24; // x1
std::string::size_type v25; // x2
std::string *v26; // x1
__int64 v27; // x0
__n128 result; // q0
__int64 v29; // x26
std::string *v30; // x21
__int64 v31; // x0
const std::string::value_type *CString; // x0
std::allocator v33[8]; // [xsp+10h] [xbp-B0h] BYREF
char v34; // [xsp+27h] [xbp-99h]
std::string __str; // [xsp+28h] [xbp-98h] BYREF
std::string __a; // [xsp+40h] [xbp-80h] BYREF
std::string v37; // [xsp+58h] [xbp-68h] BYREF
v5 = 0;
for ( i = -1; ; --i )
{
size = SHIBYTE(__s->__r_.__value_.__r.__words[2]);
if ( (size & 0x8000000000000000LL) != 0 )
{
size = __s->__r_.__value_.__l.__size_;
if ( size <= v5 )
break;
}
else if ( v5 >= size )
{
break;
}
a2 = std::string::at(__s, size + i);
v8 = *a2;
if ( v8 < 0 || (_DefaultRuneLocale.__runetype[v8] & 0x400) == 0 )
break;
++v5;
}
v9 = (unsigned int)v5;
if ( !(_DWORD)v5 )
{
if ( SHIBYTE(__s->__r_.__value_.__r.__words[2]) < 0 )
{
v30 = (std::string *)__s->__r_.__value_.__r.__words[0];
if ( strlen(__s->__r_.__value_.__l.__data_) >= 0x13 )
goto LABEL_64;
}
else
{
v30 = __s;
if ( strlen((const char *)__s) > 0x12 )
{
LABEL_64:
result = *(__n128 *)&__s->__r_.__value_.__l.__data_;
*(_OWORD *)a3 = *(_OWORD *)&__s->__r_.__value_.__l.__data_;
*(_QWORD *)(a3 + 16) = *((_QWORD *)&__s->__r_.__value_.__l + 2);
__s->__r_.__value_.__l.__size_ = 0;
__s->__r_.__value_.__r.__words[2] = 0;
__s->__r_.__value_.__r.__words[0] = 0;
return result;
}
}
v31 = sub_1003065B0("%s 2", (const char *)v30);
CString = (const std::string::value_type *)cocos2d::CCString::getCString(v31);
std::string::assign(__s, CString);
goto LABEL_64;
}
v10 = LocalLevelManager::sharedState(a2);
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v10);
v12 = SHIBYTE(__s->__r_.__value_.__r.__words[2]);
if ( (v12 & 0x8000000000000000LL) != 0 )
v12 = __s->__r_.__value_.__l.__size_;
std::string::basic_string(&v37, __s, v12 - v9, v12, (std::allocator *)&__a);
if ( (v37.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v13 = &v37;
else
v13 = (std::string *)v37.__r_.__value_.__r.__words[0];
v14 = atoi((const char *)v13);
v15 = 0;
do
{
while ( 1 )
{
v16 = sub_1003065B0("%i", ++v14);
v17 = (char *)cocos2d::CCString::getCString(v16);
sub_100009900(&__a, v17);
v18 = HIBYTE(__a.__r_.__value_.__r.__words[2]);
if ( (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v18 = __a.__r_.__value_.__l.__size_;
if ( v18 < v9 )
{
sub_100009900(&__str, "");
v19 = (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? SHIBYTE(__a.__r_.__value_.__r.__words[2])
: __a.__r_.__value_.__l.__size_;
if ( v9 == v19 )
{
v20 = (unsigned __int64)SHIBYTE(__a.__r_.__value_.__r.__words[2]) >> 63;
}
else
{
v21 = 0;
do
{
std::string::append(&__str, "0");
++v21;
if ( (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v19 = SHIBYTE(__a.__r_.__value_.__r.__words[2]);
else
v19 = __a.__r_.__value_.__l.__size_;
}
while ( v9 - v19 > v21 );
v20 = (unsigned __int64)SHIBYTE(__a.__r_.__value_.__r.__words[2]) >> 63;
}
v22 = (_DWORD)v20 ? (std::string *)__a.__r_.__value_.__r.__words[0] : &__a;
std::string::append(&__str, (const std::string::value_type *)v22, v19);
std::string::operator=(&__a, &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}
v23 = SHIBYTE(__s->__r_.__value_.__r.__words[2]);
if ( (v23 & 0x8000000000000000LL) != 0 )
v23 = __s->__r_.__value_.__l.__size_;
std::string::basic_string(&__str, __s, 0, v23 - v9, v33);
v24 = (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? &__a
: (std::string *)__a.__r_.__value_.__r.__words[0];
v25 = (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? HIBYTE(__a.__r_.__value_.__r.__words[2])
: __a.__r_.__value_.__l.__size_;
std::string::append(&__str, (const std::string::value_type *)v24, v25);
v26 = (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? &__str
: (std::string *)__str.__r_.__value_.__r.__words[0];
sub_100009900(v33, (char *)v26);
v27 = cocos2d::CCDictionary::objectForKey(AllLevelsInDict, v33);
v29 = v27;
if ( v34 < 0 )
{
operator delete(*(void **)&v33[0].std::__non_trivial_if);
if ( !v29 )
{
LABEL_51:
result = *(__n128 *)&__str.__r_.__value_.__l.__data_;
*(std::string *)a3 = __str;
memset(&__str, 0, sizeof(__str));
goto LABEL_53;
}
}
else if ( !v27 )
{
goto LABEL_51;
}
if ( v15 < 999 )
{
++v15;
LOBYTE(v29) = 1;
}
else
{
LOBYTE(v29) = 0;
result = *(__n128 *)&__s->__r_.__value_.__l.__data_;
*(_OWORD *)a3 = *(_OWORD *)&__s->__r_.__value_.__l.__data_;
*(_QWORD *)(a3 + 16) = *((_QWORD *)&__s->__r_.__value_.__l + 2);
__s->__r_.__value_.__l.__size_ = 0;
__s->__r_.__value_.__r.__words[2] = 0;
__s->__r_.__value_.__r.__words[0] = 0;
}
LABEL_53:
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( SHIBYTE(__a.__r_.__value_.__r.__words[2]) < 0 )
break;
if ( (v29 & 1) == 0 )
goto LABEL_59;
}
operator delete(__a.__r_.__value_.__l.__data_);
}
while ( (v29 & 1) != 0 );
LABEL_59:
if ( SHIBYTE(v37.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v37.__r_.__value_.__l.__data_);
return result;
}