//
// sub_180114BD0 from 0x180114bd0 to 0x180114dc5 (501 bytes)
//
// 3 xrefs:
// > ??> @ 0x18016f588
// > ??> @ 0x180201ed4
// > ??> @ 0x180201ee0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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 10:54:36 +0000
//
__int64 __fastcall sub_180114BD0(__int64 a1, __int64 a2, __int64 a3)
{
char v3; // al
__int64 result; // rax
struct _RTL_CRITICAL_SECTION *v7; // rsi
int v8; // eax
int v9; // r8d
int v10; // edx
__int64 v11; // rcx
__int64 v12; // rcx
void *v13; // rcx
int v14; // eax
int v15; // r8d
int v16; // edx
__int64 v17; // rcx
__int64 v18; // rbx
unsigned int v19; // eax
int v20; // eax
v3 = *(_BYTE *)(a2 + 9);
switch ( v3 )
{
case 0:
result = sub_180114370(a1, a2, a3);
if ( (_DWORD)result )
return result;
return 0;
case 1:
v7 = *(struct _RTL_CRITICAL_SECTION **)(a1 + 56);
FMOD_OS_CriticalSection_Enter(v7);
if ( !*(_DWORD *)(a1 + 116) )
goto LABEL_11;
v8 = *(_DWORD *)(a1 + 88);
if ( !v8 )
goto LABEL_11;
v9 = *(_DWORD *)(a2 + 12);
v10 = *(_DWORD *)(*(_QWORD *)(a1 + 80) + 4LL * (v9 & (v8 - 1)));
if ( v10 == -1 )
goto LABEL_11;
v11 = *(_QWORD *)(a1 + 96);
while ( *(_DWORD *)(v11 + 16LL * v10) != v9 )
{
v10 = *(_DWORD *)(v11 + 16LL * v10 + 4);
if ( v10 == -1 )
goto LABEL_11;
}
v12 = *(_QWORD *)(v11 + 16LL * v10 + 8);
if ( !v12 )
goto LABEL_11;
*(_DWORD *)(v12 + 24) = *(_DWORD *)(a2 + 16);
*(_DWORD *)(v12 + 20) = *(_DWORD *)(a2 + 20);
v13 = *(void **)(v12 + 8);
LABEL_14:
sub_1800C14F0(v13);
LABEL_11:
FMOD_OS_CriticalSection_Leave(v7);
return 0;
case 2:
result = sub_1801146F0(a1, (_DWORD *)a2, a3);
if ( !(_DWORD)result )
return 0;
break;
case 3:
v7 = *(struct _RTL_CRITICAL_SECTION **)(a1 + 56);
FMOD_OS_CriticalSection_Enter(v7);
if ( !*(_DWORD *)(a1 + 116) )
goto LABEL_11;
v14 = *(_DWORD *)(a1 + 88);
if ( !v14 )
goto LABEL_11;
v15 = *(_DWORD *)(a2 + 12);
v16 = *(_DWORD *)(*(_QWORD *)(a1 + 80) + 4LL * (v15 & (v14 - 1)));
if ( v16 == -1 )
goto LABEL_11;
v17 = *(_QWORD *)(a1 + 96);
while ( *(_DWORD *)(v17 + 16LL * v16) != v15 )
{
v16 = *(_DWORD *)(v17 + 16LL * v16 + 4);
if ( v16 == -1 )
goto LABEL_11;
}
v18 = *(_QWORD *)(v17 + 16LL * v16 + 8);
if ( !v18 )
goto LABEL_11;
v19 = *(_DWORD *)(v18 + 40);
if ( *(_DWORD *)(a2 + 24) != v19 || *(_DWORD *)(a2 + 28) > v19 )
{
FMOD_OS_CriticalSection_Leave(v7);
return 28;
}
v20 = *(_DWORD *)(a2 + 16);
if ( v20 )
{
v13 = *(void **)(v18 + 8);
*(_DWORD *)(v18 + 48) = v20;
}
else
{
memmove(*(void **)(v18 + 32), (const void *)(a2 + 32), *(unsigned int *)(a2 + 28));
v13 = *(void **)(v18 + 8);
*(_DWORD *)(v18 + 44) = *(_DWORD *)(a2 + 28);
}
goto LABEL_14;
case 4:
result = sub_180113F70(a1, a2);
if ( !(_DWORD)result )
return 0;
break;
default:
return 0;
}
return result;
}