//
// sub_10056D820 from 0x10056d820 to 0x10056db0c (748 bytes)
//
// 1 xrefs:
// > ??> @ 0x1009641a0
//
// 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 sub_10056D820(__int64 a1)
{
unsigned int v2; // eax
CURL *v3; // rax
_QWORD *v4; // r14
__int64 v5; // rdx
_QWORD *v6; // r14
_QWORD *v7; // rax
__int64 v8; // r12
pthread_mutex_t *v9; // r15
__int64 *v10; // r12
_QWORD *v11; // rax
__int64 v12; // rcx
cocos2d::CCUserDefault *v14; // rax
char v15; // r15
size_t v16; // rdx
unsigned int v17; // eax
char *v18; // rdi
_QWORD *v19; // rax
__int64 v20; // r12
pthread_mutex_t *v21; // r15
__int64 *v22; // r12
_QWORD *v23; // rax
__int64 v24; // rcx
unsigned __int8 v25; // [rsp+8h] [rbp-38h] BYREF
char v26; // [rsp+9h] [rbp-37h] BYREF
size_t v27; // [rsp+10h] [rbp-30h]
void *__s1; // [rsp+18h] [rbp-28h]
v2 = *(unsigned __int8 *)(a1 + 80);
if ( (v2 & 1) != 0 )
{
if ( !*(_QWORD *)(a1 + 88) )
{
LABEL_15:
LODWORD(v4) = 0;
return (unsigned int)v4;
}
}
else if ( !(v2 >> 1) )
{
goto LABEL_15;
}
v3 = curl_easy_init();
*(_QWORD *)(a1 + 128) = v3;
if ( !v3 )
goto LABEL_15;
if ( (*(_BYTE *)(a1 + 32) & 1) != 0 )
{
**(_BYTE **)(a1 + 48) = 0;
*(_QWORD *)(a1 + 40) = 0;
v3 = *(CURL **)(a1 + 128);
v4 = (_QWORD *)(a1 + 32);
if ( (*(_BYTE *)(a1 + 80) & 1) != 0 )
goto LABEL_8;
}
else
{
*(_WORD *)(a1 + 32) = 0;
v4 = (_QWORD *)(a1 + 32);
if ( (*(_BYTE *)(a1 + 80) & 1) != 0 )
{
LABEL_8:
v5 = *(_QWORD *)(a1 + 96);
goto LABEL_11;
}
}
v5 = a1 + 81;
LABEL_11:
curl_easy_setopt(v3, CURLOPT_URL, v5);
curl_easy_setopt(*(CURL **)(a1 + 128), CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(*(CURL **)(a1 + 128), CURLOPT_WRITEFUNCTION, sub_10056DB30);
curl_easy_setopt(*(CURL **)(a1 + 128), CURLOPT_WRITEDATA, v4);
if ( *(_DWORD *)(a1 + 152) )
curl_easy_setopt(*(CURL **)(a1 + 128), CURLOPT_CONNECTTIMEOUT);
if ( curl_easy_perform(*(CURL **)(a1 + 128)) )
{
v6 = operator new(0x10u);
v6[1] = 0;
*(_DWORD *)v6 = 3;
v7 = operator new(0x10u);
*(_OWORD *)v7 = 0;
*(_DWORD *)v7 = 1;
v7[1] = a1;
v6[1] = v7;
v8 = *(_QWORD *)(a1 + 136);
v9 = (pthread_mutex_t *)(v8 + 64);
pthread_mutex_lock((pthread_mutex_t *)(v8 + 64));
v10 = *(__int64 **)(v8 + 56);
v11 = operator new(0x18u);
v11[2] = v6;
v11[1] = v10;
v12 = *v10;
*v11 = *v10;
*(_QWORD *)(v12 + 8) = v11;
*v10 = (__int64)v11;
++v10[2];
pthread_mutex_unlock(v9);
curl_easy_cleanup(*(CURL **)(a1 + 128));
goto LABEL_15;
}
v14 = cocos2d::CCUserDefault::sharedUserDefault();
cocos2d::CCUserDefault::getStringForKey_1(&v25, v14, "current-version-code");
v15 = v25 & 1;
if ( (v25 & 1) != 0 )
{
v16 = v27;
v17 = *(unsigned __int8 *)(a1 + 32);
if ( (v17 & 1) == 0 )
goto LABEL_19;
LABEL_22:
LOBYTE(v4) = 1;
if ( v16 != *(_QWORD *)(a1 + 40) )
goto LABEL_30;
LABEL_23:
if ( v15 )
{
v18 = (char *)__s1;
if ( (v17 & 1) == 0 )
goto LABEL_25;
}
else
{
v18 = &v26;
if ( (v17 & 1) == 0 )
{
LABEL_25:
if ( memcmp(v18, (const void *)(a1 + 33), v16) )
goto LABEL_30;
LABEL_29:
v4 = operator new(0x10u);
v4[1] = 0;
*(_DWORD *)v4 = 3;
v19 = operator new(0x10u);
*(_OWORD *)v19 = 0;
*(_DWORD *)v19 = 2;
v19[1] = a1;
v4[1] = v19;
v20 = *(_QWORD *)(a1 + 136);
v21 = (pthread_mutex_t *)(v20 + 64);
pthread_mutex_lock((pthread_mutex_t *)(v20 + 64));
v22 = *(__int64 **)(v20 + 56);
v23 = operator new(0x18u);
v23[2] = v4;
v23[1] = v22;
v24 = *v22;
*v23 = *v22;
*(_QWORD *)(v24 + 8) = v23;
*v22 = (__int64)v23;
++v22[2];
pthread_mutex_unlock(v21);
sub_10056DBF0(a1);
v15 = v25 & 1;
LODWORD(v4) = 0;
goto LABEL_30;
}
}
if ( memcmp(v18, *(const void **)(a1 + 48), v16) )
goto LABEL_30;
goto LABEL_29;
}
v16 = v25 >> 1;
v17 = *(unsigned __int8 *)(a1 + 32);
if ( (v17 & 1) != 0 )
goto LABEL_22;
LABEL_19:
LOBYTE(v4) = 1;
if ( v16 == v17 >> 1 )
goto LABEL_23;
LABEL_30:
if ( v15 )
operator delete(__s1);
return (unsigned int)v4;
}