//
// sub_B9D6EC from 0xb9d6ec to 0xb9d96c (640 bytes)
//
// 2 xrefs:
// > sub_B94C64 @ 0xb94d74
// > sub_B9D96C @ 0xb9d990
//
// 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_B9D6EC(__int64 a1, _DWORD *a2)
{
__time_t v4; // x22
__int64 v5; // x1
__int64 v6; // x23
__int64 result; // x0
__int64 v8; // x19
int v9; // w27
int v10; // w20
__int64 v11; // x2
__int64 v12; // x26
__int64 *v13; // x28
__int64 ***v14; // x21
__int64 **v15; // x19
__int64 **v16; // x20
bool v17; // cc
__int64 **v18; // x1
__int64 **v19; // x1
__int64 v20; // x5
_QWORD v21[4]; // [xsp+78h] [xbp+78h] BYREF
_QWORD v22[2]; // [xsp+98h] [xbp+98h] BYREF
__int64 v23; // [xsp+A8h] [xbp+A8h]
__int64 v24; // [xsp+B0h] [xbp+B0h]
char v25; // [xsp+B8h] [xbp+B8h]
v4 = sub_B70B94();
v6 = v5;
if ( !a1 )
return 1;
result = 1;
if ( *(_QWORD *)a1 != 764702 )
return result;
v8 = *(_QWORD *)(a1 + 8);
if ( !v8 )
{
v9 = 0;
goto LABEL_14;
}
v9 = 0;
do
{
while ( 1 )
{
v25 = *(_BYTE *)(v8 + 1596);
if ( !v25 )
break;
v10 = sub_B9C364(a1, v4, v6, v8);
if ( v25 )
goto LABEL_6;
LABEL_11:
sigaction(13, (const struct sigaction *)v22, nullptr);
v8 = *(_QWORD *)v8;
if ( v10 )
v9 = v10;
if ( !v8 )
goto LABEL_14;
}
v22[0] = 0;
v22[1] = 0;
v23 = 0;
v24 = 0;
sigaction(13, nullptr, (struct sigaction *)v22);
v21[0] = v22[0];
v21[2] = v23;
v21[3] = v24;
v21[1] = 1;
sigaction(13, (const struct sigaction *)v21, nullptr);
v10 = sub_B9C364(a1, v4, v6, v8);
if ( !v25 )
goto LABEL_11;
LABEL_6:
v8 = *(_QWORD *)v8;
if ( v10 )
v9 = v10;
}
while ( v8 );
LABEL_14:
while ( 1 )
{
*(_QWORD *)(a1 + 128) = sub_BA2F00(v4, v6, *(_QWORD *)(a1 + 128), v22);
v11 = v22[0];
if ( !v22[0] )
break;
v12 = *(_QWORD *)(v22[0] + 40LL) + 0x8000LL;
v13 = (__int64 *)(*(_QWORD *)(v22[0] + 40LL) + 35920LL);
v14 = *(__int64 ****)(*(_QWORD *)(v22[0] + 40LL) + 35984LL);
v15 = *v14;
if ( !*v14 )
goto LABEL_25;
do
{
v16 = (__int64 **)v15[2];
v17 = sub_B70BFC(**v15, (*v15)[1], v4, v6) <= 0;
v18 = v15;
v15 = v16;
if ( !v17 )
break;
sub_B994E4((__int64)v14, v18, 0);
}
while ( v16 );
v19 = *v14;
if ( *v14 )
{
v20 = (*v19)[1];
*v13 = **v19;
v13[1] = v20;
sub_B994E4((__int64)v14, v19, 0);
*(_QWORD *)(a1 + 128) = sub_BA2E0C(*v13, v13[1], *(_QWORD *)(a1 + 128), v12 + 3168);
if ( !v22[0] )
break;
}
else
{
v11 = v22[0];
LABEL_25:
*(_QWORD *)(v12 + 3152) = 0;
*(_QWORD *)(v12 + 3160) = 0;
if ( !v11 )
break;
}
}
*a2 = *(_DWORD *)(a1 + 28);
if ( v9 <= 0 )
sub_B9A724((_QWORD *)a1);
return (unsigned int)v9;
}