//
// sub_10057B5C0 from 0x10057b5c0 to 0x10057ba10 (1104 bytes)
//
// 2 xrefs:
// > sub_10057B4C0 @ 0x10057b56f
// > sub_100870400 @ 0x100870598
//
// 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:18 +0000
//
void __fastcall sub_10057B5C0(__int64 a1, __int64 a2)
{
__int64 v2; // r12
const char *v4; // rdi
__int64 v5; // rax
char *CString; // r15
size_t v7; // rax
std::string::size_type v8; // r13
char *data; // rbx
char *v10; // r12
__int64 v11; // r15
size_t v12; // r14
__int64 v13; // rbx
__int64 v14; // r13
size_t v15; // rax
std::string::size_type v16; // rbx
char *v17; // r12
char *v18; // r13
__int64 v19; // r15
size_t v20; // r14
__int64 v21; // rax
__int64 v22; // rax
const std::string::value_type *v23; // rax
const char *v24; // r15
size_t v25; // rax
size_t v26; // r12
char *v27; // rbx
size_t v28; // r13
size_t v29; // rax
size_t v30; // r15
char *v31; // rbx
size_t v32; // r12
char v33; // [rsp+0h] [rbp-B0h]
char v34; // [rsp+0h] [rbp-B0h]
__int64 v35; // [rsp+10h] [rbp-A0h]
std::string v36; // [rsp+18h] [rbp-98h] BYREF
_QWORD v37[2]; // [rsp+30h] [rbp-80h] BYREF
void *v38; // [rsp+40h] [rbp-70h]
__int128 v39; // [rsp+48h] [rbp-68h] BYREF
void *v40; // [rsp+58h] [rbp-58h]
__int64 v41; // [rsp+60h] [rbp-50h]
char *__s; // [rsp+68h] [rbp-48h]
std::string __dst[2]; // [rsp+70h] [rbp-40h] BYREF
v2 = a2;
if ( (*(_BYTE *)a2 & 1) != 0 )
{
if ( !*(_QWORD *)(a2 + 8) )
return;
v4 = *(const char **)(a2 + 16);
}
else
{
if ( !*(_BYTE *)a2 )
return;
v4 = (const char *)(a2 + 1);
}
atoi(v4);
v5 = sub_10088E820("readFriendReq_%i", v33);
CString = (char *)cocos2d::CCString::getCString(v5);
v7 = strlen(CString);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_56;
v8 = v7;
__s = *(char **)(a1 + 1088);
if ( v7 >= 0x17 )
{
v41 = a2;
v10 = CString;
v11 = a1;
v12 = 26;
if ( (v7 | 7) != 0x17 )
v12 = (v7 | 7) + 1;
data = (char *)operator new(v12);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v12 + 1;
a1 = v11;
CString = v10;
v2 = v41;
__dst[0].__r_.__value_.__l.__size_ = v8;
goto LABEL_13;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v7);
data = __dst[0].__r_.__value_.__s.__data_;
if ( v7 )
LABEL_13:
memmove(data, CString, v8);
data[v8] = 0;
v13 = cocos2d::CCDictionary::objectForKey((__int64)__s, (char *)__dst);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
if ( v13 )
return;
v14 = *(_QWORD *)(a1 + 1088);
__s = (char *)cocos2d::CCNode::create();
v15 = strlen(CString);
if ( v15 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_56:
sub_100003630();
v16 = v15;
v41 = v2;
if ( v15 >= 0x17 )
{
v35 = v14;
v18 = CString;
v19 = a1;
v20 = 26;
if ( (v15 | 7) != 0x17 )
v20 = (v15 | 7) + 1;
v17 = (char *)operator new(v20);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v17;
__dst[0].__r_.__value_.__r.__words[0] = v20 + 1;
a1 = v19;
CString = v18;
v14 = v35;
__dst[0].__r_.__value_.__l.__size_ = v16;
goto LABEL_24;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v15);
v17 = __dst[0].__r_.__value_.__s.__data_;
if ( v15 )
LABEL_24:
memmove(v17, CString, v16);
v17[v16] = 0;
cocos2d::CCDictionary::setObject(v14, (__int64)__s, (char *)__dst);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
GameLevelManager::getBasePostString(__dst);
v21 = sub_10088E820("%c%s%s%c%c%s", (char)"7");
cocos2d::CCString::getCString(v21);
v22 = sub_10088E820("&requestID=%s&secret=%s", v34);
v23 = (const std::string::value_type *)cocos2d::CCString::getCString(v22);
std::string::append(__dst, v23);
__s = CString;
v36.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x40u);
v36.__r_.__value_.__r.__words[0] = 65;
v36.__r_.__value_.__l.__size_ = 60;
strcpy(v36.__r_.__value_.__l.__data_, "https://www.boomlings.com/database/readGJFriendRequest20.php");
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v24 = __dst[0].__r_.__value_.__l.__data_;
else
v24 = __dst[0].__r_.__value_.__s.__data_;
v25 = strlen(v24);
if ( v25 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v26 = v25;
if ( v25 >= 0x17 )
{
v28 = 26;
if ( (v25 | 7) != 0x17 )
v28 = (v25 | 7) + 1;
v27 = (char *)operator new(v28);
v38 = v27;
v37[0] = v28 | 1;
v37[1] = v26;
goto LABEL_37;
}
LOBYTE(v37[0]) = 2 * v25;
v27 = (char *)v37 + 1;
if ( v25 )
LABEL_37:
memmove(v27, v24, v26);
v27[v26] = 0;
v29 = strlen(__s);
if ( v29 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v30 = v29;
if ( v29 >= 0x17 )
{
v32 = 26;
if ( (v29 | 7) != 0x17 )
v32 = (v29 | 7) + 1;
v31 = (char *)operator new(v32);
v40 = v31;
*(_QWORD *)&v39 = v32 | 1;
*((_QWORD *)&v39 + 1) = v30;
goto LABEL_45;
}
LOBYTE(v39) = 2 * v29;
v31 = (char *)&v39 + 1;
if ( v29 )
LABEL_45:
memmove(v31, __s, v30);
v31[v30] = 0;
GameLevelManager::ProcessHttpRequest(a1, &v36, (__int64)v37, &v39, 0x26u);
if ( (v39 & 1) == 0 )
{
if ( (v37[0] & 1) == 0 )
goto LABEL_48;
LABEL_53:
operator delete(v38);
if ( (*(_BYTE *)&v36.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_49:
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
return;
goto LABEL_50;
}
goto LABEL_54;
}
operator delete(v40);
if ( (v37[0] & 1) != 0 )
goto LABEL_53;
LABEL_48:
if ( (*(_BYTE *)&v36.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_49;
LABEL_54:
operator delete(v36.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
LABEL_50:
operator delete(__dst[0].__r_.__value_.__l.__data_);
}