//
// sub_180017BA0 from 0x180017ba0 to 0x18001818b (1515 bytes)
//
// 2 xrefs:
// > sub_180018C40 @ 0x180018c44
// > ??> @ 0x18004aaa0
//
// 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
//
// Hidden C++ exception states: #wind=4
void __fastcall sub_180017BA0(struct cocos2d::extension::CCHttpRequest **a1)
{
__int64 v2; // r14
BOOL v3; // ebx
struct cocos2d::extension::CCHttpRequest *v4; // rdi
int v5; // ecx
int v6; // ecx
int v7; // ecx
int v8; // ecx
__int64 v9; // rsi
__int64 v10; // rsi
__int64 v11; // rsi
__int64 v12; // rsi
__int64 v13; // rdx
__int64 v14; // rsi
__int64 v15; // rsi
__int64 v16; // rsi
void *v17; // rcx
void *v18; // rcx
void *Block[2]; // [rsp+20h] [rbp-30h] BYREF
__int64 v20; // [rsp+30h] [rbp-20h]
void *v21[2]; // [rsp+38h] [rbp-18h] BYREF
__int64 v22; // [rsp+48h] [rbp-8h]
int v23; // [rsp+80h] [rbp+30h] BYREF
double v24; // [rsp+88h] [rbp+38h] BYREF
v23 = 0;
v24 = COERCE_DOUBLE(operator new(0xA0u));
v2 = cocos2d::extension::CCHttpResponse::CCHttpResponse(*(cocos2d::extension::CCHttpResponse **)&v24, *a1);
*(_OWORD *)v21 = 0;
v22 = 0;
*(_OWORD *)Block = 0;
v20 = 0;
v3 = 1;
v4 = *a1;
v5 = *((_DWORD *)*a1 + 14);
if ( !v5 )
{
v16 = *((_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + (unsigned int)TlsIndex);
if ( !*(_BYTE *)(v16 + 16) )
_dyn_tls_on_demand_init();
v12 = *(_QWORD *)(v16 + 304);
if ( !v12 )
goto LABEL_37;
curl_easy_reset(v12);
if ( !sub_1800177D0(v12, (__int64)v4) )
goto LABEL_37;
curl_easy_setopt(v12, 10002);
curl_easy_setopt(v12, 20011);
curl_easy_setopt(v12, 10001);
curl_easy_setopt(v12, 20079);
curl_easy_setopt(v12, 10029);
curl_easy_setopt(v12, 43);
curl_easy_setopt(v12, 20056);
v13 = 10057;
LABEL_34:
curl_easy_setopt(v12, v13);
if ( (unsigned int)curl_easy_perform(v12) )
goto LABEL_37;
curl_easy_getinfo(v12, 2097154, &v23);
goto LABEL_36;
}
v6 = v5 - 1;
if ( !v6 )
{
v15 = *((_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + (unsigned int)TlsIndex);
if ( !*(_BYTE *)(v15 + 16) )
_dyn_tls_on_demand_init();
v12 = *(_QWORD *)(v15 + 304);
if ( !v12 )
goto LABEL_37;
curl_easy_reset(v12);
if ( !sub_1800177D0(v12, (__int64)v4) )
goto LABEL_37;
curl_easy_setopt(v12, 10002);
curl_easy_setopt(v12, 47);
goto LABEL_23;
}
v7 = v6 - 1;
if ( !v7 )
{
v14 = *((_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + (unsigned int)TlsIndex);
if ( !*(_BYTE *)(v14 + 16) )
_dyn_tls_on_demand_init();
v12 = *(_QWORD *)(v14 + 304);
if ( !v12 )
goto LABEL_37;
curl_easy_reset(v12);
if ( !sub_1800177D0(v12, (__int64)v4) )
goto LABEL_37;
curl_easy_setopt(v12, 10002);
curl_easy_setopt(v12, 10036);
LABEL_23:
curl_easy_setopt(v12, 10015);
curl_easy_setopt(v12, 60);
LABEL_17:
curl_easy_setopt(v12, 20011);
curl_easy_setopt(v12, 10001);
curl_easy_setopt(v12, 20079);
v13 = 10029;
goto LABEL_34;
}
v8 = v7 - 1;
if ( !v8 )
{
v11 = *((_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + (unsigned int)TlsIndex);
if ( !*(_BYTE *)(v11 + 16) )
_dyn_tls_on_demand_init();
v12 = *(_QWORD *)(v11 + 304);
if ( !v12 )
goto LABEL_37;
curl_easy_reset(v12);
if ( !sub_1800177D0(v12, (__int64)v4) )
goto LABEL_37;
curl_easy_setopt(v12, 10002);
curl_easy_setopt(v12, 10036);
goto LABEL_17;
}
if ( v8 == 1 )
{
v9 = *((_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + (unsigned int)TlsIndex);
if ( !*(_BYTE *)(v9 + 16) )
_dyn_tls_on_demand_init();
v10 = *(_QWORD *)(v9 + 304);
if ( v10 )
{
curl_easy_reset(v10);
if ( sub_1800177D0(v10, (__int64)v4) )
{
curl_easy_setopt(v10, 10002);
curl_easy_setopt(v10, 44);
curl_easy_setopt(v10, 20079);
curl_easy_setopt(v10, 10029);
if ( !(unsigned int)curl_easy_perform(v10) )
{
curl_easy_getinfo(v10, 2097154, &v23);
v24 = 0.0;
curl_easy_getinfo(v10, 3145743, &v24);
*((_QWORD *)v4 + 21) = (int)v24;
LABEL_36:
v3 = (unsigned int)(v23 - 200) > 0x63;
}
}
}
}
LABEL_37:
*(_DWORD *)(v2 + 120) = v23;
*(_BYTE *)(v2 + 64) = !v3;
if ( Block[0] != Block[1] )
sub_180018D70(v2 + 96, Block);
if ( v21[0] != v21[1] )
sub_180018D70(v2 + 72, v21);
v24 = COERCE_DOUBLE(&unk_180048630);
if ( Mtx_lock((_Mtx_t)&unk_180048630) )
{
std::_Throw_Cpp_error(5);
__debugbreak();
}
if ( dword_18004867C == 0x7FFFFFFF )
{
dword_18004867C = 2147483646;
std::_Throw_Cpp_error(6);
}
cocos2d::CCArray::addObject((cocos2d::CCArray *)qword_1800486C8, (struct cocos2d::CCObject *)v2);
Mtx_unlock((_Mtx_t)&unk_180048630);
cocos2d::CCObject::release((cocos2d::CCObject *)v2);
cocos2d::CCObject::release(*a1);
v17 = Block[0];
if ( Block[0] )
{
if ( v20 - (unsigned __int64)Block[0] >= 0x1000 )
{
v17 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v17 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v17);
*(_OWORD *)Block = 0;
v20 = 0;
}
v18 = v21[0];
if ( v21[0] )
{
if ( v22 - (unsigned __int64)v21[0] >= 0x1000 )
{
v18 = *((void **)v21[0] - 1);
if ( (unsigned __int64)((char *)v21[0] - (char *)v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
}