//
// sub_BBCE4 from 0xbbce4 to 0xbbde0 (252 bytes)
//
// 2 xrefs:
// > ??> @ 0xbbce2
// > sub_62B54 @ 0x63efe
//
// 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:46 +0000
//
unsigned int __fastcall sub_BBCE4(_DWORD *a1, unsigned int a2, const void *a3)
{
unsigned int v4; // r1
unsigned int result; // r0
int v8; // r1
int v9; // r2
size_t v10; // r6
int v11; // r0
void *v12; // r0
int v13; // r0
int v14; // r0
int v15; // r1
unsigned int v16; // r1
v4 = a1[81];
result = 0;
if ( !v4 )
return result;
a1[82] = 0;
a1[80] = v4;
if ( a2 <= 0x800 )
a2 = 2048;
if ( a2 < v4 )
a2 = v4;
v8 = a2 % v4;
a1[81] = a2 - v8;
a1[84] = a2 - v8;
a1[85] = a2 - v8;
v9 = 2 * (a2 - v8);
v10 = a1[79];
a1[79] = v9;
v11 = *(int *)((char *)&dword_14C + (_DWORD)off_E8000);
if ( a3 )
{
v12 = (void *)sub_BD580(v11, v9 | 1, "../../src/fmod_file.cpp", 1815, 1);
a1[104] = v12;
if ( v12 )
{
qmemcpy(v12, a3, v10);
v13 = a1[104];
goto LABEL_10;
}
return 38;
}
v13 = sub_BD598(v11, a1[104], v9 | 1, "../../src/fmod_file.cpp", 1824, 1);
a1[104] = v13;
if ( !v13 )
return 38;
LABEL_10:
a1[103] = v13;
result = sub_BB00C((int)a1);
if ( !result )
{
j_FMOD_OS_CriticalSection_Enter(*(_DWORD *)(a1[89] + 336));
v14 = a1[89];
v15 = *(_DWORD *)(v14 + 316);
a1[2] = v14 + 316;
a1[1] = v15;
*(_DWORD *)(v15 + 4) = a1 + 1;
*(_DWORD *)a1[2] = a1 + 1;
j_FMOD_OS_CriticalSection_Leave(*(_DWORD *)(v14 + 336));
v16 = sub_BB510((int)a1);
result = v16 & 0xFFFFFFEF;
if ( (v16 & 0xFFFFFFEF) != 0 )
return v16;
}
return result;
}