//
// sub_140063390 from 0x140063390 to 0x14006357c (492 bytes)
//
// 2 xrefs:
// > FMODAudioEngine::queuePlayEffect @ 0x140057ada
// > ??> @ 0x1406c5cac
//
// 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: #try_helpers=1
__int64 __fastcall sub_140063390(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v5; // r10
__int64 v6; // rbx
__int64 v7; // rcx
unsigned __int64 v8; // r13
unsigned __int64 v9; // rdx
unsigned __int64 v10; // rcx
__int64 v11; // r12
_QWORD *v12; // rsi
__int64 v13; // r15
__int64 v14; // rdx
__int64 v15; // rcx
_QWORD *v16; // r8
__int64 v17; // rbx
__int64 i; // r14
_QWORD *v19; // r8
v5 = *a1;
v6 = (a2 - *a1) / 112;
v7 = a1[1] - *a1;
if ( v7 / 112 == 0x249249249249249LL )
sub_140062A20();
v8 = v7 / 112 + 1;
v9 = (a1[2] - v5) / 112;
if ( v9 <= 0x249249249249249LL - (v9 >> 1) )
{
v10 = v7 / 112 + 1;
if ( (v9 >> 1) + v9 >= v8 )
v10 = (v9 >> 1) + v9;
if ( v10 > 0x249249249249249LL )
sub_140007AB0();
}
else
{
v10 = 0x249249249249249LL;
}
v11 = 14 * v10;
v12 = sub_14003AA10(112 * v10);
v13 = (__int64)&v12[14 * v6];
sub_14005B3A0(v13, a3);
v14 = a1[1];
v15 = *a1;
v16 = v12;
if ( a2 != v14 )
{
sub_140063950(v15, a2, v12);
v16 = (_QWORD *)(v13 + 112);
v14 = a1[1];
v15 = a2;
}
sub_140063950(v15, v14, v16);
v17 = *a1;
if ( *a1 )
{
for ( i = a1[1]; v17 != i; v17 += 112 )
sub_14003A830(v17);
v19 = (_QWORD *)*a1;
if ( (unsigned __int64)(112 * ((a1[2] - *a1) / 112)) >= 0x1000 )
{
if ( (unsigned __int64)v19 - *(v19 - 1) - 8 > 0x1F )
invalid_parameter_noinfo_noreturn();
v19 = (_QWORD *)*(v19 - 1);
}
j_j_free(v19);
}
*a1 = (__int64)v12;
a1[1] = (__int64)&v12[14 * v8];
a1[2] = (__int64)&v12[v11];
return v13;
}