#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 cos(double);
double chebyshev(int i, int n, double a, double b) {
  return .5 * (a + b +
               (a - b) * cos(3.141592653589793 * (2. * i + 1) / (2. * n + 2)));
}


x86 assembly (clang, -O0):
<chebyshev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xec1(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xead(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe90(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe5e(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chebyshev>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
subsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
addsd  %xmm0,%xmm0
addsd  0xec1(%rip),%xmm0
mulsd  0xec1(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
addsd  %xmm1,%xmm1
addsd  0xeb6(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
mulsd  0xea1(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @chebyshev(i32 %0, i32 %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %7
%10 = load double, double* %8
%11 = fadd double %9, %10
%12 = load double, double* %7
%13 = load double, double* %8
%14 = fsub double %12, %13
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to double
%17 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %16, double 1.000000e+00)
%18 = fmul double 0x400921FB54442D18, %17
%19 = load i32, i32* %6
%20 = sitofp i32 %19 to double
%21 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %20, double 2.000000e+00)
%22 = fdiv double %18, %21
%23 = call double @cos(double %22)
%24 = call double @llvm.fmuladd.f64(double %14, double %23, double %11)
%25 = fmul double 5.000000e-01, %24
ret double %25
}

LLVM IR (-O2):
define double @chebyshev(i32 %0, i32 %1, double %2, double %3) {
%5 = fadd double %2, %3
%6 = fsub double %2, %3
%7 = sitofp i32 %0 to double
%8 = tail call double @llvm.fmuladd.f64(double %7, double 2.000000e+00, double 1.000000e+00)
%9 = fmul double %8, 0x400921FB54442D18
%10 = sitofp i32 %1 to double
%11 = tail call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double 2.000000e+00)
%12 = fdiv double %9, %11
%13 = tail call double @cos(double %12)
%14 = tail call double @llvm.fmuladd.f64(double %6, double %13, double %5)
%15 = fmul double %14, 5.000000e-01
ret double %15
}