#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 sin(double);
float evlmem(float fdt, float d[], int m, float xms) {
  int i;
  float sumr = 1.0, sumi = 0.0;
  double wr = 1.0, wi = 0.0, wpr, wpi, wtemp, theta;
  theta = 6.28318530717959 * fdt;
  wpr = cos(theta);
  wpi = sin(theta);
  for (i = 1; i <= m; i++) {
    wr = (wtemp = wr) * wpr - wi * wpi;
    wi = wi * wpr + wtemp * wpi;
    sumr -= d[i] * wr;
    sumi -= d[i] * wi;
  }
  return xms / (sumr * sumr + sumi * sumi);
}


x86 assembly (clang, -O0):
<evlmem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  0xecf(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movsd  0xeb2(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     12a8 <evlmem+0x188>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x30(%rbp),%xmm2
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x38(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <evlmem+0x82>
movss  -0x18(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x20(%rbp),%xmm3
movss  -0x24(%rbp),%xmm2
mulss  -0x24(%rbp),%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evlmem>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movss  %xmm1,0x4(%rsp)
mov    %esi,%ebx
mov    %rdi,%r14
cvtss2sd %xmm0,%xmm0
mulsd  0xec2(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
test   %ebx,%ebx
jle    11d4 <evlmem+0xb4>
add    $0x1,%ebx
movapd 0x10(%rsp),%xmm6
unpcklpd %xmm6,%xmm6
xorpd  %xmm2,%xmm2
movhpd 0xe91(%rip),%xmm2
unpcklpd %xmm0,%xmm0
movapd 0xe8d(%rip),%xmm1
mov    $0x1,%eax
movapd 0xe90(%rip),%xmm3
movapd %xmm2,%xmm4
xorpd  %xmm3,%xmm4
movapd %xmm2,%xmm5
shufpd $0x1,%xmm4,%xmm5
mulpd  %xmm0,%xmm5
mulpd  %xmm6,%xmm2
addpd  %xmm5,%xmm2
movss  (%r14,%rax,4),%xmm4
cvtps2pd %xmm1,%xmm1
cvtss2sd %xmm4,%xmm4
movlhps %xmm4,%xmm4
mulpd  %xmm2,%xmm4
subpd  %xmm4,%xmm1
cvtpd2ps %xmm1,%xmm1
add    $0x1,%rax
cmp    %rax,%rbx
jne    1190 <evlmem+0x70>
jmp    11dc <evlmem+0xbc>
movapd 0xe34(%rip),%xmm1
movapd %xmm1,%xmm0
mulss  %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm1
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
divss  %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

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