//
// sub_BAFA8C from 0xbafa8c to 0xbafb78 (236 bytes)
//
// 1 xrefs:
// > sub_B87370 @ 0xb87410
//
// 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_BAFA8C(__int64 result, __int64 a2)
{
__int64 v2; // x20
__int64 v3; // x21
_QWORD *v4; // x0
_QWORD *v6; // x1
_QWORD *v7; // x0
_QWORD *v8; // x2
_QWORD *v9; // x0
__int64 v10[3]; // [xsp+38h] [xbp+38h] BYREF
v2 = *(_QWORD *)(a2 + 1816);
if ( v2 )
{
v3 = result;
v4 = *(_QWORD **)(v2 + 16);
v6 = (_QWORD *)*v4;
if ( *v4 )
{
while ( a2 != *v6 )
{
v6 = (_QWORD *)v6[2];
if ( !v6 )
goto LABEL_16;
}
sub_B994E4((__int64)v4, v6, 0);
result = *(_QWORD *)(v2 + 8) - 1LL;
*(_QWORD *)(v2 + 8) = result;
*(_QWORD *)(a2 + 1816) = 0;
if ( result )
goto LABEL_7;
}
else
{
LABEL_16:
result = *(_QWORD *)(v2 + 8);
if ( result )
goto LABEL_7;
}
if ( v3 )
{
sub_B99E04(v3, (__int64)v10);
v7 = (_QWORD *)sub_B99E14(v10);
v8 = v7;
if ( !v7 )
{
LABEL_8:
result = *(_QWORD *)(v3 + 48) - 1LL;
*(_QWORD *)(v3 + 48) = result;
return result;
}
if ( v2 != *v7 )
{
do
{
v9 = (_QWORD *)sub_B99E14(v10);
v8 = v9;
if ( !v9 )
goto LABEL_8;
}
while ( v2 != *v9 );
}
result = sub_B99A3C(v3, v8[1], v8[2]);
LABEL_7:
if ( !v3 )
return result;
goto LABEL_8;
}
}
return result;
}