//
// sub_C56BF8 from 0xc56bf8 to 0xc56d50 (344 bytes)
//
// 1 xrefs:
// > sub_C55E2C @ 0xc5611c
//
// 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_C56BF8(__int64 result, __int16 *a2, __int64 a3, long double a4, long double a5)
{
__int64 v5; // x20
__int64 v8; // x22
__int64 i; // x24
int v10; // w1
int v11; // w19
int v12; // w0
int v13; // w3
int v14; // w2
int v15; // w25
v5 = result;
v8 = *(_QWORD *)(result + 16);
if ( a3 > 0 )
{
for ( i = 0; i != a3; ++i )
{
while ( 1 )
{
v15 = *a2;
if ( v15 > 0 )
{
v10 = *(_DWORD *)(v5 + 4);
v11 = 16760832;
if ( v15 <= 7409 )
{
v11 = (v15 - 3314) >> 2 << 14;
if ( v10 )
{
v12 = rand();
v10 = *(_DWORD *)(v5 + 4);
v11 = (int)((double)v12 * 4.65661288e-10 + ((double)v15 - 3314.0) * 0.25 - 0.5) << 14;
}
}
}
else
{
v10 = *(_DWORD *)(v5 + 4);
v11 = 0;
}
v13 = a2[1];
v14 = a2[2];
a2 += 3;
*(double *)&a4 = ((double)v13 + 0.5) * 0.0000305175781;
*(double *)&a5 = ((double)v14 + 0.5) * 0.0000305175781;
result = uv_encode(v10, a4, a5);
if ( (result & 0x80000000) != 0 )
break;
*(_DWORD *)(v8 + 4 * i++) = result | v11;
if ( i == a3 )
return result;
}
*(_QWORD *)&a4 = 0x3FCAF286BD156C1ALL;
*(_QWORD *)&a5 = 0x3FDE50D794B8199ELL;
result = uv_encode(0, a4, a5);
*(_DWORD *)(v8 + 4 * i) = result | v11;
}
}
return result;
}