#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 /*<<< orphan*/ erdl_coeff(double, double, double, double *, double *,
                              double *);
double sqrt(double);
double cosminus(double r, double d, double m1) {
  double a0, a1, a2;
  double det, rtdet;
  double val;
  erdl_coeff(r, d, m1, &a0, &a1, &a2);
  if (a2 == 0.0) {
    if (a1 == 0.0)
      val = 1.0;
    else
      val = -a0 / a1;
  } else {
    det = a1 * a1 - 4.0 * a0 * a2;
    if (det < 0.0)
      det = 0.0;
    rtdet = sqrt(det);
    val = -0.5 * (a1 - rtdet) / a2;
  }
  return (val);
}


x86 assembly (clang, -O0):
<cosminus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <erdl_coeff@plt>
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c4 <cosminus+0xa4>
jp     11c4 <cosminus+0xa4>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1199 <cosminus+0x79>
jp     1199 <cosminus+0x79>
movsd  0xe81(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11bf <cosminus+0x9f>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1249 <cosminus+0x129>
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  0xe2a(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    121a <cosminus+0xfa>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  0xdcd(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cosminus>:
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <erdl_coeff@plt>
movsd  (%rsp),%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
movsd  0x8(%rsp),%xmm1
jne    1162 <cosminus+0x42>
jp     1162 <cosminus+0x42>
ucomisd %xmm2,%xmm1
jne    1193 <cosminus+0x73>
jp     1193 <cosminus+0x73>
movsd  0xeb3(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0x10(%rsp),%xmm3
mulsd  0xe90(%rip),%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
maxsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11aa <cosminus+0x8a>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    11b3 <cosminus+0x93>
movsd  0x10(%rsp),%xmm0
xorpd  0xe7f(%rip),%xmm0
divsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
call   1040 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
mulsd  0xe43(%rip),%xmm0
divsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @cosminus(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%13 = load double, double* %4
%14 = load double, double* %5
%15 = load double, double* %6
%16 = call i32 @erdl_coeff(double %13, double %14, double %15, double* %7, double* %8, double* %9)
%17 = load double, double* %9
%18 = fcmp oeq double %17, 0.000000e+00
br i1 %18, label %19, label %29
19: ; preds = %3
%20 = load double, double* %8
%21 = fcmp oeq double %20, 0.000000e+00
br i1 %21, label %22, label %23
22: ; preds = %19
store double 1.000000e+00, double* %12
br label %28
23: ; preds = %19
%24 = load double, double* %7
%25 = fneg double %24
%26 = load double, double* %8
%27 = fdiv double %25, %26
store double %27, double* %12
br label %28
28: ; preds = %23, %22
br label %50
29: ; preds = %3
%30 = load double, double* %8
%31 = load double, double* %8
%32 = load double, double* %7
%33 = fmul double 4.000000e+00, %32
%34 = load double, double* %9
%35 = fmul double %33, %34
%36 = fneg double %35
%37 = call double @llvm.fmuladd.f64(double %30, double %31, double %36)
store double %37, double* %10
%38 = load double, double* %10
%39 = fcmp olt double %38, 0.000000e+00
br i1 %39, label %40, label %41
40: ; preds = %29
store double 0.000000e+00, double* %10
br label %41
41: ; preds = %40, %29
%42 = load double, double* %10
%43 = call double @sqrt(double %42)
store double %43, double* %11
%44 = load double, double* %8
%45 = load double, double* %11
%46 = fsub double %44, %45
%47 = fmul double -5.000000e-01, %46
%48 = load double, double* %9
%49 = fdiv double %47, %48
store double %49, double* %12
br label %50
50: ; preds = %41, %28
%51 = load double, double* %12
ret double %51
}

LLVM IR (-O2):
define double @cosminus(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = bitcast double* %4 to i8*
%8 = bitcast double* %5 to i8*
%9 = bitcast double* %6 to i8*
%10 = call i32 @erdl_coeff(double %0, double %1, double %2, double* %4, double* %5, double* %6)
%11 = load double, double* %6
%12 = fcmp oeq double %11, 0.000000e+00
%13 = load double, double* %5
br i1 %12, label %14, label %20
14: ; preds = %3
%15 = fcmp oeq double %13, 0.000000e+00
br i1 %15, label %33, label %16
16: ; preds = %14
%17 = load double, double* %4
%18 = fneg double %17
%19 = fdiv double %18, %13
br label %33
20: ; preds = %3
%21 = load double, double* %4
%22 = fmul double %21, -4.000000e+00
%23 = fmul double %11, %22
%24 = call double @llvm.fmuladd.f64(double %13, double %13, double %23)
%25 = fcmp olt double %24, 0.000000e+00
%26 = select i1 %25, double 0.000000e+00, double %24
%27 = call double @sqrt(double %26)
%28 = load double, double* %5
%29 = fsub double %28, %27
%30 = fmul double %29, -5.000000e-01
%31 = load double, double* %6
%32 = fdiv double %30, %31
br label %33
33: ; preds = %14, %16, %20
%34 = phi double [ %19, %16 ], [ %32, %20 ], [ 1.000000e+00, %14 ]
ret double %34
}