//
// sub_CFA100 from 0xcfa100 to 0xcfa260 (352 bytes)
//
// 3 xrefs:
// > sub_CD4850 @ 0xcd4898
// > sub_CF0974 @ 0xcf09c0
// > sub_CF9F50 @ 0xcf9f5c
//
// 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_CFA100(_QWORD *a1, _QWORD *a2, _BYTE *a3)
{
unsigned __int64 v4; // x2
unsigned int *v6; // x1
unsigned int v8; // w2
__int64 v9; // x21
__int64 v10; // x0
__int64 v11; // x19
unsigned int *v12; // x0
int *v13; // x1
int v14; // w0
unsigned int *v15; // x0
v4 = a1[3];
v6 = (unsigned int *)a1[2];
*a3 = 1;
if ( (unsigned __int64)v6 >= v4 )
v8 = (*(__int64 (__fastcall **)(_QWORD *))(*a1 + 72LL))(a1);
else
v8 = *v6;
v9 = 0;
while ( v8 != -1 )
{
v11 = (__int64)(a1[3] - a1[2]) >> 2;
if ( v11 > 1 )
{
v10 = (*(__int64 (__fastcall **)(_QWORD *))(*a2 + 96LL))(a2);
v9 += v10;
a1[2] += 4 * v10;
if ( v11 > v10 )
goto LABEL_17;
}
else
{
v12 = (unsigned int *)a2[5];
if ( (unsigned __int64)v12 >= a2[6] )
{
if ( (*(unsigned int (__fastcall **)(_QWORD *, _QWORD))(*a2 + 104LL))(a2, v8) == -1 )
{
LABEL_17:
*a3 = 0;
return v9;
}
}
else
{
*v12 = v8;
a2[5] = v12 + 1;
}
v13 = (int *)a1[2];
++v9;
if ( (unsigned __int64)v13 >= a1[3] )
{
v14 = (*(__int64 (__fastcall **)(_QWORD *))(*a1 + 80LL))(a1);
}
else
{
v14 = *v13;
a1[2] = v13 + 1;
}
if ( v14 == -1 )
return v9;
v15 = (unsigned int *)a1[2];
if ( (unsigned __int64)v15 < a1[3] )
{
v8 = *v15;
continue;
}
}
v8 = (*(__int64 (__fastcall **)(_QWORD *))(*a1 + 72LL))(a1);
}
return v9;
}