//
// sub_140061560 from 0x140061560 to 0x140061880 (800 bytes)
//
// 46 xrefs:
// > FMODAudioEngine::playEffectAdvanced @ 0x140057035
// > FMODAudioEngine::stopChannel @ 0x1400587ba
// > FMODAudioEngine::setChannelVolume @ 0x140058f16
// > FMODAudioEngine::setChannelVolumeMod @ 0x1400590e6
// > FMODAudioEngine::setChannelPitch @ 0x140059235
// > FMODAudioEngine::isMusicPlaying_1 @ 0x140059d69
// > FMODAudioEngine::isMusicPlaying @ 0x140059f6a
// > FMODAudioEngine::loadAndPlayMusic @ 0x14005a0ee
// > FMODAudioEngine::playMusic @ 0x14005a200
// > FMODAudioEngine::playMusic @ 0x14005a265
// > FMODAudioEngine::loadMusic @ 0x14005a38e
// > FMODAudioEngine::loadMusic @ 0x14005a408
// > FMODAudioEngine::loadMusic @ 0x14005a4e8
// > FMODAudioEngine::startMusic @ 0x14005a696
// > FMODAudioEngine::isPersistentMatchPlaying @ 0x14005adf5
// > FMODAudioEngine::isPersistentMatchPlaying @ 0x14005ae55
// > FMODAudioEngine::updateQueuedMusic @ 0x14005b80e
// > FMODAudioEngine::updateQueuedMusic @ 0x14005b840
// > FMODAudioEngine::triggerQueuedMusic @ 0x14005ba4c
// > FMODAudioEngine::triggerQueuedMusic @ 0x14005bb2c
// > FMODAudioEngine::swapMusicIndex @ 0x14005bfb9
// > FMODAudioEngine::swapMusicIndex @ 0x14005bff9
// > FMODAudioEngine::swapMusicIndex @ 0x14005c00c
// > FMODAudioEngine::swapMusicIndex @ 0x14005c05e
// > FMODAudioEngine::swapMusicIndex @ 0x14005c0bc
// > FMODAudioEngine::swapMusicIndex @ 0x14005c0cf
// > FMODAudioEngine::swapMusicIndex @ 0x14005c11e
// > FMODAudioEngine::swapMusicIndex @ 0x14005c131
// > FMODAudioEngine::setMusicTimeMS @ 0x14005c1ed
// > FMODAudioEngine::setMusicTimeMS @ 0x14005c228
// > FMODAudioEngine::setMusicTimeMS @ 0x14005c277
// > FMODAudioEngine::getMusicTimeMS @ 0x14005c327
// > FMODAudioEngine::getMusicLengthMS @ 0x14005c38d
// > FMODAudioEngine::fadeInMusic @ 0x14005c43d
// > FMODAudioEngine::fadeOutMusic @ 0x14005c57d
// > FMODAudioEngine::fadeMusic @ 0x14005c6c5
// > FMODAudioEngine::preloadMusic @ 0x14005c829
// > FMODAudioEngine::preloadMusic @ 0x14005c8c2
// > FMODAudioEngine::preloadMusic @ 0x14005ca43
// > FMODAudioEngine::stopAndRemoveMusic @ 0x14005caec
// > FMODAudioEngine::stopAndRemoveMusic @ 0x14005cb29
// > FMODAudioEngine::stopAndRemoveMusic @ 0x14005cb49
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x140243c10
// > GJBaseGameLayer::processSongState @ 0x140245c46
// > PlayLayer::showCompleteEffect @ 0x1403a947d
// > ??> @ 0x1406c59ac
//
// 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=2
__int64 __fastcall sub_140061560(_QWORD *a1, __int64 a2, unsigned __int8 *a3)
{
_QWORD *v6; // r8
__int64 v7; // rcx
__int64 v8; // rax
__int64 *v9; // rbx
__int64 *v10; // r12
__int64 *v11; // r15
__int64 *v12; // rcx
__int64 *v14; // r13
char *v15; // rsi
float v16; // xmm3_4
__int64 v17; // rcx
float v18; // xmm0_4
unsigned __int64 v19; // rdi
float v20; // xmm2_4
__int64 v21; // rcx
float v22; // xmm0_4
unsigned __int64 v23; // rcx
unsigned __int64 v24; // rax
unsigned __int64 v25; // rcx
unsigned __int64 v26; // r8
__int64 v27; // rcx
__int64 *v28; // rax
__int64 *v29; // rdx
int v30; // ecx
_QWORD *v31; // rax
_QWORD *v32; // rdx
__int64 v33; // rcx
__int64 v34; // rax
__int64 *v35; // r8
__int64 *v36; // [rsp+20h] [rbp-48h]
_QWORD *v37; // [rsp+70h] [rbp+8h]
unsigned __int64 v38; // [rsp+80h] [rbp+18h]
v38 = 0x100000001B3LL
* (a3[3]
^ (0x100000001B3LL * (a3[2] ^ (0x100000001B3LL * (a3[1] ^ (0x100000001B3LL * (*a3 ^ 0xCBF29CE484222325uLL)))))));
v6 = a1 + 6;
v7 = 2 * (v38 & a1[6]);
v8 = a1[3];
v9 = *(__int64 **)(v8 + 8 * v7 + 8);
v10 = (__int64 *)a1[1];
if ( v9 == v10 )
{
v9 = (__int64 *)a1[1];
v37 = v6;
v11 = v9;
goto LABEL_9;
}
v12 = *(__int64 **)(v8 + 8 * v7);
if ( *(_DWORD *)a3 != *((_DWORD *)v9 + 4) )
{
while ( v9 != v12 )
{
v9 = (__int64 *)v9[1];
if ( *(_DWORD *)a3 == *((_DWORD *)v9 + 4) )
goto LABEL_6;
}
v10 = v9;
v37 = a1 + 6;
v11 = v9;
LABEL_9:
v14 = a1 + 3;
if ( a1[2] == 0x333333333333333LL )
std::_Xlength_error("unordered_map/set too long");
v15 = (char *)operator new(0x50u);
*((_DWORD *)v15 + 4) = *(_DWORD *)a3;
*(_OWORD *)(v15 + 24) = 0;
*(_OWORD *)(v15 + 56) = 0;
*((_QWORD *)v15 + 9) = 0;
*((_DWORD *)v15 + 6) = 0;
*((_QWORD *)v15 + 4) = 0;
*(_OWORD *)(v15 + 40) = 0;
*((_QWORD *)v15 + 7) = 0;
*((_QWORD *)v15 + 8) = 15;
v15[40] = 0;
*((_WORD *)v15 + 36) = 0;
v16 = *(float *)a1;
v17 = a1[2] + 1LL;
if ( v17 < 0 )
v18 = (float)(v17 & 1 | (unsigned int)((unsigned __int64)v17 >> 1))
+ (float)(v17 & 1 | (unsigned int)((unsigned __int64)v17 >> 1));
else
v18 = (float)(int)v17;
v19 = a1[7];
if ( (v19 & 0x8000000000000000uLL) != 0LL )
{
v21 = a1[7] & 1LL | (v19 >> 1);
v20 = (float)(int)v21 + (float)(int)v21;
}
else
{
v20 = (float)(int)v19;
}
if ( (float)(v18 / v20) > v16 )
{
v22 = ceilf(v18 / v16);
v23 = 0;
if ( v22 >= 9.223372e18 )
{
v22 = v22 - 9.223372e18;
if ( v22 < 9.223372e18 )
v23 = 0x8000000000000000uLL;
}
v24 = v23 + (unsigned int)(int)v22;
v25 = 8;
if ( v24 > 8 )
v25 = v24;
if ( v19 < v25 )
{
if ( v19 >= 0x200 || (v19 *= 8LL, v19 < v25) )
v19 = v25;
}
sub_14005EF40(a1, v19);
v26 = v38;
v27 = a1[3];
v28 = *(__int64 **)(v27 + 16 * (a1[6] & v38) + 8);
v9 = (__int64 *)a1[1];
if ( v28 != v9 )
{
v29 = *(__int64 **)(v27 + 16 * (a1[6] & v38));
v30 = *((_DWORD *)v15 + 4);
if ( v30 != *((_DWORD *)v28 + 4) )
{
while ( 1 )
{
v9 = v28;
if ( v28 == v29 )
break;
v28 = (__int64 *)v28[1];
if ( v30 == *((_DWORD *)v28 + 4) )
goto LABEL_31;
}
v36 = v28;
v11 = v28;
v14 = a1 + 3;
v31 = a1 + 6;
v10 = v36;
LABEL_35:
v32 = (_QWORD *)v9[1];
++a1[2];
*(_QWORD *)v15 = v10;
*((_QWORD *)v15 + 1) = v32;
*v32 = v15;
v9[1] = (__int64)v15;
v33 = *v14;
v34 = 2 * (v26 & *v31);
v35 = *(__int64 **)(*v14 + 8 * v34);
if ( v35 == (__int64 *)a1[1] )
{
*(_QWORD *)(v33 + 8 * v34) = v15;
LABEL_40:
*(_QWORD *)(v33 + 8 * v34 + 8) = v15;
goto LABEL_41;
}
if ( v35 == v11 )
{
*(_QWORD *)(v33 + 8 * v34) = v15;
}
else if ( *(_QWORD **)(v33 + 8 * v34 + 8) == v32 )
{
goto LABEL_40;
}
LABEL_41:
*(_QWORD *)a2 = v15;
*(_BYTE *)(a2 + 8) = 1;
return a2;
}
LABEL_31:
v9 = (__int64 *)*v28;
}
v11 = v9;
v14 = a1 + 3;
v31 = a1 + 6;
v10 = v9;
goto LABEL_35;
}
v31 = v37;
v26 = v38;
goto LABEL_35;
}
LABEL_6:
*(_QWORD *)a2 = v9;
*(_BYTE *)(a2 + 8) = 0;
return a2;
}