//
// sub_1004C656C from 0x1004c656c to 0x1004c674c (480 bytes)
//
// 3 xrefs:
// > sub_1004C1E04 @ 0x1004c1e04
// > ??> @ 0x100828a30
// > ??> @ 0x100828bc0
//
// 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_1004C656C(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4, unsigned int a5)
{
__int64 result; // x0
unsigned int v7; // w8
unsigned int v8; // w9
unsigned int v9; // w8
unsigned int v10; // w9
unsigned int v11; // w9
unsigned int v12; // w8
unsigned int v13; // w10
unsigned int v14; // w9
bool v15; // cf
unsigned int v16; // w9
unsigned int *v17; // x8
unsigned int v18; // w9
result = 19;
if ( a3 > 4 )
return result;
if ( ((1 << a3) & 0x16) == 0 )
return result;
result = 19;
if ( a5 > 4 || ((1 << a5) & 0x16) == 0 )
return result;
if ( a3 == 1 )
{
a2 = (unsigned int)(float)((float)((float)a2 / 1000.0) * *(float *)(a1 + 108));
if ( a5 != 1 )
goto LABEL_17;
}
else
{
if ( a3 != 4 )
{
if ( a3 != 2 )
a2 = 0;
if ( a5 == 1 )
goto LABEL_25;
LABEL_17:
if ( a5 == 4 )
{
v9 = *(_DWORD *)(a1 + 104);
if ( v9 )
{
v10 = *(_DWORD *)(a1 + 40) - 1;
if ( v10 <= 4 )
a4 = (unsigned int)(8 * (unsigned __int64)a4 / qword_10064B368[v10]) / v9;
}
else
{
a4 = 0;
}
}
else if ( a5 != 2 )
{
a4 = 0;
}
goto LABEL_27;
}
v7 = *(_DWORD *)(a1 + 104);
if ( v7 )
{
v8 = *(_DWORD *)(a1 + 40) - 1;
if ( v8 <= 4 )
a2 = (unsigned int)(8 * (unsigned __int64)a2 / qword_10064B368[v8]) / v7;
if ( a5 == 1 )
goto LABEL_25;
goto LABEL_17;
}
a2 = 0;
if ( a5 != 1 )
goto LABEL_17;
}
LABEL_25:
a4 = (unsigned int)(float)((float)((float)a4 / 1000.0) * *(float *)(a1 + 108));
LABEL_27:
v11 = *(_DWORD *)(a1 + 68);
if ( a2 >= v11 )
v12 = 0;
else
v12 = a2;
v13 = v11 - 1;
if ( a4 >= v11 )
v14 = v11 - 1;
else
v14 = a4;
if ( !v14 )
v14 = v13;
v15 = v14 >= v12;
v16 = v14 - v12;
if ( v16 == 0 || !v15 )
return 31;
*(_DWORD *)(a1 + 76) = v12;
*(_DWORD *)(a1 + 80) = v16 + 1;
result = (**(__int64 (__fastcall ***)(__int64))a1)(a1);
if ( (_DWORD)result )
{
if ( (*(_DWORD *)(a1 + 76) || *(_DWORD *)(a1 + 80) != *(_DWORD *)(a1 + 68)) && (*(_BYTE *)(a1 + 44) & 6) != 0 )
{
v17 = (unsigned int *)(a1 + 88);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 | 0x10, v17) );
}
return 0;
}
return result;
}