#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 M_PI;
double cos(double);
double sin(double);
double evlmem(double f, double *cof, long m, double pm) {
  int i = 0;
  double sumr = 1.0, sumi = 0.0;
  double wr = 1.0, wi = 0.0, wpr = 0.0, wpi = 0.0, wt = 0.0, theta = 0.0;
  theta = 2.0 * M_PI * f;
  wpr = cos(theta);
  wpi = sin(theta);
  for (i = 0; i < m; i++) {
    wt = wr;
    sumr -= cof[i] * (wr = wr * wpr - wi * wpi);
    sumi -= cof[i] * (wi = wi * wpr + wt * wpi);
  }
  return (pm / (sumr * sumr + sumi * sumi));
}


x86 assembly (clang, -O0):
<evlmem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xeaa(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe6d(%rip),%xmm0
mov    0x2e4e(%rip),%rax
mulsd  (%rax),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    12b8 <evlmem+0x198>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cd <evlmem+0xad>
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm2
mulsd  -0x38(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evlmem>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm1,0x8(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2eae(%rip),%rax
movsd  (%rax),%xmm1
addsd  %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1040 <cos@plt>
movapd %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
test   %rbx,%rbx
jle    11e2 <evlmem+0xc2>
unpcklpd %xmm0,%xmm0
movapd 0x10(%rsp),%xmm7
unpcklpd %xmm7,%xmm7
movsd  0xe85(%rip),%xmm1
xor    %eax,%eax
movapd 0xe8b(%rip),%xmm3
movapd %xmm1,%xmm4
nopl   0x0(%rax)
movapd %xmm4,%xmm2
movapd %xmm1,%xmm6
unpckhpd %xmm1,%xmm6
xorpd  %xmm3,%xmm6
movsd  (%r14,%rax,8),%xmm5
unpcklpd %xmm1,%xmm6
mulpd  %xmm0,%xmm6
mulpd  %xmm7,%xmm1
addpd  %xmm6,%xmm1
movapd %xmm5,%xmm6
unpcklpd %xmm5,%xmm6
mulpd  %xmm1,%xmm6
subpd  %xmm6,%xmm4
add    $0x1,%rax
cmp    %rax,%rbx
jne    1190 <evlmem+0x70>
xorpd  %xmm3,%xmm5
pshufd $0x44,%xmm5,%xmm3
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
jmp    11ea <evlmem+0xca>
movsd  0xe16(%rip),%xmm3
movapd %xmm3,%xmm1
mulpd  %xmm3,%xmm1
unpckhpd %xmm1,%xmm1
mulsd  %xmm3,%xmm3
addsd  %xmm1,%xmm3
movsd  0x8(%rsp),%xmm0
divsd  %xmm3,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @evlmem(double %0, double* %1, i64 %2, double %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca i64
%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 double
%17 = alloca double
store double %0, double* %5
store double* %1, double** %6
store i64 %2, i64* %7
store double %3, double* %8
store i32 0, i32* %9
store double 1.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 1.000000e+00, double* %12
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %16
store double 0.000000e+00, double* %17
%18 = load double, double* @M_PI
%19 = fmul double 2.000000e+00, %18
%20 = load double, double* %5
%21 = fmul double %19, %20
store double %21, double* %17
%22 = load double, double* %17
%23 = call double @cos(double %22)
store double %23, double* %14
%24 = load double, double* %17
%25 = call double @sin(double %24)
store double %25, double* %15
store i32 0, i32* %9
br label %26
26: ; preds = %62, %4
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = load i64, i64* %7
%30 = icmp slt i64 %28, %29
br i1 %30, label %31, label %65
31: ; preds = %26
%32 = load double, double* %12
store double %32, double* %16
%33 = load double*, double** %6
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = load double, double* %12
%39 = load double, double* %14
%40 = load double, double* %13
%41 = load double, double* %15
%42 = fmul double %40, %41
%43 = fneg double %42
%44 = call double @llvm.fmuladd.f64(double %38, double %39, double %43)
store double %44, double* %12
%45 = load double, double* %10
%46 = fneg double %37
%47 = call double @llvm.fmuladd.f64(double %46, double %44, double %45)
store double %47, double* %10
%48 = load double*, double** %6
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
%53 = load double, double* %13
%54 = load double, double* %14
%55 = load double, double* %16
%56 = load double, double* %15
%57 = fmul double %55, %56
%58 = call double @llvm.fmuladd.f64(double %53, double %54, double %57)
store double %58, double* %13
%59 = load double, double* %11
%60 = fneg double %52
%61 = call double @llvm.fmuladd.f64(double %60, double %58, double %59)
store double %61, double* %11
br label %62
62: ; preds = %31
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %26
65: ; preds = %26
%66 = load double, double* %8
%67 = load double, double* %10
%68 = load double, double* %10
%69 = load double, double* %11
%70 = load double, double* %11
%71 = fmul double %69, %70
%72 = call double @llvm.fmuladd.f64(double %67, double %68, double %71)
%73 = fdiv double %66, %72
ret double %73
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @evlmem(double %0, double* nocapture %1, i64 %2, double %3) {
%5 = load double, double* @M_PI
%6 = fmul double %5, 2.000000e+00
%7 = fmul double %6, %0
%8 = tail call double @cos(double %7)
%9 = tail call double @sin(double %7)
%10 = icmp sgt i64 %2, 0
br i1 %10, label %11, label %37
11: ; preds = %4
%12 = insertelement <2 x double> poison, double %9, i64 0
%13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
%14 = insertelement <2 x double> poison, double %8, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
br label %16
16: ; preds = %11, %16
%17 = phi i64 [ %33, %16 ], [ 0, %11 ]
%18 = phi <2 x double> [ %28, %16 ], [ <double 1.000000e+00, double 0.000000e+00>, %11 ]
%19 = phi <2 x double> [ %32, %16 ], [ <double 1.000000e+00, double 0.000000e+00>, %11 ]
%20 = getelementptr inbounds double, double* %1, i64 %17
%21 = load double, double* %20
%22 = extractelement <2 x double> %18, i64 1
%23 = fneg double %22
%24 = fneg double %21
%25 = insertelement <2 x double> poison, double %23, i64 0
%26 = shufflevector <2 x double> %25, <2 x double> %18, <2 x i32> <i32 0, i32 2>
%27 = fmul <2 x double> %13, %26
%28 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %15, <2 x double> %27)
%29 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %15, <2 x double> %27)
%30 = insertelement <2 x double> poison, double %24, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %29, <2 x double> %19)
%33 = add nuw nsw i64 %17, 1
%34 = icmp eq i64 %33, %2
br i1 %34, label %35, label %16
35: ; preds = %16
%36 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %29, <2 x double> %19)
br label %37
37: ; preds = %35, %4
%38 = phi <2 x double> [ <double 1.000000e+00, double 0.000000e+00>, %4 ], [ %36, %35 ]
%39 = fmul <2 x double> %38, %38
%40 = extractelement <2 x double> %39, i64 1
%41 = extractelement <2 x double> %38, i64 0
%42 = tail call double @llvm.fmuladd.f64(double %41, double %41, double %40)
%43 = fdiv double %3, %42
ret double %43
}