//
// sub_CB918 from 0xcb918 to 0xcbbea (722 bytes)
//
// 1 xrefs:
// > ??> @ 0xcb916
//
// 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
//
int __fastcall sub_CB918(int a1, _DWORD *a2, _DWORD *a3)
{
int v4; // r0
int *v5; // r1
int v6; // r6
int v7; // r4
int v8; // r0
char *v9; // r5
_DWORD *v10; // r9
int v11; // r10
int v12; // r0
_DWORD *v13; // r4
int v14; // r0
int v15; // r10
_DWORD *v16; // r3
int v17; // lr
int v18; // r0
int v19; // r10
int v20; // r0
int i; // r1
__int64 v22; // kr00_8
int v23; // r0
int v24; // r1
float *v25; // r2
float *v26; // r3
int j; // r5
float v28; // s2
float v29; // s0
float v30; // s0
float v31; // s0
int k; // r5
int v33; // r0
int v34; // r0
int m; // r5
__int64 v37; // [sp+8h] [bp-50h] BYREF
int v38; // [sp+10h] [bp-48h]
_UNKNOWN **v39; // [sp+14h] [bp-44h]
_DWORD *v40; // [sp+18h] [bp-40h]
_DWORD *v41; // [sp+1Ch] [bp-3Ch]
int v42; // [sp+20h] [bp-38h]
_DWORD *v43; // [sp+24h] [bp-34h]
char *v44; // [sp+28h] [bp-30h]
int v45; // [sp+2Ch] [bp-2Ch]
int v46; // [sp+30h] [bp-28h]
_DWORD *v47; // [sp+34h] [bp-24h]
v42 = a1;
v4 = a2[7];
v5 = (int *)a2[16];
v47 = a2;
v6 = *v5;
v46 = v5[24];
v45 = *(_DWORD *)(v6 + 28);
v7 = *(_DWORD *)(v45 + 4 * v4);
a2[9] = v7;
v8 = *(_DWORD *)(v6 + 4);
v9 = (char *)&v37 - ((4 * v8 + 7) & 0xFFFFFFF8);
v38 = v7;
v40 = (_DWORD *)((2 * v7) & 0x7FFFFFFE);
v44 = v9;
v10 = a3 + 1;
v11 = 0;
v43 = a3 + 257;
v41 = a3;
while ( v11 < v8 )
{
v12 = v43[v10[v11]];
v13 = v47;
v14 = (*(int (__fastcall **)(int, _DWORD *, _DWORD))(dword_E5F7C[*(_DWORD *)(v45 + 4 * v12 + 796)] + 20))(
v42,
v47,
*(_DWORD *)(*(_DWORD *)(v46 + 20) + 4 * v12));
*(_DWORD *)&v44[4 * v11] = v14;
*(_DWORD *)&v9[4 * v11] = v14 != 0;
memset(*(void **)(*v13 + 4 * v11++), 0, (size_t)v40);
v8 = *(_DWORD *)(v6 + 4);
}
v15 = 0;
v16 = v41 + 290;
v17 = v41[289];
HIDWORD(v37) = v41 + 546;
LODWORD(v37) = v41 + 290;
while ( v15 < v17 )
{
v18 = v16[256];
if ( *(_DWORD *)&v9[4 * *v16] || *(_DWORD *)&v9[4 * v18] )
{
*(_DWORD *)&v9[4 * *v16] = 1;
*(_DWORD *)&v9[4 * v18] = 1;
}
++v16;
++v15;
}
v19 = 0;
v40 = v41 + 273;
v39 = &off_E5F84;
while ( v19 < *v41 )
{
v20 = 0;
for ( i = 0; i < *(_DWORD *)(v6 + 4); ++i )
{
if ( v10[i] == v19 )
{
*(_DWORD *)&v9[4 * v20] = *(_DWORD *)&v9[4 * i] != 0;
*(_DWORD *)&v9[4 * v20++] = *(_DWORD *)(*v47 + 4 * i);
}
}
(*((void (__fastcall **)(int, _DWORD *, _DWORD, char *, char *, int))v39[*(_DWORD *)(v45 + 4 * v40[v19] + 1308)] + 7))(
v42,
v47,
*(_DWORD *)(*(_DWORD *)(v46 + 24) + 4 * v40[v19]),
v9,
v9,
v20);
++v19;
}
v22 = v37;
v23 = v41[289];
v24 = v38 / 2;
LABEL_19:
if ( v23 > 0 )
{
--v23;
v25 = *(float **)(*v47 + 4 * *(_DWORD *)(HIDWORD(v22) + 4 * v23));
v26 = *(float **)(*v47 + 4 * *(_DWORD *)(v22 + 4 * v23));
for ( j = 0; ; ++j )
{
if ( j >= v24 )
goto LABEL_19;
v28 = *v26;
v29 = *v25;
if ( *v26 <= 0.0 )
{
if ( v29 > 0.0 )
{
v30 = v29 + v28;
goto LABEL_27;
}
v31 = v28 - v29;
*v25 = v28;
}
else
{
if ( v29 > 0.0 )
{
v30 = v28 - v29;
LABEL_27:
*v25 = v30;
goto LABEL_31;
}
*v25 = v28;
v31 = v29 + v28;
}
*v26 = v31;
LABEL_31:
++v25;
++v26;
}
}
for ( k = 0; ; ++k )
{
v33 = *(_DWORD *)(v6 + 4);
if ( k >= v33 )
break;
v34 = v43[v10[k]];
(*(void (__fastcall **)(_DWORD *, _DWORD, _DWORD, _DWORD))(dword_E5F7C[*(_DWORD *)(v45 + 4 * v34 + 796)] + 24))(
v47,
*(_DWORD *)(*(_DWORD *)(v46 + 20) + 4 * v34),
*(_DWORD *)&v44[4 * k],
*(_DWORD *)(*v47 + 4 * k));
}
for ( m = 0; m < v33; ++m )
{
sub_CBE86(**(_DWORD **)(v46 + 4 * v47[7] + 8), *(_DWORD *)(*v47 + 4 * m), *(_DWORD *)(*v47 + 4 * m));
v33 = *(_DWORD *)(v6 + 4);
}
return 0;
}