//
// sub_CABA8 from 0xcaba8 to 0xcad02 (346 bytes)
//
// 0 xrefs:
//
// 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
//
_DWORD *__fastcall sub_CABA8(int a1, int a2, _DWORD *a3)
{
int v4; // r0
_DWORD *v5; // r5
_DWORD *v6; // r9
int v7; // r3
int v8; // r6
int v9; // r4
signed int v10; // r6
signed int v11; // r0
_DWORD *v12; // r1
signed int i; // r0
signed int j; // r1
unsigned int v15; // r0
int v16; // r0
int v17; // r1
int v18; // r11
_DWORD *v19; // r0
int v20; // r1
int v21; // r6
int v22; // r8
int v23; // r4
int v24; // r2
int v25; // r5
int v26; // r12
char v27; // r0
_DWORD *v29; // [sp+4h] [bp-134h]
_DWORD *v30; // [sp+8h] [bp-130h]
_DWORD *v31; // [sp+Ch] [bp-12Ch]
int v32; // [sp+10h] [bp-128h]
int v33; // [sp+14h] [bp-124h]
_DWORD base[65]; // [sp+18h] [bp-120h] BYREF
v4 = sub_8112C(a1, 1, 1052);
v5 = (_DWORD *)v4;
if ( v4 )
{
*(_DWORD *)(v4 + 1036) = a3;
v6 = a3 + 209;
*(_DWORD *)(v4 + 1028) = a3[210];
v7 = 0;
v8 = 0;
while ( v7 < *a3 )
{
v9 = a3[++v7];
v8 += a3[v9 + 32];
}
v32 = v8;
v10 = v8 + 2;
v11 = 0;
v12 = a3 + 209;
v5[256] = v10;
while ( v11 < v10 )
base[v11++] = v12++;
qsort(base, v10, 4u, (__compar_fn_t)sub_CB0A4);
for ( i = 0; i < v10; ++i )
v5[i] = (base[i] - (int)v6) >> 2;
for ( j = 0; j < v10; ++j )
v5[v5[j] + 65] = j;
v15 = a3[208] - 1;
if ( v15 <= 3 )
v5[258] = dword_22BF8[v15];
v30 = v5 + 130;
v29 = v5 + 193;
v16 = v32;
v17 = 0;
v18 = 2;
v31 = v5;
while ( v17 < v16 )
{
v19 = &v6[v17];
v33 = v17;
v20 = v5[257];
v21 = 1;
v22 = v19[2];
v23 = 0;
v24 = 0;
v25 = 0;
while ( v18 != v23 )
{
v26 = v6[v23];
v27 = 0;
if ( v26 < v20 && v26 > v22 )
{
v20 = v6[v23];
v21 = v23;
}
if ( v26 > v25 )
v27 = 1;
if ( ((unsigned __int8)v27 & (v26 < v22)) != 0 )
{
v25 = v6[v23];
v24 = v23;
}
++v23;
}
++v18;
v29[v33] = v24;
v30[v33] = v21;
v17 = v33 + 1;
v5 = v31;
v16 = v32;
}
}
return v5;
}