//
// GameLevelManager::rateDemon from 0x100547950 to 0x100547da9 (1113 bytes)
//
// 1 xrefs:
// > RateDemonLayer::onRate @ 0x100284304
//
// 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
//
bool __fastcall GameLevelManager::rateDemon(GameLevelManager *a1, int a2, int a3, bool a4)
{
__m128 v4; // xmm0
_BOOL4 v5; // ebx
GameLevelManager *v6; // r15
int v7; // r14d
cocos2d::CCString *v8; // rax
const char *CString; // r13
cocos2d::CCDictionary *m_friendReqAndUserBlocks; // rbx
size_t v11; // rax
std::string::size_type v12; // r14
char *data; // r12
size_t v14; // r15
__int64 v15; // rbx
cocos2d::CCDictionary *v17; // r14
cocos2d::CCNode *v18; // r12
size_t v19; // rax
std::string::size_type v20; // rbx
char *v21; // r14
size_t v22; // r15
cocos2d::CCString *v23; // rax
cocos2d::CCString *v24; // rax
const char *v25; // rax
const char *v26; // rbx
size_t v27; // rax
size_t v28; // r15
char *v29; // r14
size_t v30; // r12
size_t v31; // rax
size_t v32; // rbx
char *v33; // r14
cocos2d::CCObject *v34; // r15
size_t v35; // r15
char v36; // [rsp+0h] [rbp-B0h]
char v37; // [rsp+0h] [rbp-B0h]
std::string v38; // [rsp+8h] [rbp-A8h] BYREF
GameLevelManager *v39; // [rsp+20h] [rbp-90h]
_QWORD v40[2]; // [rsp+28h] [rbp-88h] BYREF
void *v41; // [rsp+38h] [rbp-78h]
_QWORD v42[2]; // [rsp+40h] [rbp-70h] BYREF
void *v43; // [rsp+50h] [rbp-60h]
int v44; // [rsp+5Ch] [rbp-54h]
int v45; // [rsp+60h] [rbp-50h]
_BOOL4 v46; // [rsp+64h] [rbp-4Ch]
cocos2d::CCDictionary *v47; // [rsp+68h] [rbp-48h]
std::string __dst[2]; // [rsp+70h] [rbp-40h] BYREF
v5 = a4;
v6 = a1;
if ( !a4 )
{
v7 = a3;
if ( GameLevelManager::hasRatedDemon(a1, a2) )
return 0;
GameLevelManager::markLevelAsRatedDemon(a1, a2);
a3 = v7;
}
v46 = v5;
v45 = a2;
v44 = a3;
v8 = (cocos2d::CCString *)sub_1007AB580("rd_%i_%i", v36);
CString = cocos2d::CCString::getCString(v8);
m_friendReqAndUserBlocks = a1->m_friendReqAndUserBlocks;
v11 = strlen(CString);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_57:
sub_100006BF0(*(double *)v4.i64);
v12 = v11;
if ( v11 >= 0x17 )
{
v47 = a1->m_friendReqAndUserBlocks;
v14 = 26;
if ( (v11 | 7) != 0x17 )
v14 = (v11 | 7) + 1;
data = (char *)operator new(v14);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v14 + 1;
v6 = a1;
m_friendReqAndUserBlocks = v47;
__dst[0].__r_.__value_.__l.__size_ = v12;
goto LABEL_11;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v11);
data = __dst[0].__r_.__value_.__s.__data_;
if ( v11 )
LABEL_11:
memmove(data, CString, v12);
data[v12] = 0;
v15 = cocos2d::CCDictionary::objectForKey_1((__int64)m_friendReqAndUserBlocks, (char *)__dst);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
if ( v15 )
return 0;
v17 = v6->m_friendReqAndUserBlocks;
v18 = cocos2d::CCNode::create();
v19 = strlen(CString);
if ( v19 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_57;
v20 = v19;
v47 = v17;
v39 = v6;
if ( v19 >= 0x17 )
{
v22 = 26;
if ( (v19 | 7) != 0x17 )
v22 = (v19 | 7) + 1;
v21 = (char *)operator new(v22);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v21;
__dst[0].__r_.__value_.__r.__words[0] = v22 + 1;
__dst[0].__r_.__value_.__l.__size_ = v20;
goto LABEL_23;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v19);
v21 = __dst[0].__r_.__value_.__s.__data_;
if ( v19 )
LABEL_23:
memmove(v21, CString, v20);
v21[v20] = 0;
cocos2d::CCDictionary::setObject_1((__int64)v47, v18, (char *)__dst);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
GameLevelManager::getBasePostString(__dst, v4);
v23 = (cocos2d::CCString *)sub_1007AB580("%c%s%s%c%c%s", (char)"3");
cocos2d::CCString::getCString(v23);
v24 = (cocos2d::CCString *)sub_1007AB580("&levelID=%i&rating=%i&secret=%s", v37);
v25 = cocos2d::CCString::getCString(v24);
std::string::append(__dst, v25);
if ( v46 )
std::string::append(__dst, "&mode=1");
v38.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x38u);
v38.__r_.__value_.__r.__words[0] = 57;
v38.__r_.__value_.__l.__size_ = 52;
strcpy(v38.__r_.__value_.__l.__data_, "https://www.boomlings.com/database/rateGJDemon21.php");
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v26 = __dst[0].__r_.__value_.__l.__data_;
else
v26 = __dst[0].__r_.__value_.__s.__data_;
v27 = strlen(v26);
if ( v27 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(2.057594829120962e-81);
v28 = v27;
if ( v27 >= 0x17 )
{
v30 = 26;
if ( (v27 | 7) != 0x17 )
v30 = (v27 | 7) + 1;
v29 = (char *)operator new(v30);
v41 = v29;
v40[0] = v30 | 1;
v40[1] = v28;
goto LABEL_38;
}
LOBYTE(v40[0]) = 2 * v27;
v29 = (char *)v40 + 1;
if ( v27 )
LABEL_38:
memmove(v29, v26, v28);
v29[v28] = 0;
v31 = strlen(CString);
if ( v31 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(2.057594829120962e-81);
v32 = v31;
if ( v31 >= 0x17 )
{
v35 = 26;
if ( (v31 | 7) != 0x17 )
v35 = (v31 | 7) + 1;
v33 = (char *)operator new(v35);
v43 = v33;
v42[0] = v35 | 1;
v42[1] = v32;
v34 = v39;
goto LABEL_46;
}
LOBYTE(v42[0]) = 2 * v31;
v33 = (char *)v42 + 1;
v34 = v39;
if ( v31 )
LABEL_46:
memmove(v33, CString, v32);
v33[v32] = 0;
GameLevelManager::ProcessHttpRequest(v34, &v38, (__int64)v40, (__int64)v42, 50);
if ( (v42[0] & 1) != 0 )
{
operator delete(v43);
if ( (v40[0] & 1) == 0 )
{
LABEL_49:
if ( (*(_BYTE *)&v38.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_50;
LABEL_55:
operator delete(v38.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
return 1;
goto LABEL_51;
}
}
else if ( (v40[0] & 1) == 0 )
{
goto LABEL_49;
}
operator delete(v41);
if ( (*(_BYTE *)&v38.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_55;
LABEL_50:
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
LABEL_51:
operator delete(__dst[0].__r_.__value_.__l.__data_);
return 1;
}