//
// randRangeWeighted from 0x6a9f68 to 0x6aa074 (268 bytes)
//
// 1 xrefs:
// > ??> @ 0x8ff38
//
// This function is hookable on this platform (idp: arm, 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 12:50:47 +0000
//
__int64 __fastcall randRangeWeighted(float a1, float a2)
{
int v2; // w1
unsigned int v3; // w19
float v4; // s8
int v5; // w0
float v6; // s9
int v7; // w0
float v8; // s0
float v9; // s1
float v10; // s4
float v11; // s0
__int64 result; // x0
float v13; // s3
int v14; // w0
v2 = 0;
v3 = (int)a1;
v4 = (float)(int)a1;
v5 = (int)a1;
if ( a2 < v4 )
{
v14 = rand();
v9 = a2;
v8 = a1;
if ( a2 < v4 )
return v3;
v6 = 1.0 / 0.0;
v10 = (float)v14 * 4.6566e-10;
}
else
{
do
v2 += v5++;
while ( (float)v5 <= a2 );
v6 = 1.0 / (float)v2;
v7 = rand();
v8 = a1;
v9 = a2;
v10 = (float)v7 * 4.6566e-10;
}
v11 = v9 + v8;
LODWORD(result) = v3;
v13 = (float)((float)(v11 - v4) * v6) + 0.0;
if ( v13 < v10 )
{
while ( 1 )
{
LODWORD(result) = result + 1;
if ( v9 < (float)(int)result )
break;
v13 = v13 + (float)((float)(v11 - (float)(int)result) * v6);
if ( v13 >= v10 )
return (unsigned int)result;
}
return v3;
}
return (unsigned int)result;
}