#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 */
double fabs(double);
double sqrt(double);
int gsl_poly_solve_quadratic(double a, double b, double c, double *x0,
                             double *x1) {
  double disc = b * b - 4 * a * c;
  if (a == 0) {
    if (b == 0) {
      return 0;
    } else {
      *x0 = -c / b;
      return 1;
    };
  }
  if (disc > 0) {
    if (b == 0) {
      double r = fabs(0.5 * sqrt(disc) / a);
      *x0 = -r;
      *x1 = r;
    } else {
      double sgnb = (b > 0 ? 1 : -1);
      double temp = -0.5 * (b + sgnb * sqrt(disc));
      double r1 = temp / a;
      double r2 = c / temp;
      if (r1 < r2) {
        *x0 = r1;
        *x1 = r2;
      } else {
        *x0 = r2;
        *x1 = r1;
      }
    }
    return 2;
  } else if (disc == 0) {
    *x0 = -0.5 * b / a;
    *x1 = -0.5 * b / a;
    return 2;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<gsl_poly_solve_quadratic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xebf(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11e0 <gsl_poly_solve_quadratic+0xd0>
jp     11e0 <gsl_poly_solve_quadratic+0xd0>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ab <gsl_poly_solve_quadratic+0x9b>
jp     11ab <gsl_poly_solve_quadratic+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    13af <gsl_poly_solve_quadratic+0x29f>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    13af <gsl_poly_solve_quadratic+0x29f>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1350 <gsl_poly_solve_quadratic+0x240>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    126e <gsl_poly_solve_quadratic+0x15e>
jp     126e <gsl_poly_solve_quadratic+0x15e>
movsd  -0x38(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xdf1(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movaps 0xdf1(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1344 <gsl_poly_solve_quadratic+0x234>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd3d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1325 <gsl_poly_solve_quadratic+0x215>
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    133f <gsl_poly_solve_quadratic+0x22f>
movsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1344 <gsl_poly_solve_quadratic+0x234>
movl   $0x2,-0x4(%rbp)
jmp    13af <gsl_poly_solve_quadratic+0x29f>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13a8 <gsl_poly_solve_quadratic+0x298>
jp     13a8 <gsl_poly_solve_quadratic+0x298>
movsd  0xc98(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xc7e(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    13af <gsl_poly_solve_quadratic+0x29f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsl_poly_solve_quadratic>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jne    114e <gsl_poly_solve_quadratic+0x3e>
jp     114e <gsl_poly_solve_quadratic+0x3e>
xor    %eax,%eax
ucomisd %xmm4,%xmm1
jne    1134 <gsl_poly_solve_quadratic+0x24>
jnp    1277 <gsl_poly_solve_quadratic+0x167>
xorpd  0xf04(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,(%rbx)
mov    $0x1,%eax
jmp    1277 <gsl_poly_solve_quadratic+0x167>
mov    %rsi,%r14
movapd %xmm0,%xmm3
movsd  0xea3(%rip),%xmm5
mulsd  %xmm0,%xmm5
mulsd  %xmm2,%xmm5
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm5,%xmm0
ucomisd %xmm4,%xmm0
jbe    118f <gsl_poly_solve_quadratic+0x7f>
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm1
jne    11b0 <gsl_poly_solve_quadratic+0xa0>
jp     11b0 <gsl_poly_solve_quadratic+0xa0>
ucomisd %xmm4,%xmm0
jb     11d5 <gsl_poly_solve_quadratic+0xc5>
sqrtsd %xmm0,%xmm0
jmp    11e4 <gsl_poly_solve_quadratic+0xd4>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    11ce <gsl_poly_solve_quadratic+0xbe>
jp     11ce <gsl_poly_solve_quadratic+0xbe>
mulsd  0xe65(%rip),%xmm1
divsd  %xmm3,%xmm1
movsd  %xmm1,(%rbx)
jmp    126d <gsl_poly_solve_quadratic+0x15d>
seta   %al
movzbl %al,%eax
lea    0xe63(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm5
ucomisd %xmm4,%xmm0
jb     1206 <gsl_poly_solve_quadratic+0xf6>
sqrtsd %xmm0,%xmm0
jmp    1239 <gsl_poly_solve_quadratic+0x129>
xor    %eax,%eax
jmp    1277 <gsl_poly_solve_quadratic+0x167>
movapd %xmm3,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm3
mulsd  0xe24(%rip),%xmm0
divsd  %xmm3,%xmm0
movapd 0xe38(%rip),%xmm1
andpd  %xmm0,%xmm1
orpd   0xe3c(%rip),%xmm0
jmp    1269 <gsl_poly_solve_quadratic+0x159>
movapd %xmm3,(%rsp)
movsd  %xmm1,0x18(%rsp)
movapd %xmm2,0x30(%rsp)
movapd %xmm5,0x20(%rsp)
call   1030 <sqrt@plt>
movapd 0x20(%rsp),%xmm5
movapd 0x30(%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
movapd (%rsp),%xmm3
mulsd  %xmm0,%xmm5
addsd  %xmm1,%xmm5
mulsd  0xdbf(%rip),%xmm5
unpcklpd %xmm5,%xmm3
unpcklpd %xmm2,%xmm5
divpd  %xmm3,%xmm5
movapd %xmm5,%xmm1
unpckhpd %xmm5,%xmm1
movapd %xmm5,%xmm0
minsd  %xmm1,%xmm0
maxsd  %xmm5,%xmm1
movsd  %xmm0,(%rbx)
movsd  %xmm1,(%r14)
mov    $0x2,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @gsl_poly_solve_quadratic(double %0, double %1, double %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
%18 = load double, double* %8
%19 = load double, double* %8
%20 = load double, double* %7
%21 = fmul double 4.000000e+00, %20
%22 = load double, double* %9
%23 = fmul double %21, %22
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double %18, double %19, double %24)
store double %25, double* %12
%26 = load double, double* %7
%27 = fcmp oeq double %26, 0.000000e+00
br i1 %27, label %28, label %38
28: ; preds = %5
%29 = load double, double* %8
%30 = fcmp oeq double %29, 0.000000e+00
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 0, i32* %6
br label %104
32: ; preds = %28
%33 = load double, double* %9
%34 = fneg double %33
%35 = load double, double* %8
%36 = fdiv double %34, %35
%37 = load double*, double** %10
store double %36, double* %37
store i32 1, i32* %6
br label %104
38: ; preds = %5
%39 = load double, double* %12
%40 = fcmp ogt double %39, 0.000000e+00
br i1 %40, label %41, label %89
41: ; preds = %38
%42 = load double, double* %8
%43 = fcmp oeq double %42, 0.000000e+00
br i1 %43, label %44, label %56
44: ; preds = %41
%45 = load double, double* %12
%46 = call double @sqrt(double %45)
%47 = fmul double 5.000000e-01, %46
%48 = load double, double* %7
%49 = fdiv double %47, %48
%50 = call double @llvm.fabs.f64(double %49)
store double %50, double* %13
%51 = load double, double* %13
%52 = fneg double %51
%53 = load double*, double** %10
store double %52, double* %53
%54 = load double, double* %13
%55 = load double*, double** %11
store double %54, double* %55
br label %88
56: ; preds = %41
%57 = load double, double* %8
%58 = fcmp ogt double %57, 0.000000e+00
%59 = zext i1 %58 to i64
%60 = select i1 %58, i32 1, i32 -1
%61 = sitofp i32 %60 to double
store double %61, double* %14
%62 = load double, double* %8
%63 = load double, double* %14
%64 = load double, double* %12
%65 = call double @sqrt(double %64)
%66 = call double @llvm.fmuladd.f64(double %63, double %65, double %62)
%67 = fmul double -5.000000e-01, %66
store double %67, double* %15
%68 = load double, double* %15
%69 = load double, double* %7
%70 = fdiv double %68, %69
store double %70, double* %16
%71 = load double, double* %9
%72 = load double, double* %15
%73 = fdiv double %71, %72
store double %73, double* %17
%74 = load double, double* %16
%75 = load double, double* %17
%76 = fcmp olt double %74, %75
br i1 %76, label %77, label %82
77: ; preds = %56
%78 = load double, double* %16
%79 = load double*, double** %10
store double %78, double* %79
%80 = load double, double* %17
%81 = load double*, double** %11
store double %80, double* %81
br label %87
82: ; preds = %56
%83 = load double, double* %17
%84 = load double*, double** %10
store double %83, double* %84
%85 = load double, double* %16
%86 = load double*, double** %11
store double %85, double* %86
br label %87
87: ; preds = %82, %77
br label %88
88: ; preds = %87, %44
store i32 2, i32* %6
br label %104
89: ; preds = %38
%90 = load double, double* %12
%91 = fcmp oeq double %90, 0.000000e+00
br i1 %91, label %92, label %103
92: ; preds = %89
%93 = load double, double* %8
%94 = fmul double -5.000000e-01, %93
%95 = load double, double* %7
%96 = fdiv double %94, %95
%97 = load double*, double** %10
store double %96, double* %97
%98 = load double, double* %8
%99 = fmul double -5.000000e-01, %98
%100 = load double, double* %7
%101 = fdiv double %99, %100
%102 = load double*, double** %11
store double %101, double* %102
store i32 2, i32* %6
br label %104
103: ; preds = %89
store i32 0, i32* %6
br label %104
104: ; preds = %103, %92, %88, %32, %31
%105 = load i32, i32* %6
ret i32 %105
}

LLVM IR (-O2):
define i32 @gsl_poly_solve_quadratic(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = fmul double %0, -4.000000e+00
%7 = fmul double %6, %2
%8 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %7)
%9 = fcmp oeq double %0, 0.000000e+00
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = fcmp oeq double %1, 0.000000e+00
br i1 %11, label %49, label %12
12: ; preds = %10
%13 = fneg double %2
%14 = fdiv double %13, %1
store double %14, double* %3
br label %49
15: ; preds = %5
%16 = fcmp ogt double %8, 0.000000e+00
br i1 %16, label %17, label %44
17: ; preds = %15
%18 = fcmp oeq double %1, 0.000000e+00
br i1 %18, label %19, label %25
19: ; preds = %17
%20 = tail call double @sqrt(double %8)
%21 = fmul double %20, 5.000000e-01
%22 = fdiv double %21, %0
%23 = tail call double @llvm.fabs.f64(double %22)
%24 = fneg double %23
br label %41
25: ; preds = %17
%26 = fcmp ogt double %1, 0.000000e+00
%27 = select i1 %26, double 1.000000e+00, double -1.000000e+00
%28 = tail call double @sqrt(double %8)
%29 = tail call double @llvm.fmuladd.f64(double %27, double %28, double %1)
%30 = fmul double %29, -5.000000e-01
%31 = insertelement <2 x double> poison, double %2, i64 1
%32 = insertelement <2 x double> %31, double %30, i64 0
%33 = insertelement <2 x double> poison, double %0, i64 0
%34 = insertelement <2 x double> %33, double %30, i64 1
%35 = fdiv <2 x double> %32, %34
%36 = extractelement <2 x double> %35, i64 0
%37 = extractelement <2 x double> %35, i64 1
%38 = fcmp olt double %36, %37
%39 = select i1 %38, double %36, double %37
%40 = select i1 %38, double %37, double %36
br label %41
41: ; preds = %25, %19
%42 = phi double [ %39, %25 ], [ %24, %19 ]
%43 = phi double [ %40, %25 ], [ %23, %19 ]
store double %42, double* %3
store double %43, double* %4
br label %49
44: ; preds = %15
%45 = fcmp oeq double %8, 0.000000e+00
br i1 %45, label %46, label %49
46: ; preds = %44
%47 = fmul double %1, -5.000000e-01
%48 = fdiv double %47, %0
store double %48, double* %3
store double %48, double* %4
br label %49
49: ; preds = %44, %10, %46, %41, %12
%50 = phi i32 [ 1, %12 ], [ 2, %41 ], [ 2, %46 ], [ 0, %10 ], [ 0, %44 ]
ret i32 %50
}