//
// sub_180047970 from 0x180047970 to 0x1800479fa (138 bytes)
//
// 4 xrefs:
// > sub_180046AC0 @ 0x180046bf2
// > sub_180046C80 @ 0x180046e31
// > sub_180046F20 @ 0x180046f80
// > ??> @ 0x1801b18a8
//
// 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_180047970(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
_QWORD *v6; // rcx
__int64 result; // rax
v6 = *(_QWORD **)a1;
if ( v6 )
{
if ( (unsigned __int64)(2 * ((__int64)(*(_QWORD *)(a1 + 16) - (_QWORD)v6) >> 1)) >= 0x1000 )
{
if ( (unsigned __int64)v6 - *(v6 - 1) - 8 > 0x1F )
invalid_parameter_noinfo_noreturn();
v6 = (_QWORD *)*(v6 - 1);
}
j_j_free_0(v6);
}
*(_QWORD *)a1 = a2;
*(_QWORD *)(a1 + 8) = a2 + 2 * a3;
result = a2 + 2 * a4;
*(_QWORD *)(a1 + 16) = result;
return result;
}