//
// internal::solve_quadratic from 0x5955e8 to 0x595758 (368 bytes)
//
// 1 xrefs:
// > internal::solve_cubic @ 0x596362
//
// 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
//
internal *__fastcall internal::solve_quadratic(internal *this, double a2, double a3, double a4, int a5)
{
double v8; // d9
double v9; // d11
double v10; // d7
double *v11; // r1
double *v12; // r0
double *i; // r2
double *v14; // r7
double *v15; // r7
double v16; // d5
int v17; // r3
int v18; // r2
double *v20; // [sp+8h] [bp-14h] BYREF
double *v21; // [sp+Ch] [bp-10h]
int v22; // [sp+10h] [bp-Ch]
if ( a4 == 0.0 )
{
internal::solve_linear(this, a2, a3);
}
else
{
v20 = nullptr;
v21 = nullptr;
v22 = 0;
v8 = a3 * 0.5 / a4;
v9 = v8 * v8 - a2 / a4;
v10 = fabs(v9);
if ( v10 > (fabs(a2 / a4) * 3.0 + v8 * v8 * 6.0 + v10) * (COERCE_DOUBLE(internal::get_eps(this)) * 0.5) )
{
if ( v9 >= 0.0 )
{
std::vector::resize((const void **)&v20, 2u);
v14 = v20;
*v14 = -v8 - sqrt(v9);
v15 = v20;
v15[1] = sqrt(v9) - v8;
}
}
else
{
std::vector::resize((const void **)&v20, 1u);
*v20 = -v8;
}
v11 = v20;
v12 = v21;
for ( i = v20; ; ++i )
{
v17 = 0;
if ( i == v12 )
break;
while ( v17 < a5 )
{
v16 = a3 + (a4 + a4) * *i;
if ( fabs(v16) > 0.00000001 )
*i = *i - (a2 + (a3 + a4 * *i) * *i) / v16;
++v17;
}
}
*((_DWORD *)this + 1) = i;
v18 = v22;
*(_DWORD *)this = v11;
v20 = nullptr;
*((_DWORD *)this + 2) = v18;
v21 = nullptr;
v22 = 0;
std::_Vector_base::~_Vector_base((void **)&v20);
}
return this;
}