//
// sub_B9978C from 0xb9978c to 0xb998cc (320 bytes)
//
// 4 xrefs:
// > sub_B71138 @ 0xb71188
// > sub_B71B20 @ 0xb71b3c
// > sub_B9A870 @ 0xb9a8f0
// > sub_BAF6C4 @ 0xbaf6dc
//
// 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_B9978C(char **a1, int a2, char *a3, char *a4, char *a5)
{
char *v7; // x0
__int64 v8; // x20
char *v9; // x19
int v10; // w22
__int64 v11; // x1
unsigned int v12; // w0
__int64 v13; // x20
unsigned __int64 v14; // x22
bool v15; // zf
if ( !a2 || !a3 || !a4 || !a5 )
return 1;
a1[1] = a3;
a1[2] = a4;
*((_DWORD *)a1 + 8) = a2;
a1[3] = a5;
a1[5] = nullptr;
v7 = (char *)off_1231000(8LL * a2);
*a1 = v7;
if ( v7 )
{
if ( a2 <= 0 )
{
return 0;
}
else
{
v8 = 0;
v9 = v7;
v10 = 0;
while ( 1 )
{
*(_QWORD *)&v9[v8] = sub_B993D8((__int64)sub_B99724);
v9 = *a1;
v11 = *(_QWORD *)&(*a1)[v8];
v8 += 8;
if ( !v11 )
break;
if ( ++v10 == a2 )
return 0;
}
v12 = v10 - 1;
if ( v10 )
{
v13 = 8LL * (int)v12;
v14 = 8 * ((int)v12 - (unsigned __int64)v12);
do
{
sub_B99590(*(_QWORD **)&v9[v13], 0);
v15 = v13 == v14;
*(_QWORD *)&(*a1)[v13] = 0;
v13 -= 8;
v9 = *a1;
}
while ( !v15 );
}
off_1231008(v9);
*a1 = nullptr;
*((_DWORD *)a1 + 8) = 0;
return 1;
}
}
else
{
*((_DWORD *)a1 + 8) = 0;
return 1;
}
}