//
// lws_client_connect from 0xbc1064 to 0xbc1238 (468 bytes)
//
// 3 xrefs:
// > cocos2d::extension::WebSocket::onSubThreadStarted @ 0xaada08
// > lws_client_connect_extended @ 0xbc1254
// > ??> @ 0x67710
//
// 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 lws_client_connect(
__int64 a1,
_BYTE *a2,
unsigned int a3,
int a4,
_BYTE *a5,
_BYTE *a6,
_BYTE *a7,
_BYTE *a8,
int a9)
{
_BYTE *v16; // x0
__int64 v17; // x19
char v18; // w1
v16 = sub_BBF8A8(0xD8u);
v17 = (__int64)v16;
if ( !v16 )
goto LABEL_16;
v18 = a9;
if ( a9 == -1 )
v18 = 13;
*(_QWORD *)v16 = a1;
v16[66] = v18;
*((_DWORD *)v16 + 22) = -1;
*((_QWORD *)v16 + 18) = 0;
v16[73] = 6;
*((_QWORD *)v16 + 1) = 0;
v16[77] = 0;
if ( a4 )
{
lws_log(1, "libwebsockets not configured for ssl\n");
goto LABEL_16;
}
if ( (unsigned int)sub_BBDDB0((__int64)v16) )
{
LABEL_16:
sub_BBF88C((void *)v17, 0);
return 0;
}
*(_WORD *)(*(_QWORD *)(v17 + 152) + 2124LL) = a3;
if ( (unsigned int)sub_BBE054(v17, 78, a2)
|| (unsigned int)sub_BBE054(v17, 79, a5)
|| (unsigned int)sub_BBE054(v17, 80, a6)
|| a7 && (unsigned int)sub_BBE054(v17, 81, a7)
|| a8 && (unsigned int)sub_BBE054(v17, 77, a8) )
{
sub_BBF88C(*(void **)(v17 + 152), 0);
goto LABEL_16;
}
*(_QWORD *)(v17 + 8) = *(_QWORD *)(a1 + 4584);
if ( (int)sub_BC4538(a1, v17, 17, a2, a3) <= 0 )
return sub_BC0C6C(v17);
lws_set_timeout(v17, 7, 5);
*(_BYTE *)(v17 + 72) = 13;
return v17;
}