//
// sub_1801091F0 from 0x1801091f0 to 0x180109360 (368 bytes)
//
// 2 xrefs:
// > ??> @ 0x1801b0820
// > ??> @ 0x1802016c4
//
// 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
//
__int64 __fastcall sub_1801091F0(__int64 a1, int a2)
{
struct _RTL_CRITICAL_SECTION *v2; // r14
__int64 v5; // rax
__int64 v6; // rsi
int *v7; // rbx
__int64 v8; // rax
unsigned int v9; // edi
int v10; // eax
int *v11; // rax
__int64 v12; // r8
int v13; // ecx
int v15; // [rsp+50h] [rbp+8h] BYREF
v2 = lpCriticalSection;
FMOD_OS_CriticalSection_Enter(lpCriticalSection);
v5 = qword_1801F24F0[*(int *)(a1 + 48)];
if ( v5 )
{
if ( a2 )
{
if ( a2 == 1 )
{
v11 = (int *)(v5 + 108);
v12 = 32;
do
{
v13 = 1 - *v11;
*v11 = v13;
v11 += 28;
*((_BYTE *)v11 + v13 - 120) = 0;
*((_BYTE *)v11 + *(v11 - 28) - 118) = 0;
*((_BYTE *)v11 + *(v11 - 28) - 116) = 0;
--v12;
}
while ( v12 );
}
}
else
{
v6 = 0;
v7 = (int *)(v5 + 92);
do
{
if ( !*v7 )
{
v8 = *(_QWORD *)(a1 + 40);
v15 = 0;
v9 = (*(__int64 (__fastcall **)(__int64, int *, _QWORD))(v8 + 56))(a1, &v15, 0);
if ( v9 )
goto LABEL_24;
if ( v15 > 1000 )
{
LABEL_16:
v10 = 0;
}
else if ( v15 == 1000 )
{
LABEL_10:
v10 = 2;
}
else
{
switch ( v15 )
{
case 2:
v10 = 1;
break;
case 3:
goto LABEL_10;
case 4:
v10 = 4;
break;
case 5:
v10 = 5;
break;
case 6:
v10 = 6;
break;
case 7:
v10 = 8;
break;
case 8:
v10 = 12;
break;
default:
goto LABEL_16;
}
}
*v7 = v10;
}
++v6;
v7 += 28;
}
while ( v6 < 32 );
}
}
v9 = 0;
LABEL_24:
FMOD_OS_CriticalSection_Leave(v2);
return v9;
}