//
// sub_BA0ED8 from 0xba0ed8 to 0xba10a4 (460 bytes)
//
// 2 xrefs:
// > sub_BA2110 @ 0xba2534
// > ??> @ 0x111c908
//
// 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_BA0ED8(__int64 *a1, _BYTE *a2)
{
void *v4; // x0
__int64 v5; // x19
__int64 v6; // x2
int v7; // w22
__int64 v8; // x0
int v9; // w3
int v10; // w2
__int64 result; // x0
void *v12; // x0
int *v13; // x0
__int64 v14; // x19
const char *v15; // x0
void *v16; // x0
v4 = off_1231020(1u, 0x170u);
a1[195] = (__int64)v4;
v5 = (__int64)v4;
if ( !v4 )
return 27;
v6 = *(_QWORD *)(*a1 + 888);
if ( v6 )
{
result = 71;
if ( (unsigned int)(v6 - 8) > 0xFFB0 )
return result;
v7 = *(_QWORD *)(*a1 + 888);
}
else
{
v7 = 512;
}
if ( !*(_QWORD *)(v5 + 352) )
{
v12 = off_1231020(1u, v7 + 4);
*(_QWORD *)(v5 + 352) = v12;
if ( !v12 )
return 27;
}
if ( *(_QWORD *)(v5 + 360) || (v16 = off_1231020(1u, v7 + 4), (*(_QWORD *)(v5 + 360) = v16) != 0) )
{
sub_B99314((__int64)a1, 1);
v8 = a1[12];
v9 = *((_DWORD *)a1 + 152);
*(_QWORD *)(v5 + 16) = a1;
v10 = *(_DWORD *)(v8 + 4);
*(_DWORD *)(v5 + 24) = v9;
*(_DWORD *)v5 = 0;
*(_DWORD *)(v5 + 8) = -100;
*(_DWORD *)(v5 + 344) = v7;
*(_DWORD *)(v5 + 340) = 512;
*(_WORD *)(v5 + 72) = v10;
sub_BA09A0(v5);
if ( !*((_BYTE *)a1 + 979) )
{
if ( bind(*(_DWORD *)(v5 + 24), (const struct sockaddr *)(v5 + 72), *(_DWORD *)(a1[12] + 16)) )
{
v13 = (int *)__errno();
v14 = *a1;
v15 = (const char *)sub_B9F460((__int64)a1, *v13);
sub_B7B690(v14, "bind() failed; %s", v15);
return 7;
}
*((_BYTE *)a1 + 979) = 1;
}
sub_B72210(*a1);
*a2 = 1;
return 0;
}
return 27;
}