//
// sub_180017B30 from 0x180017b30 to 0x180018134 (1540 bytes)
//
// 2 xrefs:
// > sub_180018930 @ 0x180018934
// > ??> @ 0x18004c9f8
//
// 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:15:42 +0000
//
// Hidden C++ exception states: #wind=4
void __fastcall sub_180017B30(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
_Mtx_t v17; // rbx
void *v18; // rcx
void *v19; // rcx
void *Block[2]; // [rsp+30h] [rbp-30h] BYREF
__int64 v21; // [rsp+40h] [rbp-20h]
void *v22[2]; // [rsp+48h] [rbp-18h] BYREF
__int64 v23; // [rsp+58h] [rbp-8h]
int v24; // [rsp+90h] [rbp+30h] BYREF
double v25; // [rsp+98h] [rbp+38h] BYREF
v24 = 0;
v25 = COERCE_DOUBLE(sub_18001F040(0xA0u));
v2 = cocos2d::extension::CCHttpResponse::CCHttpResponse(*(cocos2d::extension::CCHttpResponse **)&v25, *a1);
*(_OWORD *)v22 = 0;
v23 = 0;
*(_OWORD *)Block = 0;
v21 = 0;
v3 = 1;
v4 = *a1;
v5 = *((_DWORD *)*a1 + 14);
if ( !v5 )
{
v16 = *((_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + (unsigned int)TlsIndex);
if ( !*(_BYTE *)(v16 + 16) )
sub_18001F1E8();
v12 = *(_QWORD *)(v16 + 304);
if ( !v12 )
goto LABEL_37;
curl_easy_reset(v12);
if ( !sub_180017740(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, &v24);
goto LABEL_36;
}
v6 = v5 - 1;
if ( !v6 )
{
v15 = *((_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + (unsigned int)TlsIndex);
if ( !*(_BYTE *)(v15 + 16) )
sub_18001F1E8();
v12 = *(_QWORD *)(v15 + 304);
if ( !v12 )
goto LABEL_37;
curl_easy_reset(v12);
if ( !sub_180017740(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) )
sub_18001F1E8();
v12 = *(_QWORD *)(v14 + 304);
if ( !v12 )
goto LABEL_37;
curl_easy_reset(v12);
if ( !sub_180017740(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) )
sub_18001F1E8();
v12 = *(_QWORD *)(v11 + 304);
if ( !v12 )
goto LABEL_37;
curl_easy_reset(v12);
if ( !sub_180017740(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) )
sub_18001F1E8();
v10 = *(_QWORD *)(v9 + 304);
if ( v10 )
{
curl_easy_reset(v10);
if ( sub_180017740(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, &v24);
v25 = 0.0;
curl_easy_getinfo(v10, 3145743, &v25);
*((_QWORD *)v4 + 21) = (int)v25;
LABEL_36:
v3 = (unsigned int)(v24 - 200) > 0x63;
}
}
}
}
LABEL_37:
*(_DWORD *)(v2 + 120) = v24;
*(_BYTE *)(v2 + 64) = !v3;
if ( Block[0] != Block[1] )
sub_180018D20(v2 + 96, Block);
if ( v22[0] != v22[1] )
sub_180018D20(v2 + 72, v22);
v17 = qword_18004A620;
v25 = *(double *)&qword_18004A620;
if ( Mtx_lock(qword_18004A620) )
{
std::_Throw_Cpp_error(5);
__debugbreak();
}
if ( *((_DWORD *)v17 + 19) == 0x7FFFFFFF )
{
*((_DWORD *)v17 + 19) = 2147483646;
std::_Throw_Cpp_error(6);
}
cocos2d::CCArray::addObject((cocos2d::CCArray *)qword_18004A770, (struct cocos2d::CCObject *)v2);
Mtx_unlock(v17);
cocos2d::CCObject::release((cocos2d::CCObject *)v2);
cocos2d::CCObject::release(*a1);
v18 = Block[0];
if ( Block[0] )
{
if ( v21 - (unsigned __int64)Block[0] >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v18);
*(_OWORD *)Block = 0;
v21 = 0;
}
v19 = v22[0];
if ( v22[0] )
{
if ( v23 - (unsigned __int64)v22[0] >= 0x1000 )
{
v19 = *((void **)v22[0] - 1);
if ( (unsigned __int64)((char *)v22[0] - (char *)v19 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v19);
}
}