//
// sub_B9DE5C from 0xb9de5c to 0xb9df44 (232 bytes)
//
// 2 xrefs:
// > sub_B9E24C @ 0xb9e4a4
// > sub_B9E24C @ 0xb9e53c
//
// 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_B9DE5C(_BYTE *a1, __int64 a2, _QWORD *a3)
{
unsigned int v3; // w5
char v4; // w6
__int64 v6; // x3
_BYTE *v7; // x4
__int64 v8; // x0
v3 = 1;
v4 = a1[3];
if ( a1[2] == 8 && (a1[3] & 0xE0) == 0 )
{
v6 = a2 - 10;
v7 = a1 + 10;
if ( (a1[3] & 4) != 0 )
{
v3 = 2;
if ( v6 <= 1 )
return v3;
v8 = (unsigned __int8)a1[10] | ((unsigned __int8)a1[11] << 8);
if ( v6 <= v8 + 1 )
return v3;
v6 = v6 - v8 - 2;
v7 += v8 + 2;
}
if ( (v4 & 8) != 0 )
{
if ( !v6 )
return 2;
while ( *v7 )
{
--v6;
++v7;
if ( !v6 )
return 2;
}
--v6;
++v7;
}
if ( (v4 & 0x10) != 0 )
{
if ( !v6 )
return 2;
while ( *v7 )
{
--v6;
++v7;
if ( !v6 )
return 2;
}
--v6;
}
if ( (v4 & 2) == 0 )
goto LABEL_15;
v3 = 2;
if ( v6 > 1 )
{
v6 -= 2;
LABEL_15:
v3 = 0;
*a3 = a2 - v6;
}
}
return v3;
}