//
// sub_C9AF18 from 0xc9af18 to 0xc9affc (228 bytes)
//
// 2 xrefs:
// > sub_C9BDA0 @ 0xc9c0bc
// > sub_C9BDA0 @ 0xc9c124
//
// 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_C9AF18(__int64 result, __int64 **a2)
{
__int64 *v2; // x2
__int64 *v3; // x5
int v4; // w3
int v5; // w4
int v6; // w6
if ( a2 )
{
v2 = a2[1];
v3 = &v2[*((int *)a2 + 4)];
}
else
{
v3 = nullptr;
v2 = nullptr;
}
LABEL_3:
while ( v2 )
{
while ( 1 )
{
if ( *(_BYTE *)v2 == 2 )
{
v4 = *((_DWORD *)v2 + 1);
v5 = v4 / (int)result;
v6 = v4 % (int)result;
if ( v4 % (int)result > 8 || v5 > 7 )
{
if ( v6 < (int)result - 7 || v5 > 6 )
*((_DWORD *)v2 + 1) = v4 + 120;
else
*((_DWORD *)v2 + 1) = byte_F55BD0[16 * v5 + 24 + (int)result - v6] + 1;
}
else
{
*((_DWORD *)v2 + 1) = byte_F55BD0[16 * v5 + 8 - v6] + 1;
}
}
if ( v3 != ++v2 )
break;
a2 = (__int64 **)*a2;
if ( !a2 )
{
v2 = nullptr;
v3 = nullptr;
goto LABEL_3;
}
v2 = a2[1];
v3 = &v2[*((int *)a2 + 4)];
if ( !v2 )
return result;
}
}
return result;
}