#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 sqrt(float);
int solve_quadratic_bernstein(float a, float b, float c, float t[2]) {
  if (b * b < a * c)
    return 0;
  float divisor = a - 2 * b + c;
  if (divisor == 0) {
    t[0] = a / (a - c);
    return 1;
  }
  float center = a - b;
  float det = sqrt(b * b - a * c);
  t[0] = (center + det) / divisor;
  t[1] = (center - det) / divisor;
  return 2;
}


x86 assembly (clang, -O0):
<solve_quadratic_bernstein>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movss  -0xc(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1154 <solve_quadratic_bernstein+0x44>
movl   $0x0,-0x4(%rbp)
jmp    1226 <solve_quadratic_bernstein+0x116>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11ae <solve_quadratic_bernstein+0x9e>
jp     11ae <solve_quadratic_bernstein+0x9e>
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1226 <solve_quadratic_bernstein+0x116>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x20(%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
call   1030 <sqrt@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
divss  -0x1c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x20(%rbp),%xmm0
subss  -0x24(%rbp),%xmm0
divss  -0x1c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_quadratic_bernstein>:
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,%xmm5
movaps %xmm1,%xmm0
mulss  %xmm1,%xmm0
movaps %xmm5,%xmm3
mulss  %xmm2,%xmm3
xor    %eax,%eax
ucomiss %xmm0,%xmm3
ja     11b7 <solve_quadratic_bernstein+0xa7>
mov    %rdi,%rbx
movaps %xmm1,%xmm4
addss  %xmm1,%xmm4
movaps %xmm5,%xmm6
subss  %xmm4,%xmm6
addss  %xmm2,%xmm6
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm6
jne    1166 <solve_quadratic_bernstein+0x56>
jp     1166 <solve_quadratic_bernstein+0x56>
movaps %xmm5,%xmm0
subss  %xmm2,%xmm0
divss  %xmm0,%xmm5
movss  %xmm5,(%rbx)
mov    $0x1,%eax
jmp    11b7 <solve_quadratic_bernstein+0xa7>
subss  %xmm1,%xmm5
subss  %xmm3,%xmm0
ucomiss %xmm4,%xmm0
jb     1179 <solve_quadratic_bernstein+0x69>
sqrtss %xmm0,%xmm0
jmp    1196 <solve_quadratic_bernstein+0x86>
movss  %xmm5,0xc(%rsp)
movss  %xmm6,0x8(%rsp)
call   1030 <sqrt@plt>
movss  0x8(%rsp),%xmm6
movss  0xc(%rsp),%xmm5
movaps %xmm5,%xmm1
addss  %xmm0,%xmm1
divss  %xmm6,%xmm1
movss  %xmm1,(%rbx)
subss  %xmm0,%xmm5
divss  %xmm6,%xmm5
movss  %xmm5,0x4(%rbx)
mov    $0x2,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @solve_quadratic_bernstein(float %0, float %1, float %2, float* nocapture writeonly %3) {
%5 = fmul float %1, %1
%6 = fmul float %0, %2
%7 = fcmp olt float %5, %6
br i1 %7, label %25, label %8
8: ; preds = %4
%9 = tail call float @llvm.fmuladd.f32(float %1, float -2.000000e+00, float %0)
%10 = fadd float %9, %2
%11 = fcmp oeq float %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = fsub float %0, %2
%14 = fdiv float %0, %13
store float %14, float* %3
br label %25
15: ; preds = %8
%16 = fsub float %0, %1
%17 = fneg float %6
%18 = tail call float @llvm.fmuladd.f32(float %1, float %1, float %17)
%19 = tail call float @sqrt(float %18)
%20 = fadd float %16, %19
%21 = fdiv float %20, %10
store float %21, float* %3
%22 = fsub float %16, %19
%23 = fdiv float %22, %10
%24 = getelementptr inbounds float, float* %3, i64 1
store float %23, float* %24
br label %25
25: ; preds = %12, %15, %4
%26 = phi i32 [ 0, %4 ], [ 1, %12 ], [ 2, %15 ]
ret i32 %26
}