//
// sub_1800CFA60 from 0x1800cfa60 to 0x1800cfc3c (476 bytes)
//
// 8 xrefs:
// > sub_18001CFD0 @ 0x18001f4ba
// > FMOD::Channel::setPosition @ 0x1800a08e9
// > sub_1800CE1D0 @ 0x1800ce315
// > sub_1800CE3D0 @ 0x1800ce58f
// > sub_1800CEB90 @ 0x1800cec36
// > sub_1800D57B0 @ 0x1800d58be
// > ??> @ 0x1801fe9b8
// > ??> @ 0x1801fe9c4
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 10:54:09 +0000
//
__int64 __fastcall sub_1800CFA60(_QWORD *a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // rdi
__int64 v5; // rcx
__int64 result; // rax
__int64 v8; // rcx
_QWORD *v9; // r10
__int64 v10; // rax
__int64 v11; // r8
int v12; // ecx
float v13; // xmm1_4
__int64 v14; // rax
int v15; // ecx
int v16; // ecx
int v17; // ecx
unsigned __int64 v18; // rcx
unsigned int v19; // eax
__int64 v20; // rdx
__int64 v21; // [rsp+30h] [rbp+8h] BYREF
v4 = a2;
v5 = a1[59];
if ( !v5 || !a1[4] )
return 30;
if ( (a3 & 0x600) != 0 )
return 68;
v8 = *(_QWORD *)(v5 + 40);
if ( v8 && (a3 & 0x10) == 0 )
{
result = (*(__int64 (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v8 + 152LL))(v8, &v21);
if ( (_DWORD)result )
return result;
if ( (unsigned int)v4 >= (unsigned int)v21 )
return 32;
}
v9 = (_QWORD *)a1[59];
if ( (a3 & 7) == 0 )
{
result = (*(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, _QWORD))(*v9 + 208LL))(a1[59], (unsigned int)v4, a3, 0);
if ( (_DWORD)result )
return result;
goto LABEL_36;
}
v10 = v9[5];
if ( v10 )
{
v11 = *(unsigned int *)(v10 + 104);
v12 = *(_DWORD *)(v10 + 40);
v13 = *(float *)(v10 + 108);
goto LABEL_15;
}
v14 = v9[6];
if ( !v14 )
return 30;
v11 = *(unsigned __int16 *)(v14 + 280);
v12 = 5;
v13 = (float)*(int *)(a1[1] + 1744LL);
LABEL_15:
if ( (a3 & 2) == 0 )
{
if ( (a3 & 4) != 0 )
{
if ( !(_DWORD)v11 )
goto LABEL_32;
v15 = v12 - 1;
if ( v15 )
{
v16 = v15 - 1;
if ( v16 )
{
v17 = v16 - 1;
if ( v17 )
{
if ( (unsigned int)(v17 - 1) >= 2 )
{
HIDWORD(v21) = v4;
goto LABEL_32;
}
v18 = 32;
}
else
{
v18 = 24;
}
}
else
{
v18 = 16;
}
}
else
{
v18 = 8;
}
v19 = (unsigned int)(8 * v4 / v18) / (unsigned int)v11;
}
else
{
if ( (a3 & 1) == 0 )
goto LABEL_33;
v19 = (int)(float)((float)((float)((float)(int)v4 * 0.001) * v13) + 0.5);
}
HIDWORD(v21) = v19;
goto LABEL_32;
}
HIDWORD(v21) = v4;
LABEL_32:
LODWORD(v21) = 0;
LABEL_33:
result = (*(__int64 (__fastcall **)(_QWORD *, __int64, __int64))(*v9 + 120LL))(v9, v21, v11);
if ( !(_DWORD)result )
{
LABEL_36:
LOBYTE(v20) = 1;
return sub_1800D0760(a1, v20);
}
return result;
}