//
// sub_9D7EC from 0x9d7ec to 0x9db58 (876 bytes)
//
// 1 xrefs:
// > sub_9BBEA @ 0x9bbec
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:41:31 +0000
//
int __fastcall sub_9D7EC(int a1, int a2, float a3)
{
_DWORD *v4; // r6
__int64 v5; // kr08_8
int v6; // r8
float v7; // s16
int i; // r5
int v9; // r0
int v10; // r5
int v11; // r1
int v12; // r10
int v13; // r0
int v14; // r12
bool v15; // zf
bool v16; // zf
int v17; // r4
int v18; // r1
float v19; // s2
int v20; // r0
float v21; // s4
float v22; // s6
float v23; // r5
float v24; // s12
float v25; // s10
float v26; // s14
float v27; // s8
int v28; // r6
int v29; // r5
float *v30; // r5
int v31; // r4
int v32; // r3
_DWORD *v33; // r0
int v34; // r2
int v35; // r2
int v36; // r1
int v37; // r5
int v38; // r10
int v39; // r9
int v40; // r4
int v41; // r11
float *v42; // r0
int v43; // r1
int v44; // r1
int v45; // r0
unsigned int v47; // lr
int v48; // r3
_DWORD *v49; // r2
int *v50; // [sp+10h] [bp-38h]
_DWORD *v51; // [sp+14h] [bp-34h]
int v52; // [sp+18h] [bp-30h] BYREF
char v53; // [sp+1Ch] [bp-2Ch]
v52 = *(_DWORD *)(a1 + 128);
v53 = 0;
v4 = (_DWORD *)(a1 + 49528);
v5 = *(_QWORD *)(a1 + 49532);
v6 = *(_DWORD *)(a1 + 49552);
v7 = *(float *)(a1 + 49528);
v51 = (_DWORD *)(a1 + 49528);
switch ( a2 )
{
case 0:
*(float *)v4 = a3;
if ( a3 == 0.0 )
*v4 = 1065353216;
break;
case 1:
if ( a3 <= 4096.0 )
{
for ( i = 256; i <= 4096; i *= 2 )
{
if ( (float)i >= a3 )
goto LABEL_14;
}
}
else
{
i = 4096;
LABEL_14:
if ( (_DWORD)v5 != i )
{
sub_9DB7C(&v52);
v4 = v51;
v51[1] = i;
}
}
break;
case 2:
if ( HIDWORD(v5) != 4 )
{
sub_9DB7C(&v52);
v4 = v51;
v51[2] = 4;
}
break;
case 3:
*(_DWORD *)(a1 + 49540) = (int)a3;
break;
default:
break;
}
v9 = *(_DWORD *)(a1 + 128);
v4[5] = *(_DWORD *)(v9 + 1184);
v10 = v4[3];
if ( !v10 )
v10 = *(_DWORD *)(v9 + 1188);
if ( v10 != v6 )
{
sub_9DB7C(&v52);
v4 = v51;
v51[6] = v10;
}
v11 = v4[1];
if ( (_DWORD)v5 == v11 )
{
v12 = v5;
LABEL_24:
if ( HIDWORD(v5) == v4[2] )
goto LABEL_57;
goto LABEL_25;
}
v13 = v4[4];
if ( !v13 )
{
LABEL_52:
v31 = 30;
goto LABEL_76;
}
sub_9BD64(v13, v11);
v4 = v51;
v12 = v51[1];
if ( (_DWORD)v5 == v12 )
goto LABEL_24;
LABEL_25:
v14 = v4[4];
if ( !v14 )
goto LABEL_52;
v15 = v12 == 4096;
if ( v12 != 4096 )
v15 = v12 == 512;
if ( !v15 )
{
if ( v12 == 1024 )
{
v48 = 1;
v49 = &unk_40B40;
goto LABEL_35;
}
v16 = v12 == 2048;
if ( v12 != 2048 )
v16 = v12 == 256;
if ( !v16 )
{
v47 = 0;
v48 = 0;
v49 = nullptr;
goto LABEL_36;
}
}
v48 = 0;
v49 = &unk_40B40;
LABEL_35:
v47 = 513;
LABEL_36:
v17 = a1 + 33144;
v18 = 2 * (v47 - 1);
v19 = 1.0 / sqrtf((float)((float)v12 * 0.25) * (float)(int)v51[2]);
v20 = 0;
v21 = (float)(int)(v47 - 1);
v22 = (float)v18;
while ( v20 < v12 )
{
if ( v48 )
{
if ( v20 >= v47 )
v23 = *(float *)&v49[v18];
else
v23 = *(float *)&v49[v20];
*(float *)(v17 + 4 * v20) = v23;
v27 = v23;
}
else
{
v24 = (float)((float)v20 * v22) * (float)(1.0 / (float)v12);
v25 = v24;
if ( v24 > v21 )
v25 = v22 - v24;
v26 = (float)(int)v25;
v27 = *(float *)&v49[v25];
if ( v25 != v26 )
{
v28 = 1;
if ( v24 > v21 )
v28 = -1;
v29 = (int)v25 + v28;
if ( v29 >= 0 )
v27 = v27 + (float)((float)(*(float *)&v49[v29] - v27) * (float)(v25 - v26));
}
*(float *)(v17 + 4 * v20) = v27;
}
v30 = (float *)(v17 + 4 * v20);
--v18;
++v20;
*v30 = v27 * v19;
}
v32 = 0;
v33 = (_DWORD *)(v14 + 81952);
v34 = v51[6];
while ( v32 < v34 )
{
*v33 = a1 + 33144;
v33 += 20495;
++v32;
}
sub_AB144(a1);
v4 = v51;
LABEL_57:
v35 = v4[6];
v36 = v4[4];
if ( v35 != v6 )
{
v50 = v4 + 4;
if ( v36 )
{
sub_BD7AC(*(int *)((char *)&dword_14C + (_DWORD)off_E8000), v36, "../../src/fmod_dsp_pitchshift.cpp", 2195, 1);
v35 = v4[6];
}
goto LABEL_62;
}
if ( !v36 )
{
v50 = v4 + 4;
LABEL_62:
v36 = sub_BD410(
*(int *)((char *)&dword_14C + (_DWORD)off_E8000),
81980 * v35,
"../../src/fmod_dsp_pitchshift.cpp",
2198);
*v50 = v36;
if ( !v36 )
{
v31 = 38;
goto LABEL_76;
}
v4 = v51;
v37 = 81972;
v38 = a1 + 33144;
v39 = a1 + 376;
v40 = 0;
v41 = 0;
while ( 1 )
{
v6 = v51[6];
if ( v41 >= v6 )
break;
sub_9CDB8(v36 + v40);
++v41;
v36 = *v50;
*(_DWORD *)(v36 + v37) = v39;
*(_DWORD *)(v36 + v37 - 20) = v38;
v40 += 81980;
v37 += 81980;
}
}
v42 = (float *)(v36 + 81976);
v43 = 0;
while ( v43 < v6 )
{
++v43;
v15 = v7 == *(float *)v4;
*(v42 - 4) = *(float *)v4 * (float)(1.0 / v7);
if ( !v15 )
*(_BYTE *)v42 = 1;
v42 += 20495;
}
v44 = v4[1];
v45 = 0;
while ( v44 >= 2 )
{
++v45;
v44 = (unsigned int)v44 >> 1;
}
v31 = 0;
v4[7] = v45;
LABEL_76:
sub_9DB90(&v52);
return v31;
}