//
// sub_BFB8A8 from 0xbfb8a8 to 0xbfb978 (208 bytes)
//
// 2 xrefs:
// > sub_BFCC40 @ 0xbfcd70
// > sub_BFD428 @ 0xbfdea8
//
// 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_BFB8A8(__int64 (__fastcall ***a1)(_QWORD), __int64 a2)
{
__int64 (__fastcall **v2)(_QWORD); // x2
_BYTE *v4; // x3
__int64 v5; // x3
__int64 result; // x0
_BYTE *v7; // x2
__int64 v8; // x1
int v9; // w0
void (__fastcall *v10)(__int64 (__fastcall ***)(_QWORD), __int64); // x3
__int64 (__fastcall *v11)(_QWORD); // x2
__int64 v12; // [xsp+28h] [xbp+28h]
v2 = a1[5];
v4 = *v2;
*v2 = (__int64 (__fastcall *)(_QWORD))((char *)*v2 + 1);
*v4 = BYTE1(a2);
v5 = (__int64)v2[1] - 1;
v2[1] = (__int64 (__fastcall *)(_QWORD))v5;
if ( !v5 )
{
v12 = a2;
v9 = ((__int64 (*)(void))v2[3])();
LOBYTE(a2) = v12;
if ( !v9 )
{
v10 = (void (__fastcall *)(__int64 (__fastcall ***)(_QWORD), __int64))**a1;
*((_DWORD *)*a1 + 10) = 25;
v10(a1, v12);
LOBYTE(a2) = v12;
}
}
result = (__int64)a1[5];
v7 = (_BYTE *)(*(_QWORD *)result)++;
*v7 = a2;
v8 = *(_QWORD *)(result + 8) - 1LL;
*(_QWORD *)(result + 8) = v8;
if ( !v8 )
{
result = (*(__int64 (__fastcall **)(_QWORD))(result + 24))(a1);
if ( !(_DWORD)result )
{
v11 = **a1;
*((_DWORD *)*a1 + 10) = 25;
return v11(a1);
}
}
return result;
}