#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 */
int solve_degree_1(double const *, double *);
double sqrt(double);
scalar_t__ zero(double *);
int solve_degree_2(const double *c, double *x) {
  if (c[2] == 0)
    return solve_degree_1(c, x);
  double p = c[1] / (2.0 * c[2]);
  double q = c[0] / c[2];
  double D = p * p - q;
  if (zero(&D)) {
    x[0] = x[1] = -p;
    return 1;
  } else if (D < 0)
    return 0;
  else {
    double sqrt_D = sqrt(D);
    x[0] = -sqrt_D - p;
    x[1] = sqrt_D - p;
    return 2;
  }
}


x86 assembly (clang, -O0):
<solve_degree_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1171 <solve_degree_2+0x41>
jp     1171 <solve_degree_2+0x41>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <solve_degree_1@plt>
mov    %eax,-0x4(%rbp)
jmp    1295 <solve_degree_2+0x165>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0xe7a(%rip),%xmm1
mulsd  0x10(%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <zero@plt>
cmp    $0x0,%rax
je     1229 <solve_degree_2+0xf9>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1295 <solve_degree_2+0x165>
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1243 <solve_degree_2+0x113>
movl   $0x0,-0x4(%rbp)
jmp    1295 <solve_degree_2+0x165>
movsd  -0x30(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_degree_2>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
movsd  0x10(%rdi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1156 <solve_degree_2+0x26>
jp     1156 <solve_degree_2+0x26>
mov    %rbx,%rsi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <solve_degree_1@plt>
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm2
divsd  %xmm0,%xmm1
addsd  %xmm0,%xmm0
divsd  %xmm0,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <zero@plt>
test   %rax,%rax
je     11b0 <solve_degree_2+0x80>
movdqa 0x10(%rsp),%xmm0
pxor   0xe60(%rip),%xmm0
pshufd $0x44,%xmm0,%xmm0
movdqu %xmm0,(%rbx)
mov    $0x1,%eax
jmp    11fa <solve_degree_2+0xca>
movsd  0x8(%rsp),%xmm0
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11fa <solve_degree_2+0xca>
ucomisd %xmm1,%xmm0
jb     11ce <solve_degree_2+0x9e>
sqrtsd %xmm0,%xmm0
jmp    11d3 <solve_degree_2+0xa3>
call   1050 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
movapd 0xe1f(%rip),%xmm1
xorpd  %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
unpcklpd %xmm2,%xmm2
subpd  %xmm2,%xmm1
movupd %xmm1,(%rbx)
mov    $0x2,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @solve_degree_2(double* %0, double* %1) {
%3 = alloca double
%4 = getelementptr inbounds double, double* %0, i64 2
%5 = load double, double* %4
%6 = fcmp oeq double %5, 0.000000e+00
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @solve_degree_1(double* %0, double* %1)
br label %38
9: ; preds = %2
%10 = getelementptr inbounds double, double* %0, i64 1
%11 = load double, double* %10
%12 = fmul double %5, 2.000000e+00
%13 = fdiv double %11, %12
%14 = load double, double* %0
%15 = bitcast double* %3 to i8*
%16 = fneg double %14
%17 = fdiv double %16, %5
%18 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %17)
store double %18, double* %3
%19 = call i64 @zero(double* %3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %9
%22 = fneg double %13
%23 = getelementptr inbounds double, double* %1, i64 1
store double %22, double* %23
store double %22, double* %1
br label %36
24: ; preds = %9
%25 = load double, double* %3
%26 = fcmp olt double %25, 0.000000e+00
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = call double @sqrt(double %25)
%29 = fneg double %28
%30 = insertelement <2 x double> poison, double %29, i64 0
%31 = insertelement <2 x double> %30, double %28, i64 1
%32 = insertelement <2 x double> poison, double %13, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = fsub <2 x double> %31, %33
%35 = bitcast double* %1 to <2 x double>*
store <2 x double> %34, <2 x double>* %35
br label %36
36: ; preds = %24, %27, %21
%37 = phi i32 [ 1, %21 ], [ 2, %27 ], [ 0, %24 ]
br label %38
38: ; preds = %36, %7
%39 = phi i32 [ %8, %7 ], [ %37, %36 ]
ret i32 %39
}