//
// sub_1800C6FD0 from 0x1800c6fd0 to 0x1800c7167 (407 bytes)
//
// 2 xrefs:
// > sub_1800E31C0 @ 0x1800e35ff
// > ??> @ 0x1801fe070
//
// 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_1800C6FD0(int a1, __int64 *a2)
{
__int64 v4; // rbx
__int64 *v5; // r14
struct _RTL_CRITICAL_SECTION *v6; // rsi
void *v7; // rax
unsigned int v8; // edi
char v10[256]; // [rsp+50h] [rbp-138h] BYREF
v4 = qword_1801EF9A8[a1];
v5 = &qword_1801EF9A8[a1];
if ( v4 )
goto LABEL_8;
v6 = *((struct _RTL_CRITICAL_SECTION **)off_1801AED20 + 37);
FMOD_OS_CriticalSection_Enter(v6);
v4 = *v5;
if ( *v5 )
{
LABEL_7:
FMOD_OS_CriticalSection_Leave(v6);
LABEL_8:
*a2 = v4;
return 0;
}
v7 = sub_1800B6880(
*((_QWORD *)off_1801AED20 + 52),
376,
"C:\\buildagent1\\work\\570ad728b1678096\\core_api\\src\\fmod_async.cpp",
368,
0x200000);
v4 = (__int64)v7;
if ( v7 )
{
sub_1800B8400((__int64)v7);
*(_DWORD *)(v4 + 368) = a1;
*(_QWORD *)(v4 + 344) = v4 + 336;
*(_QWORD *)(v4 + 336) = v4 + 336;
*(_QWORD *)(v4 + 352) = 0;
*(_QWORD *)(v4 + 360) = 0;
v8 = FMOD_OS_CriticalSection_Create((struct _RTL_CRITICAL_SECTION **)(v4 + 360), 0);
if ( !v8 )
{
sub_1800B7CA0((int)v10, 256, "FMOD nonblocking thread (%d)", *(_DWORD *)(v4 + 368));
v8 = sub_1800B8690(v4, v10, (__int64)sub_1800C6FC0, v4, 4, 1, 0, 0, 1);
if ( !v8 )
{
*((_QWORD *)off_1801AED20 + *(int *)(v4 + 368) + 38) = *(_QWORD *)(v4 + 272);
*v5 = v4;
goto LABEL_7;
}
}
}
else
{
v8 = 38;
}
FMOD_OS_CriticalSection_Leave(v6);
return v8;
}