//
// sub_180078660 from 0x180078660 to 0x18007874f (239 bytes)
//
// 7 xrefs:
// > sub_180079470 @ 0x180079793
// > sub_180079470 @ 0x1800797c5
// > sub_180079470 @ 0x1800797fb
// > sub_180079470 @ 0x180079831
// > sub_180079470 @ 0x180079867
// > sub_180079470 @ 0x18007989d
// > ??> @ 0x1801b4a70
//
// 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
//
// Hidden C++ exception states: #wind=1
int __fastcall sub_180078660(__int64 a1, _OWORD *a2)
{
__int64 v4; // rbx
_QWORD *v5; // rdi
__int64 v6; // r8
__int64 v7; // rsi
_OWORD *v8; // rcx
v4 = a1 + 56;
if ( Mtx_lock((_Mtx_t)(a1 + 56)) )
{
std::_Throw_Cpp_error(5);
JUMPOUT(0x18007874ELL);
}
if ( *(_DWORD *)(v4 + 76) == 0x7FFFFFFF )
{
*(_DWORD *)(v4 + 76) = 2147483646;
std::_Throw_Cpp_error(6);
__debugbreak();
}
v5 = (_QWORD *)(a1 + 136);
if ( v5[2] <= (unsigned __int64)(v5[4] + 1LL) )
sub_180076180(v5, 1u);
v6 = v5[2] - 1LL;
v5[3] &= v6;
v7 = 8 * ((v5[4] + v5[3]) & v6);
if ( !*(_QWORD *)(v7 + v5[1]) )
*(_QWORD *)(v7 + v5[1]) = operator new(0x20u);
v8 = *(_OWORD **)(v7 + v5[1]);
*v8 = *a2;
v8[1] = a2[1];
++v5[4];
return Mtx_unlock((_Mtx_t)v4);
}