//
// sub_51FA4 from 0x51fa4 to 0x52090 (236 bytes)
//
// 1 xrefs:
// > sub_6DB70 @ 0x6df0c
//
// 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_51FA4(int a1, unsigned __int64 *a2)
{
unsigned __int64 v2; // x21
__int64 v5; // x23
unsigned int v6; // w20
__int64 v8; // x0
__int64 v9; // [xsp+0h] [xbp-40h] BYREF
char v10; // [xsp+8h] [xbp-38h]
v2 = atomic_load(&qword_11F750[a1]);
if ( v2 )
goto LABEL_4;
v5 = a1;
v9 = *(__int64 *)((char *)&qword_138 + (_QWORD)off_114000);
FMOD_OS_CriticalSection_Enter(v9);
v10 = 1;
v2 = atomic_load(&qword_11F750[v5]);
if ( !v2 )
{
v8 = sub_E2AC4(
*(__int64 *)((char *)&qword_1B0 + (_QWORD)off_114000),
376,
"../../src/fmod_async.cpp",
368,
0x200000);
if ( v8 )
{
v2 = v8;
sub_51DE4(v8);
v6 = sub_51EF4(v2, a1);
if ( !v6 )
{
atomic_store(v2, &qword_11F750[v5]);
goto LABEL_3;
}
}
else
{
v6 = 38;
}
sub_52090(&v9);
return v6;
}
LABEL_3:
sub_52090(&v9);
LABEL_4:
v6 = 0;
*a2 = v2;
return v6;
}