#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
float min(float, float);
scalar_t__ sqrt(float);
float GetLowestRoot(float a, float b, float c, float max) {
  float determinant = b * b - a * c;
  if (determinant < 0.0f)
    return 0.0f;
  determinant = (float)sqrt(determinant);
  float root1 = (b + determinant) / a;
  if (root1 <= 0.0f || root1 > max)
    root1 = max + 1.0f;
  float root2 = (b - determinant) / a;
  if (root2 <= 0.0f || root2 > max)
    root2 = max + 1.0f;
  float root = min(root1, root2);
  if (root == max + 1.0f)
    return 0.0f;
  return root;
}


x86 assembly (clang, -O0):
<GetLowestRoot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm3,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    1184 <GetLowestRoot+0x64>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1268 <GetLowestRoot+0x148>
movss  -0x18(%rbp),%xmm0
call   1040 <sqrt@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jae    11c8 <GetLowestRoot+0xa8>
movss  -0x1c(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    11da <GetLowestRoot+0xba>
movss  0xe30(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x20(%rbp),%xmm0
jae    120a <GetLowestRoot+0xea>
movss  -0x20(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    121c <GetLowestRoot+0xfc>
movss  0xdee(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
call   1030 <min@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movss  0xdc3(%rip),%xmm1
addss  -0x14(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    125e <GetLowestRoot+0x13e>
jp     125e <GetLowestRoot+0x13e>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1268 <GetLowestRoot+0x148>
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetLowestRoot>:
movaps %xmm0,%xmm4
mulss  %xmm0,%xmm2
movaps %xmm1,%xmm0
mulss  %xmm1,%xmm0
subss  %xmm2,%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
ja     1204 <GetLowestRoot+0xe4>
sub    $0x48,%rsp
movaps %xmm1,0x10(%rsp)
movaps %xmm3,0x30(%rsp)
movss  %xmm4,0xc(%rsp)
call   1040 <sqrt@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
movaps %xmm1,%xmm0
movaps 0x10(%rsp),%xmm6
addss  %xmm6,%xmm0
movss  0xc(%rsp),%xmm7
divss  %xmm7,%xmm0
movss  0xe83(%rip),%xmm4
movaps 0x30(%rsp),%xmm3
addss  %xmm3,%xmm4
movaps %xmm3,%xmm2
movaps %xmm3,%xmm8
cmpltss %xmm0,%xmm2
movaps %xmm2,%xmm3
andnps %xmm0,%xmm3
andps  %xmm4,%xmm2
movaps %xmm4,%xmm5
movaps %xmm4,0x20(%rsp)
orps   %xmm3,%xmm2
xorps  %xmm3,%xmm3
cmpless %xmm3,%xmm0
movaps %xmm0,%xmm4
andnps %xmm2,%xmm4
andps  %xmm5,%xmm0
orps   %xmm4,%xmm0
movaps %xmm6,%xmm2
subss  %xmm1,%xmm2
divss  %xmm7,%xmm2
movaps %xmm8,%xmm4
cmpltss %xmm2,%xmm4
movaps %xmm4,%xmm1
andnps %xmm2,%xmm1
andps  %xmm5,%xmm4
orps   %xmm1,%xmm4
cmpless %xmm3,%xmm2
movaps %xmm2,%xmm1
andnps %xmm4,%xmm1
andps  %xmm5,%xmm2
orps   %xmm1,%xmm2
movaps %xmm2,%xmm1
call   1030 <min@plt>
movaps 0x20(%rsp),%xmm2
cmpeqss %xmm0,%xmm2
andnps %xmm0,%xmm2
add    $0x48,%rsp
movaps %xmm2,%xmm0
ret

LLVM IR (-O0):
define float @GetLowestRoot(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
%14 = load float, float* %7
%15 = load float, float* %7
%16 = load float, float* %6
%17 = load float, float* %8
%18 = fmul float %16, %17
%19 = fneg float %18
%20 = call float @llvm.fmuladd.f32(float %14, float %15, float %19)
store float %20, float* %10
%21 = load float, float* %10
%22 = fcmp olt float %21, 0.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %4
store float 0.000000e+00, float* %5
br label %68
24: ; preds = %4
%25 = load float, float* %10
%26 = call i64 @sqrt(float %25)
%27 = sitofp i64 %26 to float
store float %27, float* %10
%28 = load float, float* %7
%29 = load float, float* %10
%30 = fadd float %28, %29
%31 = load float, float* %6
%32 = fdiv float %30, %31
store float %32, float* %11
%33 = load float, float* %11
%34 = fcmp ole float %33, 0.000000e+00
br i1 %34, label %39, label %35
35: ; preds = %24
%36 = load float, float* %11
%37 = load float, float* %9
%38 = fcmp ogt float %36, %37
br i1 %38, label %39, label %42
39: ; preds = %35, %24
%40 = load float, float* %9
%41 = fadd float %40, 1.000000e+00
store float %41, float* %11
br label %42
42: ; preds = %39, %35
%43 = load float, float* %7
%44 = load float, float* %10
%45 = fsub float %43, %44
%46 = load float, float* %6
%47 = fdiv float %45, %46
store float %47, float* %12
%48 = load float, float* %12
%49 = fcmp ole float %48, 0.000000e+00
br i1 %49, label %54, label %50
50: ; preds = %42
%51 = load float, float* %12
%52 = load float, float* %9
%53 = fcmp ogt float %51, %52
br i1 %53, label %54, label %57
54: ; preds = %50, %42
%55 = load float, float* %9
%56 = fadd float %55, 1.000000e+00
store float %56, float* %12
br label %57
57: ; preds = %54, %50
%58 = load float, float* %11
%59 = load float, float* %12
%60 = call float @min(float %58, float %59)
store float %60, float* %13
%61 = load float, float* %13
%62 = load float, float* %9
%63 = fadd float %62, 1.000000e+00
%64 = fcmp oeq float %61, %63
br i1 %64, label %65, label %66
65: ; preds = %57
store float 0.000000e+00, float* %5
br label %68
66: ; preds = %57
%67 = load float, float* %13
store float %67, float* %5
br label %68
68: ; preds = %66, %65, %23
%69 = load float, float* %5
ret float %69
}

LLVM IR (-O2):
define float @GetLowestRoot(float %0, float %1, float %2, float %3) {
%5 = fneg float %0
%6 = fmul float %5, %2
%7 = tail call float @llvm.fmuladd.f32(float %1, float %1, float %6)
%8 = fcmp olt float %7, 0.000000e+00
br i1 %8, label %28, label %9
9: ; preds = %4
%10 = tail call i64 @sqrt(float %7)
%11 = sitofp i64 %10 to float
%12 = fadd float %11, %1
%13 = fdiv float %12, %0
%14 = fcmp ole float %13, 0.000000e+00
%15 = fcmp ogt float %13, %3
%16 = or i1 %14, %15
%17 = fadd float %3, 1.000000e+00
%18 = select i1 %16, float %17, float %13
%19 = fsub float %1, %11
%20 = fdiv float %19, %0
%21 = fcmp ole float %20, 0.000000e+00
%22 = fcmp ogt float %20, %3
%23 = or i1 %21, %22
%24 = select i1 %23, float %17, float %20
%25 = tail call float @min(float %18, float %24)
%26 = fcmp oeq float %25, %17
%27 = select i1 %26, float 0.000000e+00, float %25
br label %28
28: ; preds = %4, %9
%29 = phi float [ %27, %9 ], [ 0.000000e+00, %4 ]
ret float %29
}