//
// sub_B7DB50 from 0xb7db50 to 0xb7dcf0 (416 bytes)
//
// 2 xrefs:
// > ??> @ 0x111c360
// > ??> @ 0x111c3e0
//
// 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_B7DB50(_BYTE *a1, unsigned __int8 a2)
{
int v2; // w21
_BYTE *v4; // x19
void *v5; // x1
char *v6; // x0
__int64 v7; // x20
int v8; // w21
int v9; // w0
bool v10; // cc
__int64 v12; // x22
const char *v13; // x0
v2 = a2;
v4 = a1 + 1560;
if ( a2 )
{
a1[1705] = 0;
}
else if ( a1[1705] )
{
if ( (unsigned int)sub_BAA4B0(v4, "%s", "QUIT") )
{
v12 = *(_QWORD *)a1;
v13 = (const char *)sub_B9EF34();
sub_B7B690(v12, "Failure sending QUIT command: %s", v13);
a1[1705] = v2;
sub_B99314(a1, 1);
*((_DWORD *)v4 + 44) = v2;
}
else
{
*((_DWORD *)v4 + 44) = 34;
while ( !(unsigned int)sub_BAA0F4(v4, 1) && *((_DWORD *)v4 + 44) )
;
}
}
v5 = *((void **)v4 + 14);
if ( v5 )
{
if ( v5 == *(void **)(*(_QWORD *)a1 + 35992LL) )
*(_QWORD *)(*(_QWORD *)a1 + 35992LL) = 0;
off_1231008(v5);
*((_QWORD *)v4 + 14) = 0;
}
v6 = *((char **)v4 + 15);
if ( v6 )
{
if ( *((int *)v4 + 32) > 0 )
{
v7 = 0;
v8 = 0;
do
{
++v8;
off_1231008(*(void **)&v6[v7]);
v9 = *((_DWORD *)v4 + 32);
*(_QWORD *)(*((_QWORD *)v4 + 15) + v7) = 0;
v10 = v8 < v9;
v7 += 8;
v6 = *((char **)v4 + 15);
}
while ( v10 );
}
off_1231008(v6);
*((_QWORD *)v4 + 15) = 0;
*((_DWORD *)v4 + 32) = 0;
}
off_1231008(*((void **)v4 + 17));
*((_QWORD *)v4 + 17) = 0;
off_1231008(*((void **)v4 + 26));
*((_QWORD *)v4 + 26) = 0;
off_1231008(*((void **)v4 + 19));
*((_QWORD *)v4 + 19) = 0;
off_1231008(*((void **)v4 + 24));
*((_QWORD *)v4 + 24) = 0;
sub_BAAAC8(v4);
return 0;
}