//
// randRangeWeighted from 0x2f0a58 to 0x2f0ae8 (144 bytes)
//
// 0 xrefs:
//
// 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
//
int __fastcall randRangeWeighted(float a1, float a2)
{
int v2; // r3
int v5; // r2
float v6; // s17
float v7; // s15
unsigned int v8; // s12
int result; // r0
float v10; // s12
int v11; // [sp+4h] [bp-8h]
v2 = 0;
v5 = (int)a1;
v11 = (int)a1;
while ( (float)v5 <= a2 )
v2 += v5++;
v6 = 1.0 / (float)v2;
v7 = 0.0;
v8 = rand();
result = v11;
v10 = vcvts_n_f32_s32(v8, 0x1Fu);
while ( (float)result <= a2 )
{
v7 = v7 + (float)((float)((float)(a2 + a1) - (float)result) * v6);
if ( v10 <= v7 )
return result;
++result;
}
return v11;
}