//
// sub_10001AE40 from 0x10001ae40 to 0x10001af1c (220 bytes)
//
// 1 xrefs:
// > sub_10001ABFC @ 0x10001ac74
//
// 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
//
unsigned __int64 __fastcall sub_10001AE40(unsigned __int64 result, size_t __n)
{
unsigned __int64 v2; // x19
unsigned __int64 v3; // x20
int8x8_t v4; // x21
uint8x8_t v5; // d0
__int64 v6; // x8
v2 = result;
if ( __n == 1 )
{
v3 = 2;
}
else
{
v3 = __n;
if ( (__n & (__n - 1)) != 0 )
{
result = std::__next_prime(__n);
v3 = result;
}
}
v4 = *(int8x8_t *)(v2 + 8);
if ( v3 > *(_QWORD *)&v4 )
return sub_10001AF1C(v2, v3);
if ( v3 < *(_QWORD *)&v4 )
{
result = vcvtps_u32_f32((float)*(unsigned __int64 *)(v2 + 24) / *(float *)(v2 + 32));
if ( *(_QWORD *)&v4 < 3u || (v5 = (uint8x8_t)vcnt_s8(v4), v5.i16[0] = vaddlv_u8(v5), v5.u32[0] > 1uLL) )
{
result = std::__next_prime(result);
}
else
{
v6 = 1LL << -(char)__clz(result - 1);
if ( result >= 2 )
result = v6;
}
if ( v3 <= result )
v3 = result;
if ( v3 < *(_QWORD *)&v4 )
return sub_10001AF1C(v2, v3);
}
return result;
}