//
// cocos2d::extension::CCHttpClient::availableThreadCount from 0x180018190 to 0x180018212 (130 bytes)
//
// 2 xrefs:
// > ??> @ 0x18002fdf8
// > ??> @ 0x18004aaac
//
// 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 cocos2d::extension::CCHttpClient::availableThreadCount(cocos2d::extension::CCHttpClient *this)
{
__int64 v1; // rdi
struct _Mtx_internal_imp_t *v2; // rbx
unsigned __int64 v3; // rdx
unsigned __int64 v4; // rax
__int64 v5; // rdi
v1 = *((_QWORD *)this + 7);
v2 = (struct _Mtx_internal_imp_t *)(v1 + 64);
if ( Mtx_lock((_Mtx_t)(v1 + 64)) )
{
std::_Throw_Cpp_error(5);
__debugbreak();
}
if ( *(_DWORD *)(v1 + 140) == 0x7FFFFFFF )
{
*(_DWORD *)(v1 + 140) = 2147483646;
std::_Throw_Cpp_error(6);
__debugbreak();
}
v3 = *(_QWORD *)(v1 + 56) + *(_QWORD *)(v1 + 224);
v4 = (__int64)(*(_QWORD *)(v1 + 8) - *(_QWORD *)v1) >> 4;
v5 = v4 - v3;
if ( v4 <= v3 )
v5 = 0;
Mtx_unlock(v2);
return v5;
}