//
// sub_BA7AFC from 0xba7afc to 0xba7d5c (608 bytes)
//
// 2 xrefs:
// > ??> @ 0x111cab8
// > ??> @ 0x111cb68
//
// 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_BA7AFC(__int64 a1, bool *a2)
{
__int64 v3; // x23
__int64 v5; // x26
unsigned int v6; // w21
unsigned __int8 *v7; // x0
unsigned __int8 *v8; // x19
int v9; // w2
int v10; // t1
_BOOL4 v11; // w3
unsigned __int8 *v12; // x20
int v13; // w2
int v14; // t1
int v15; // w0
__int64 result; // x0
char *v17; // x19
__int64 v18; // x0
*a2 = 0;
v3 = a1 + 1560;
v5 = a1 + 1696;
v6 = 0;
sub_B99314(a1, 0);
*(_QWORD *)(v3 + 80) = 1800000;
*(_QWORD *)(v3 + 96) = sub_BA80C0;
*(_QWORD *)(v3 + 104) = sub_BA763C;
*(_QWORD *)(v3 + 88) = a1;
*(_DWORD *)(v3 + 172) = -1;
sub_BAE990(v5, &off_111CB10);
sub_BAA2E0(v3);
v7 = *(unsigned __int8 **)(a1 + 552);
*(_BYTE *)(v3 + 160) = 1;
while ( v7 )
{
if ( v6 )
break;
if ( !*v7 )
{
v6 = *v7;
if ( *(_DWORD *)(v3 + 172) != 2 )
goto LABEL_19;
goto LABEL_30;
}
v8 = v7;
if ( *v7 == 61 )
goto LABEL_10;
do
{
v10 = *++v8;
v9 = v10;
v11 = v10 != 0;
}
while ( v10 != 61 && v11 );
if ( v9 != 59 && v11 )
{
LABEL_10:
v12 = v8;
do
{
v14 = *++v12;
v13 = v14;
}
while ( v14 != 59 && v13 );
v6 = 3;
if ( (unsigned int)sub_B94674(v7, "AUTH=", 5) )
{
LABEL_25:
v17 = (char *)(v8 + 1);
v6 = sub_BAE84C(v5, v17);
if ( v6 && (unsigned int)sub_B94674(v17, "+APOP", v12 - (unsigned __int8 *)v17) )
{
v6 = 0;
*(_DWORD *)(v3 + 172) = 2;
*(_DWORD *)(v3 + 152) = 0;
}
}
}
else
{
v12 = v8;
v6 = 3;
if ( (unsigned int)sub_B94674(v7, "AUTH=", 5) )
goto LABEL_25;
}
if ( *v12 == 59 )
v7 = v12 + 1;
else
v7 = v12;
}
if ( *(_DWORD *)(v3 + 172) != 2 )
{
LABEL_19:
v15 = *(_DWORD *)(v3 + 152);
if ( v15 )
{
if ( v15 == -33 )
{
*(_DWORD *)(v3 + 172) = -1;
goto LABEL_22;
}
v15 = 4;
}
*(_DWORD *)(v3 + 172) = v15;
result = v6;
if ( v6 )
return result;
goto LABEL_30;
}
LABEL_22:
result = v6;
if ( v6 )
return result;
LABEL_30:
v18 = *(_QWORD *)(a1 + 1024);
*(_DWORD *)(v3 + 112) = 1;
if ( (*(_DWORD *)(v18 + 124) & 1) == 0
|| *(_BYTE *)(v3 + 116)
|| (result = sub_BB9FA4(a1, *(unsigned __int8 *)(v3 + 116), a1 + 1676), !(_DWORD)result) && *(_BYTE *)(v3 + 116) )
{
result = sub_BAA0F4(v3, 0);
*a2 = *(_DWORD *)(v3 + 112) == 0;
}
return result;
}