#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 */
scalar_t__ fabs(double);
double sqrt(double);
double cg_cubic(double a, double fa, double da, double b, double fb,
                double db) {
  double c, d1, d2, delta, t, v, w;
  delta = b - a;
  if (delta == ((double)0))
    return (a);
  v = da + db - 3. * (fb - fa) / delta;
  t = v * v - da * db;
  if (t < ((double)0)) {
    if (fabs(da) < fabs(db))
      c = a - (a - b) * (da / (da - db));
    else if (da != db)
      c = b - (a - b) * (db / (da - db));
    else
      c = -1;
    return (c);
  }
  if (delta > ((double)0))
    w = sqrt(t);
  else
    w = -sqrt(t);
  d1 = da + v - w;
  d2 = db + v + w;
  if ((d1 == ((double)0)) && (d2 == ((double)0)))
    return (-1.);
  if (fabs(d1) >= fabs(d2))
    c = a + delta * da / d1;
  else
    c = b - delta * db / d2;
  return (c);
}


x86 assembly (clang, -O0):
<cg_cubic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117f <cg_cubic+0x5f>
jp     117f <cg_cubic+0x5f>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1414 <cg_cubic+0x2f4>
movsd  -0x20(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
movsd  0xe65(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  -0x58(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x60(%rbp),%xmm0
jbe    12ed <cg_cubic+0x1cd>
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
cmp    %rcx,%rax
jge    1266 <cg_cubic+0x146>
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
subsd  -0x38(%rbp),%xmm3
divsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12de <cg_cubic+0x1be>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    1281 <cg_cubic+0x161>
jp     1281 <cg_cubic+0x161>
jmp    12cc <cg_cubic+0x1ac>
movsd  -0x28(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
subsd  -0x38(%rbp),%xmm3
divsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12d9 <cg_cubic+0x1b9>
movsd  0xd34(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12de <cg_cubic+0x1be>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1414 <cg_cubic+0x2f4>
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1313 <cg_cubic+0x1f3>
movsd  -0x60(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
jmp    1339 <cg_cubic+0x219>
movsd  -0x60(%rbp),%xmm0
call   1040 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13a3 <cg_cubic+0x283>
jp     13a3 <cg_cubic+0x283>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13a3 <cg_cubic+0x283>
jp     13a3 <cg_cubic+0x283>
movsd  0xc6f(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1414 <cg_cubic+0x2f4>
movsd  -0x48(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x80(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
cmp    %rcx,%rax
jl     13ed <cg_cubic+0x2cd>
movsd  -0x10(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
divsd  -0x48(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    140a <cg_cubic+0x2ea>
movsd  -0x28(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
divsd  -0x50(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cg_cubic>:
push   %rbx
sub    $0x40,%rsp
movapd %xmm0,%xmm6
movapd %xmm3,%xmm7
subsd  %xmm0,%xmm7
xorpd  %xmm8,%xmm8
ucomisd %xmm8,%xmm7
jne    1149 <cg_cubic+0x29>
jp     1149 <cg_cubic+0x29>
movapd %xmm6,%xmm0
add    $0x40,%rsp
pop    %rbx
ret
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm4
mulsd  0xea7(%rip),%xmm4
addsd  %xmm5,%xmm0
divsd  %xmm7,%xmm4
addsd  %xmm0,%xmm4
movapd %xmm2,%xmm1
mulsd  %xmm5,%xmm1
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
subsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm8
movsd  %xmm6,0x30(%rsp)
movsd  %xmm3,0x28(%rsp)
movsd  %xmm5,0x8(%rsp)
movsd  %xmm2,0x18(%rsp)
jbe    11e5 <cg_cubic+0xc5>
movapd %xmm2,%xmm0
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jge    11fd <cg_cubic+0xdd>
movsd  0x30(%rsp),%xmm0
movapd %xmm0,%xmm2
subsd  0x28(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movapd %xmm3,%xmm1
subsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
subsd  %xmm3,%xmm0
jmp    1143 <cg_cubic+0x23>
xorpd  %xmm8,%xmm8
ucomisd %xmm8,%xmm0
movsd  %xmm7,0x20(%rsp)
jb     123a <cg_cubic+0x11a>
sqrtsd %xmm0,%xmm0
jmp    1262 <cg_cubic+0x142>
movsd  0x18(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
ucomisd %xmm2,%xmm3
movsd  0x30(%rsp),%xmm1
movsd  0x28(%rsp),%xmm0
jne    1221 <cg_cubic+0x101>
jnp    12ac <cg_cubic+0x18c>
subsd  %xmm0,%xmm1
subsd  %xmm2,%xmm3
divsd  %xmm3,%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
jmp    1143 <cg_cubic+0x23>
movsd  %xmm4,0x10(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm8,%xmm8
movsd  0x10(%rsp),%xmm4
movsd  0x20(%rsp),%xmm7
movsd  0x18(%rsp),%xmm2
movsd  0x8(%rsp),%xmm5
movapd 0xda6(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm3,%xmm3
cmpltsd %xmm7,%xmm3
andpd  %xmm3,%xmm0
andnpd %xmm1,%xmm3
orpd   %xmm0,%xmm3
movapd %xmm4,%xmm0
addsd  %xmm2,%xmm0
subsd  %xmm3,%xmm0
addsd  %xmm5,%xmm4
addsd  %xmm3,%xmm4
ucomisd %xmm8,%xmm0
jne    12b9 <cg_cubic+0x199>
jp     12b9 <cg_cubic+0x199>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm4
jne    12b9 <cg_cubic+0x199>
jp     12b9 <cg_cubic+0x199>
movsd  0xd54(%rip),%xmm6
jmp    113f <cg_cubic+0x1f>
movsd  %xmm4,0x10(%rsp)
movsd  %xmm0,0x38(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x10(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jge    12fe <cg_cubic+0x1de>
movsd  0x20(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  0x28(%rsp),%xmm6
subsd  %xmm0,%xmm6
jmp    113f <cg_cubic+0x1f>
movsd  0x20(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
divsd  0x38(%rsp),%xmm0
movsd  0x30(%rsp),%xmm6
addsd  %xmm0,%xmm6
jmp    113f <cg_cubic+0x1f>

LLVM IR (-O0):
define double @cg_cubic(double %0, double %1, double %2, double %3, double %4, double %5) {
%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
%18 = alloca double
%19 = alloca double
%20 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
%21 = load double, double* %11
%22 = load double, double* %8
%23 = fsub double %21, %22
store double %23, double* %17
%24 = load double, double* %17
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %6
%27 = load double, double* %8
store double %27, double* %7
br label %137
28: ; preds = %6
%29 = load double, double* %10
%30 = load double, double* %13
%31 = fadd double %29, %30
%32 = load double, double* %12
%33 = load double, double* %9
%34 = fsub double %32, %33
%35 = fmul double 3.000000e+00, %34
%36 = load double, double* %17
%37 = fdiv double %35, %36
%38 = fsub double %31, %37
store double %38, double* %19
%39 = load double, double* %19
%40 = load double, double* %19
%41 = load double, double* %10
%42 = load double, double* %13
%43 = fmul double %41, %42
%44 = fneg double %43
%45 = call double @llvm.fmuladd.f64(double %39, double %40, double %44)
store double %45, double* %18
%46 = load double, double* %18
%47 = fcmp olt double %46, 0.000000e+00
br i1 %47, label %48, label %86
48: ; preds = %28
%49 = load double, double* %10
%50 = call i64 @fabs(double %49)
%51 = load double, double* %13
%52 = call i64 @fabs(double %51)
%53 = icmp slt i64 %50, %52
br i1 %53, label %54, label %66
54: ; preds = %48
%55 = load double, double* %8
%56 = load double, double* %8
%57 = load double, double* %11
%58 = fsub double %56, %57
%59 = load double, double* %10
%60 = load double, double* %10
%61 = load double, double* %13
%62 = fsub double %60, %61
%63 = fdiv double %59, %62
%64 = fneg double %58
%65 = call double @llvm.fmuladd.f64(double %64, double %63, double %55)
store double %65, double* %14
br label %84
66: ; preds = %48
%67 = load double, double* %10
%68 = load double, double* %13
%69 = fcmp une double %67, %68
br i1 %69, label %70, label %82
70: ; preds = %66
%71 = load double, double* %11
%72 = load double, double* %8
%73 = load double, double* %11
%74 = fsub double %72, %73
%75 = load double, double* %13
%76 = load double, double* %10
%77 = load double, double* %13
%78 = fsub double %76, %77
%79 = fdiv double %75, %78
%80 = fneg double %74
%81 = call double @llvm.fmuladd.f64(double %80, double %79, double %71)
store double %81, double* %14
br label %83
82: ; preds = %66
store double -1.000000e+00, double* %14
br label %83
83: ; preds = %82, %70
br label %84
84: ; preds = %83, %54
%85 = load double, double* %14
store double %85, double* %7
br label %137
86: ; preds = %28
%87 = load double, double* %17
%88 = fcmp ogt double %87, 0.000000e+00
br i1 %88, label %89, label %92
89: ; preds = %86
%90 = load double, double* %18
%91 = call double @sqrt(double %90)
store double %91, double* %20
br label %96
92: ; preds = %86
%93 = load double, double* %18
%94 = call double @sqrt(double %93)
%95 = fneg double %94
store double %95, double* %20
br label %96
96: ; preds = %92, %89
%97 = load double, double* %10
%98 = load double, double* %19
%99 = fadd double %97, %98
%100 = load double, double* %20
%101 = fsub double %99, %100
store double %101, double* %15
%102 = load double, double* %13
%103 = load double, double* %19
%104 = fadd double %102, %103
%105 = load double, double* %20
%106 = fadd double %104, %105
store double %106, double* %16
%107 = load double, double* %15
%108 = fcmp oeq double %107, 0.000000e+00
br i1 %108, label %109, label %113
109: ; preds = %96
%110 = load double, double* %16
%111 = fcmp oeq double %110, 0.000000e+00
br i1 %111, label %112, label %113
112: ; preds = %109
store double -1.000000e+00, double* %7
br label %137
113: ; preds = %109, %96
%114 = load double, double* %15
%115 = call i64 @fabs(double %114)
%116 = load double, double* %16
%117 = call i64 @fabs(double %116)
%118 = icmp sge i64 %115, %117
br i1 %118, label %119, label %127
119: ; preds = %113
%120 = load double, double* %8
%121 = load double, double* %17
%122 = load double, double* %10
%123 = fmul double %121, %122
%124 = load double, double* %15
%125 = fdiv double %123, %124
%126 = fadd double %120, %125
store double %126, double* %14
br label %135
127: ; preds = %113
%128 = load double, double* %11
%129 = load double, double* %17
%130 = load double, double* %13
%131 = fmul double %129, %130
%132 = load double, double* %16
%133 = fdiv double %131, %132
%134 = fsub double %128, %133
store double %134, double* %14
br label %135
135: ; preds = %127, %119
%136 = load double, double* %14
store double %136, double* %7
br label %137
137: ; preds = %135, %112, %84, %26
%138 = load double, double* %7
ret double %138
}

LLVM IR (-O2):
define double @cg_cubic(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = fsub double %3, %0
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %61, label %9
9: ; preds = %6
%10 = fadd double %2, %5
%11 = fsub double %4, %1
%12 = fmul double %11, 3.000000e+00
%13 = fdiv double %12, %7
%14 = fsub double %10, %13
%15 = fneg double %2
%16 = fmul double %15, %5
%17 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %16)
%18 = fcmp olt double %17, 0.000000e+00
br i1 %18, label %19, label %37
19: ; preds = %9
%20 = tail call i64 @fabs(double %2)
%21 = tail call i64 @fabs(double %5)
%22 = icmp slt i64 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = fsub double %0, %3
%25 = fsub double %2, %5
%26 = fdiv double %2, %25
%27 = fneg double %24
%28 = tail call double @llvm.fmuladd.f64(double %27, double %26, double %0)
br label %61
29: ; preds = %19
%30 = fcmp une double %2, %5
br i1 %30, label %31, label %61
31: ; preds = %29
%32 = fsub double %0, %3
%33 = fsub double %2, %5
%34 = fdiv double %5, %33
%35 = fneg double %32
%36 = tail call double @llvm.fmuladd.f64(double %35, double %34, double %3)
br label %61
37: ; preds = %9
%38 = fcmp ogt double %7, 0.000000e+00
%39 = tail call double @sqrt(double %17)
%40 = fneg double %39
%41 = select i1 %38, double %39, double %40
%42 = fadd double %14, %2
%43 = fsub double %42, %41
%44 = fadd double %14, %5
%45 = fadd double %44, %41
%46 = fcmp oeq double %43, 0.000000e+00
%47 = fcmp oeq double %45, 0.000000e+00
%48 = and i1 %46, %47
br i1 %48, label %61, label %49
49: ; preds = %37
%50 = tail call i64 @fabs(double %43)
%51 = tail call i64 @fabs(double %45)
%52 = icmp slt i64 %50, %51
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = fmul double %7, %2
%55 = fdiv double %54, %43
%56 = fadd double %55, %0
br label %61
57: ; preds = %49
%58 = fmul double %7, %5
%59 = fdiv double %58, %45
%60 = fsub double %3, %59
br label %61
61: ; preds = %53, %57, %37, %23, %31, %29, %6
%62 = phi double [ %0, %6 ], [ %28, %23 ], [ %36, %31 ], [ -1.000000e+00, %29 ], [ -1.000000e+00, %37 ], [ %56, %53 ], [ %60, %57 ]
ret double %62
}