//
// sub_BABD74 from 0xbabd74 to 0xbabfb0 (572 bytes)
//
// 1 xrefs:
// > ??> @ 0x111cd80
//
// 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_BABD74(__int64 *a1, _BYTE *a2)
{
__int64 v2; // x24
unsigned int v3; // w22
const char *v5; // x19
__int64 v6; // x0
void *v7; // x25
__int64 v8; // x20
unsigned int v9; // w19
size_t v11; // x0
const char *v12; // x3
void *v13; // [xsp+68h] [xbp+68h] BYREF
size_t v14; // [xsp+70h] [xbp+70h] BYREF
__int64 v15; // [xsp+78h] [xbp+78h] BYREF
v2 = *a1;
v3 = *((_DWORD *)a1 + 152);
v5 = *(const char **)(*a1 + 36032);
*a2 = 1;
if ( strlen(v5) > 2 )
{
v11 = strlen(v5 + 2);
v12 = v5;
if ( v11 )
{
do
{
if ( v12[2] == 63 )
*((_BYTE *)v12 + 2) = 9;
++v12;
}
while ( v12 != &v5[v11] );
}
sub_B8B660(v2, (char *)v5 + 2, 0, &v13, &v15, 0);
v7 = v13;
if ( !v13 )
return 27;
v6 = v15;
}
else
{
v6 = 0;
v15 = 0;
v13 = &byte_F288A0;
v7 = nullptr;
}
v8 = sub_BABAA8(v6);
while ( 1 )
{
v9 = sub_B7BAC4((__int64)a1, v3, (__int64)v13, v8, (__int64 *)&v14);
if ( v9 )
goto LABEL_8;
v9 = sub_B7C1F0((__int64)a1, 2, (char *)v13, v14);
if ( v9 )
goto LABEL_8;
v8 -= v14;
v13 = (char *)v13 + v14;
if ( v8 <= 0 )
break;
if ( (sub_B9FFC8(-1, -1, v3, 100) & 0x80000000) != 0 )
{
v9 = 55;
LABEL_8:
off_1231008(v7);
LABEL_9:
sub_B7B690(v2, "Failed sending Gopher request");
return v9;
}
}
off_1231008(v7);
v9 = sub_B7B804(v3, a1, (__int64)&word_F203D8);
if ( v9 )
goto LABEL_9;
v9 = sub_B7C1F0((__int64)a1, 2, (char *)&word_F203D8, 2u);
if ( v9 )
return v9;
sub_B94394((__int64)a1, 0, -1, 0, v2 + 152, -1, 0);
return 0;
}