#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(int);
double sin(int);
double evalfpoly(int order, double x, double *c) {
  int i, j;
  double y = c[0];
  x = (x - (0.000000000000000)) / (5.729577951308232);
  for (i = 1, j = 1; j <= order; j += 2, i++)
    y += c[j] * cos(i * x) + c[j + 1] * sin(i * x);
  return y;
}


x86 assembly (clang, -O0):
<evalfpoly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xeab(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     120b <evalfpoly+0xeb>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116c <evalfpoly+0x4c>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evalfpoly>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
movsd  %xmm0,0x8(%rsp)
movsd  (%rsi),%xmm0
test   %edi,%edi
jle    11e3 <evalfpoly+0xc3>
mov    %rsi,%r15
mov    %edi,%r14d
movsd  0x8(%rsp),%xmm1
divsd  0xeae(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x1,%ebx
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x28(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  (%r15,%rbp,8),%xmm1
movsd  %xmm1,0x20(%rsp)
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%r12d
mov    %r12d,%edi
call   1040 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%r15,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r12d,%edi
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x28(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x2,%rbp
add    $0x1,%ebx
cmp    %r14d,%ebp
jle    1170 <evalfpoly+0x50>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @evalfpoly(i32 %0, double %1, double* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double* %2, double** %6
%10 = load double*, double** %6
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
store double %12, double* %9
%13 = load double, double* %5
%14 = fsub double %13, 0.000000e+00
%15 = fdiv double %14, 0x4016EB167B830193
store double %15, double* %5
store i32 1, i32* %7
store i32 1, i32* %8
br label %16
16: ; preds = %48, %3
%17 = load i32, i32* %8
%18 = load i32, i32* %4
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %53
20: ; preds = %16
%21 = load double*, double** %6
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = load i32, i32* %7
%27 = sitofp i32 %26 to double
%28 = load double, double* %5
%29 = fmul double %27, %28
%30 = fptosi double %29 to i32
%31 = call double @cos(i32 %30)
%32 = load double*, double** %6
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %32, i64 %35
%37 = load double, double* %36
%38 = load i32, i32* %7
%39 = sitofp i32 %38 to double
%40 = load double, double* %5
%41 = fmul double %39, %40
%42 = fptosi double %41 to i32
%43 = call double @sin(i32 %42)
%44 = fmul double %37, %43
%45 = call double @llvm.fmuladd.f64(double %25, double %31, double %44)
%46 = load double, double* %9
%47 = fadd double %46, %45
store double %47, double* %9
br label %48
48: ; preds = %20
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 2
store i32 %50, i32* %8
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %16
53: ; preds = %16
%54 = load double, double* %9
ret double %54
}

LLVM IR (-O2):
define double @evalfpoly(i32 %0, double %1, double* nocapture %2) {
%4 = load double, double* %2
%5 = fdiv double %1, 0x4016EB167B830193
%6 = icmp slt i32 %0, 1
br i1 %6, label %28, label %7
7: ; preds = %3, %7
%8 = phi i64 [ %24, %7 ], [ 1, %3 ]
%9 = phi double [ %23, %7 ], [ %4, %3 ]
%10 = phi i32 [ %25, %7 ], [ 1, %3 ]
%11 = getelementptr inbounds double, double* %2, i64 %8
%12 = load double, double* %11
%13 = sitofp i32 %10 to double
%14 = fmul double %5, %13
%15 = fptosi double %14 to i32
%16 = tail call double @cos(i32 %15)
%17 = add nuw nsw i64 %8, 1
%18 = getelementptr inbounds double, double* %2, i64 %17
%19 = load double, double* %18
%20 = tail call double @sin(i32 %15)
%21 = fmul double %19, %20
%22 = tail call double @llvm.fmuladd.f64(double %12, double %16, double %21)
%23 = fadd double %9, %22
%24 = add nuw i64 %8, 2
%25 = add nuw nsw i32 %10, 1
%26 = trunc i64 %24 to i32
%27 = icmp sgt i32 %26, %0
br i1 %27, label %28, label %7
28: ; preds = %7, %3
%29 = phi double [ %4, %3 ], [ %23, %7 ]
ret double %29
}