//
// sub_10024ACF4 from 0x10024acf4 to 0x10024aebc (456 bytes)
//
// 2 xrefs:
// > GManager::loadDataFromFile @ 0x10024ab30
// > GManager::loadDataFromFile @ 0x10024ab90
//
// 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 __usercall sub_10024ACF4(std::string *__return_ptr a1@, char *__s@, char *a3@)
{
std::string::size_type v5; // x20
unsigned __int64 size; // x8
std::string *v7; // x27
std::string::size_type v8; // x26
unsigned __int64 v9; // x24
std::string::size_type v10; // x28
void **v11; // x21
signed __int64 v12; // x22
signed __int64 v13; // x9
char *v14; // x25
char *v15; // x0
int v16; // w20
char *v17; // x0
char *v18; // x23
std::string::size_type v19; // x2
const std::string::value_type *p_p; // x3
std::string::size_type v21; // x4
std::string::size_type v22; // x8
void *__p; // [xsp+0h] [xbp-80h] BYREF
std::string::size_type v24; // [xsp+8h] [xbp-78h]
unsigned __int8 v25; // [xsp+17h] [xbp-69h]
void *v26; // [xsp+18h] [xbp-68h] BYREF
signed __int64 v27; // [xsp+20h] [xbp-60h]
char v28; // [xsp+2Fh] [xbp-51h]
sub_100009900(a1, __s);
sub_100009900(&v26, ".dat");
sub_100009900(&__p, a3);
v5 = 0;
size = HIBYTE(a1->__r_.__value_.__r.__words[2]);
if ( (size & 0x80u) == 0LL )
v7 = a1;
else
v7 = (std::string *)a1->__r_.__value_.__r.__words[0];
if ( (size & 0x80u) != 0LL )
size = a1->__r_.__value_.__l.__size_;
v8 = v28;
v9 = (unsigned __int64)v28 >> 63;
v10 = v27;
if ( v28 >= 0 )
v11 = &v26;
else
v11 = (void **)v26;
if ( v28 >= 0 )
v12 = v28;
else
v12 = v27;
while ( !v12 )
{
LABEL_22:
if ( v5 != -1 )
{
if ( (v9 & 1) != 0 )
v19 = v10;
else
v19 = v8;
if ( (v25 & 0x80u) == 0 )
p_p = (const std::string::value_type *)&__p;
else
p_p = (const std::string::value_type *)__p;
if ( (v25 & 0x80u) == 0 )
v21 = v25;
else
v21 = v24;
std::string::replace(a1, v5, v19, p_p, v21);
v22 = v25;
if ( (v25 & 0x80u) != 0 )
v22 = v24;
v5 += v22;
size = HIBYTE(a1->__r_.__value_.__r.__words[2]);
if ( (size & 0x80u) == 0LL )
v7 = a1;
else
v7 = (std::string *)a1->__r_.__value_.__r.__words[0];
if ( (size & 0x80u) != 0LL )
size = a1->__r_.__value_.__l.__size_;
v8 = v28;
v9 = (unsigned __int64)v28 >> 63;
v10 = v27;
v11 = v28 >= 0 ? &v26 : (void **)v26;
v12 = v28 >= 0 ? v28 : v27;
if ( size >= v5 )
continue;
}
goto LABEL_46;
}
v13 = size - v5;
if ( (__int64)(size - v5) >= v12 )
{
v14 = (char *)v7 + size;
v15 = (char *)v7 + v5;
v16 = *(char *)v11;
do
{
if ( v13 - v12 == -1 )
break;
v17 = (char *)memchr(v15, v16, v13 - v12 + 1);
if ( !v17 )
break;
v18 = v17;
if ( !memcmp(v17, v11, v12) )
{
if ( v18 == v14 )
break;
v5 = v18 - (char *)v7;
goto LABEL_22;
}
v15 = v18 + 1;
v13 = v14 - (v18 + 1);
}
while ( v13 >= v12 );
}
LABEL_46:
if ( ((char)v25 & 0x80000000) == 0 )
{
if ( (v8 & 0x80) == 0 )
return;
LABEL_50:
operator delete(v26);
return;
}
operator delete(__p);
if ( v28 < 0 )
goto LABEL_50;
}