#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 const copysign(int /*<<< orphan*/, double const);
int /*<<< orphan*/ sqrt(double);
int geom_quadraticd(const double a, const double b, const double c,
                    double root[2]) {
  if (NULL == root) {
    return -4;
  }
  if (0 == a) {
    if (0 == b) {
      return 0;
    } else {
      root[0] = -0.5 * c / b;
    }
  }
  double disc = b * b - a * c;
  if (0 > disc) {
    return 0;
  } else if (0 == disc) {
    root[0] = b / a;
    return 1;
  } else {
    double z = -b - copysign(sqrt(disc), b);
    root[0] = z / a;
    root[1] = c / z;
    return 2;
  }
}


x86 assembly (clang, -O0):
<geom_quadraticd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    1153 <geom_quadraticd+0x33>
movl   $0xfffffffc,-0x4(%rbp)
jmp    129e <geom_quadraticd+0x17e>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    11a6 <geom_quadraticd+0x86>
jp     11a6 <geom_quadraticd+0x86>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1187 <geom_quadraticd+0x67>
jp     1187 <geom_quadraticd+0x67>
movl   $0x0,-0x4(%rbp)
jmp    129e <geom_quadraticd+0x17e>
movsd  0xe71(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11a6 <geom_quadraticd+0x86>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -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,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11f8 <geom_quadraticd+0xd8>
movl   $0x0,-0x4(%rbp)
jmp    129e <geom_quadraticd+0x17e>
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jne    122a <geom_quadraticd+0x10a>
jp     122a <geom_quadraticd+0x10a>
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    129e <geom_quadraticd+0x17e>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
mov    %eax,%edi
movsd  -0x18(%rbp),%xmm0
call   1030 <copysign@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_quadraticd>:
push   %rbx
sub    $0x40,%rsp
test   %rdi,%rdi
je     1192 <geom_quadraticd+0x72>
mov    %rdi,%rbx
movapd %xmm0,%xmm3
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm0
jne    115b <geom_quadraticd+0x3b>
jp     115b <geom_quadraticd+0x3b>
xor    %eax,%eax
ucomisd %xmm5,%xmm1
jne    1147 <geom_quadraticd+0x27>
jnp    1197 <geom_quadraticd+0x77>
movsd  0xeb1(%rip),%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx)
movapd %xmm3,%xmm4
mulsd  %xmm2,%xmm4
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
subsd  %xmm4,%xmm0
xor    %eax,%eax
ucomisd %xmm0,%xmm5
ja     1197 <geom_quadraticd+0x77>
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jne    119d <geom_quadraticd+0x7d>
jp     119d <geom_quadraticd+0x7d>
divsd  %xmm3,%xmm1
movsd  %xmm1,(%rbx)
mov    $0x1,%eax
jmp    1197 <geom_quadraticd+0x77>
mov    $0xfffffffc,%eax
add    $0x40,%rsp
pop    %rbx
ret
movapd 0xe6b(%rip),%xmm4
xorpd  %xmm1,%xmm4
movapd %xmm4,0x10(%rsp)
movapd %xmm3,0x20(%rsp)
movapd %xmm2,0x30(%rsp)
movapd %xmm1,(%rsp)
call   1040 <sqrt@plt>
mov    %eax,%edi
movapd (%rsp),%xmm0
call   1030 <copysign@plt>
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd 0x20(%rsp),%xmm0
unpcklpd %xmm1,%xmm0
unpcklpd 0x30(%rsp),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,(%rbx)
mov    $0x2,%eax
jmp    1197 <geom_quadraticd+0x77>

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

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