#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*/ error2(int, char *);
double chebev(double a, double b, double c[], int m, double x) {
  double d = 0.0, dd = 0.0, sv, y, y2;
  int j;
  if ((x - a) * (x - b) > 0.0)
    error2(93, "x not in range in routine chebev");
  y2 = 2.0 * (y = (2.0 * x - a - b) / (b - a));
  for (j = m - 1; j >= 1; j--) {
    sv = d;
    d = y2 * d - dd + c[j];
    dd = sv;
  }
  return y * d - dd + 0.5 * c[0];
}


x86 assembly (clang, -O0):
<chebev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movsd  %xmm2,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1174 <chebev+0x64>
mov    $0x5d,%edi
lea    0xea1(%rip),%rsi
call   1030 <error2@plt>
movsd  -0x28(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x48(%rbp)
movsd  0xe43(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x1,-0x54(%rbp)
jl     123b <chebev+0x12b>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
jmp    11cf <chebev+0xbf>
movsd  -0x48(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xd8f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chebev>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
movapd %xmm2,%xmm4
subsd  %xmm0,%xmm4
movapd %xmm2,%xmm3
subsd  %xmm1,%xmm3
mulsd  %xmm4,%xmm3
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm3
jbe    1170 <chebev+0x60>
lea    0xec8(%rip),%rsi
mov    $0x5d,%edi
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
call   1030 <error2@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
xorpd  %xmm4,%xmm4
movsd  0x10(%rsp),%xmm2
addsd  %xmm2,%xmm2
subsd  %xmm0,%xmm2
subsd  %xmm1,%xmm2
subsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
xorpd  %xmm1,%xmm1
cmp    $0x2,%ebp
jl     11d6 <chebev+0xc6>
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
mov    %ebp,%eax
add    $0x1,%rax
xorpd  %xmm1,%xmm1
xorpd  %xmm3,%xmm3
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm1,%xmm4
lea    -0x2(%rax),%ecx
movapd %xmm0,%xmm1
mulsd  %xmm4,%xmm1
subsd  %xmm3,%xmm1
addsd  (%rbx,%rcx,8),%xmm1
add    $0xffffffffffffffff,%rax
movapd %xmm4,%xmm3
cmp    $0x2,%rax
ja     11b0 <chebev+0xa0>
mulsd  %xmm1,%xmm2
subsd  %xmm4,%xmm2
movsd  (%rbx),%xmm0
mulsd  0xe16(%rip),%xmm0
addsd  %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"x not in range in routine chebev\00"
define double @chebev(double %0, double %1, double* %2, i32 %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
store double %0, double* %6
store double %1, double* %7
store double* %2, double** %8
store i32 %3, i32* %9
store double %4, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
%17 = load double, double* %10
%18 = load double, double* %6
%19 = fsub double %17, %18
%20 = load double, double* %10
%21 = load double, double* %7
%22 = fsub double %20, %21
%23 = fmul double %19, %22
%24 = fcmp ogt double %23, 0.000000e+00
br i1 %24, label %25, label %27
25: ; preds = %5
%26 = call i32 @error2(i32 93, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %5
%28 = load double, double* %10
%29 = load double, double* %6
%30 = fneg double %29
%31 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %28, double %30)
%32 = load double, double* %7
%33 = fsub double %31, %32
%34 = load double, double* %7
%35 = load double, double* %6
%36 = fsub double %34, %35
%37 = fdiv double %33, %36
store double %37, double* %14
%38 = fmul double 2.000000e+00, %37
store double %38, double* %15
%39 = load i32, i32* %9
%40 = sub nsw i32 %39, 1
store i32 %40, i32* %16
br label %41
41: ; preds = %58, %27
%42 = load i32, i32* %16
%43 = icmp sge i32 %42, 1
br i1 %43, label %44, label %61
44: ; preds = %41
%45 = load double, double* %11
store double %45, double* %13
%46 = load double, double* %15
%47 = load double, double* %11
%48 = load double, double* %12
%49 = fneg double %48
%50 = call double @llvm.fmuladd.f64(double %46, double %47, double %49)
%51 = load double*, double** %8
%52 = load i32, i32* %16
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = fadd double %50, %55
store double %56, double* %11
%57 = load double, double* %13
store double %57, double* %12
br label %58
58: ; preds = %44
%59 = load i32, i32* %16
%60 = add nsw i32 %59, -1
store i32 %60, i32* %16
br label %41
61: ; preds = %41
%62 = load double, double* %14
%63 = load double, double* %11
%64 = load double, double* %12
%65 = fneg double %64
%66 = call double @llvm.fmuladd.f64(double %62, double %63, double %65)
%67 = load double*, double** %8
%68 = getelementptr inbounds double, double* %67, i64 0
%69 = load double, double* %68
%70 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %69, double %66)
ret double %70
}

LLVM IR (-O2):
@.str = [33 x i8] c"x not in range in routine chebev\00"
define double @chebev(double %0, double %1, double* nocapture %2, i32 %3, double %4) {
%6 = fsub double %4, %0
%7 = fsub double %4, %1
%8 = fmul double %6, %7
%9 = fcmp ogt double %8, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @error2(i32 93, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
%13 = fneg double %0
%14 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double %13)
%15 = fsub double %14, %1
%16 = fsub double %1, %0
%17 = fdiv double %15, %16
%18 = fmul double %17, 2.000000e+00
%19 = icmp sgt i32 %3, 1
br i1 %19, label %20, label %34
20: ; preds = %12
%21 = zext i32 %3 to i64
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ %21, %20 ], [ %26, %22 ]
%24 = phi double [ 0.000000e+00, %20 ], [ %32, %22 ]
%25 = phi double [ 0.000000e+00, %20 ], [ %24, %22 ]
%26 = add nsw i64 %23, -1
%27 = fneg double %25
%28 = tail call double @llvm.fmuladd.f64(double %18, double %24, double %27)
%29 = and i64 %26, 4294967295
%30 = getelementptr inbounds double, double* %2, i64 %29
%31 = load double, double* %30
%32 = fadd double %28, %31
%33 = icmp ugt i64 %23, 2
br i1 %33, label %22, label %34
34: ; preds = %22, %12
%35 = phi double [ 0.000000e+00, %12 ], [ %24, %22 ]
%36 = phi double [ 0.000000e+00, %12 ], [ %32, %22 ]
%37 = fneg double %35
%38 = tail call double @llvm.fmuladd.f64(double %17, double %36, double %37)
%39 = load double, double* %2
%40 = tail call double @llvm.fmuladd.f64(double %39, double 5.000000e-01, double %38)
ret double %40
}