//
// GJAccountManager::syncAccount from 0x847694 to 0x8479ec (856 bytes)
//
// 2 xrefs:
// > GJAccountManager::onGetAccountSyncURLCompleted @ 0x847b50
// > ??> @ 0xb3c70
//
// 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
//
__int64 __fastcall GJAccountManager::syncAccount(GJAccountManager *a1)
{
_BOOL4 isDLActive; // w1
__int64 result; // x0
GameLevelManager *v4; // x0
cocos2d::CCString *v5; // x0
const char *CString; // x0
cocos2d::CCString *v7; // x0
size_t v8; // x0
char *v9; // x0
char *v10; // x0
char *v11; // x0
char *v12; // x0
unsigned int *v13; // x1
int v14; // w2
unsigned int *v15; // x1
int v16; // w2
unsigned int *v17; // x1
int v18; // w2
unsigned int *v19; // x1
int v20; // w2
const char *v21; // [xsp+48h] [xbp+48h]
char *v22; // [xsp+68h] [xbp+68h] BYREF
const char *v23; // [xsp+70h] [xbp+70h] BYREF
const char *v24; // [xsp+78h] [xbp+78h] BYREF
const char *v25; // [xsp+80h] [xbp+80h] BYREF
isDLActive = GJAccountManager::isDLActive(a1, "sync_account");
result = 0;
if ( !isDLActive )
{
GJAccountManager::addDLToActive(a1, "sync_account");
v4 = GameLevelManager::sharedState();
GameLevelManager::getBasePostString(v4, (__int64)&v22);
v5 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfv",
"3899",
103,
99,
"9");
CString = cocos2d::CCString::getCString(v5);
v7 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"&secret=%s", CString);
v21 = cocos2d::CCString::getCString(v7);
v8 = strlen(v21);
sub_D15FD4(&v22, v21, v8);
sub_D18D28(&v23);
sub_D153B8((int)&v24, v22);
sub_D153B8((int)&v25, "SyncAccount");
GJAccountManager::ProcessHttpRequest(a1, &v23, &v24, &v25, 21);
v9 = (char *)(v25 - 24);
if ( v25 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v25 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v9);
}
v10 = (char *)(v24 - 24);
if ( v24 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v24 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v24 - 2);
*((_DWORD *)v24 - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v10);
}
v11 = (char *)(v23 - 24);
if ( v23 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v23 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v23 - 2);
*((_DWORD *)v23 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v11);
}
v12 = v22 - 24;
if ( v22 - 24 == (char *)&qword_124B6B0 )
return 1;
if ( &pthread_create )
{
v13 = (unsigned int *)(v22 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v22 - 2);
*((_DWORD *)v22 - 2) = v14 - 1;
}
if ( v14 > 0 )
{
return 1;
}
else
{
operator delete(v12);
return 1;
}
}
return result;
}