//
// sub_CD2B4 from 0xcd2b4 to 0xcd460 (428 bytes)
//
// 1 xrefs:
// > sub_CD4F4 @ 0xcd5fc
//
// 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_CD2B4(int a1, int *a2, int a3, int a4)
{
int v8; // r9
int v9; // r11
int v10; // r0
float v11; // s16
float v12; // s18
bool v13; // zf
int result; // r0
int v15; // r12
int v16; // lr
int v17; // r9
int i; // r8
int v19; // r4
float v20; // s4
int v21; // r1
int v22; // r11
int v23; // r3
int v24; // r2
float v25; // s2
float v26; // s6
int v27; // r2
int v28; // r6
int v29; // r2
int v30; // r11
float v31; // s22
int v32; // r4
int v33; // r9
int *v34; // r1
float v35; // s0
float v36; // s2
int v37; // r0
int v38; // r0
int v39; // [sp+0h] [bp-50h]
int v40; // [sp+4h] [bp-4Ch]
int v41; // [sp+8h] [bp-48h]
int v42; // [sp+Ch] [bp-44h]
if ( (unsigned int)(a2[3] - 1) > 1 )
return 0;
v8 = sub_CD0B2(a2[4]);
v9 = sub_CD0B2(a2[5]);
v42 = sub_8112C(a1, *a2 * a3, 4);
if ( !v42 )
return 0;
v10 = a2[3];
v11 = *(float *)&v8;
v12 = *(float *)&v9;
if ( v10 == 1 )
{
v28 = sub_CD22E(a2);
v39 = a2[1];
v40 = 0;
v29 = 0;
result = v42;
while ( v29 < v39 )
{
if ( !a4 || *(_DWORD *)(a2[2] + 4 * v29) )
{
v30 = *a2;
v31 = 0.0;
v32 = 1;
v33 = 0;
v41 = *a2 * v40;
while ( v33 < v30 )
{
v34 = (int *)(a2[8] + 4 * (v29 / v32 % v28));
v32 *= v28;
v35 = (float)(v31 + v11) + (float)(fabsf((float)*v34) * v12);
v36 = v35;
if ( !a2[7] )
v36 = v31;
v37 = v41;
if ( a4 )
v37 = *(_DWORD *)(a4 + 4 * v40) * v30;
v38 = v37 + v33++;
v31 = v36;
*(float *)(v42 + 4 * v38) = v35;
}
++v40;
result = v42;
}
++v29;
}
}
else
{
v13 = v10 == 2;
result = v42;
if ( v13 )
{
v15 = a2[1];
v16 = 0;
v17 = 0;
for ( i = 0; i < v15; ++i )
{
if ( !a4 || *(_DWORD *)(a2[2] + 4 * i) )
{
v19 = *a2;
v20 = 0.0;
v21 = 0;
v22 = *a2 * v16;
v23 = *a2 * v17;
while ( v21 < v19 )
{
v24 = v23;
v25 = (float)(v20 + v11) + (float)(fabsf((float)*(int *)(a2[8] + v22 + 4 * v21)) * v12);
v26 = v25;
if ( !a2[7] )
v26 = v20;
if ( a4 )
v24 = *(_DWORD *)(a4 + 4 * v17) * v19;
v20 = v26;
v27 = v24 + v21++;
*(float *)(v42 + 4 * v27) = v25;
}
++v17;
}
v16 += 4;
}
}
}
return result;
}