#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);
void BlackmanHarris62(int sizeWindow, double *pFWindow) {
  int i;
  double fSum = 0;
  double a0 = .44959, a1 = .49364, a2 = .05677;
  double fConst = 6.28318530717958647692 / sizeWindow;
  for (i = 0; i < sizeWindow; i++) {
    fSum += pFWindow[i] = a0 - a1 * cos(fConst * i) + a2 * cos(fConst * 2 * i);
  }
}


x86 assembly (clang, -O0):
<BlackmanHarris62>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xee9(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xed4(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xea5(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    122e <BlackmanHarris62+0x11e>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe3f(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <BlackmanHarris62+0x5b>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BlackmanHarris62>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    129e <BlackmanHarris62+0x18e>
mov    %rsi,%r14
cvtsi2sd %edi,%xmm0
movsd  0xece(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mov    %edi,%r15d
cmp    $0x1,%edi
movsd  %xmm0,0x20(%rsp)
jne    1153 <BlackmanHarris62+0x43>
xor    %ebx,%ebx
jmp    1243 <BlackmanHarris62+0x133>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
movsd  %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
movsd  %xmm2,0x18(%rsp)
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
movapd %xmm0,%xmm1
movsd  0xe72(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe6e(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
call   1030 <cos@plt>
movsd  0xe53(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
lea    0x1(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0xe0c(%rip),%xmm0
addsd  0xe0c(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
call   1030 <cos@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0xdef(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %r12,%rbx
jne    1170 <BlackmanHarris62+0x60>
test   $0x1,%r15b
je     129e <BlackmanHarris62+0x18e>
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0xd9d(%rip),%xmm0
addsd  0xd9d(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xd86(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @BlackmanHarris62(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 %0, i32* %3
store double* %1, double** %4
store double 0.000000e+00, double* %6
store double 4.495900e-01, double* %7
store double 4.936400e-01, double* %8
store double 5.677000e-02, double* %9
%11 = load i32, i32* %3
%12 = sitofp i32 %11 to double
%13 = fdiv double 0x401921FB54442D18, %12
store double %13, double* %10
store i32 0, i32* %5
br label %14
14: ; preds = %42, %2
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %45
18: ; preds = %14
%19 = load double, double* %7
%20 = load double, double* %8
%21 = load double, double* %10
%22 = load i32, i32* %5
%23 = sitofp i32 %22 to double
%24 = fmul double %21, %23
%25 = call double @cos(double %24)
%26 = fneg double %20
%27 = call double @llvm.fmuladd.f64(double %26, double %25, double %19)
%28 = load double, double* %9
%29 = load double, double* %10
%30 = fmul double %29, 2.000000e+00
%31 = load i32, i32* %5
%32 = sitofp i32 %31 to double
%33 = fmul double %30, %32
%34 = call double @cos(double %33)
%35 = call double @llvm.fmuladd.f64(double %28, double %34, double %27)
%36 = load double*, double** %4
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double %35, double* %39
%40 = load double, double* %6
%41 = fadd double %40, %35
store double %41, double* %6
br label %42
42: ; preds = %18
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %14
45: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @BlackmanHarris62(i32 %0, double* nocapture writeonly %1) {
%3 = sitofp i32 %0 to double
%4 = fdiv double 0x401921FB54442D18, %3
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %51
6: ; preds = %2
%7 = fmul double %4, 2.000000e+00
%8 = zext i32 %0 to i64
%9 = and i64 %8, 1
%10 = icmp eq i32 %0, 1
br i1 %10, label %38, label %11
11: ; preds = %6
%12 = and i64 %8, 4294967294
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %35, %13 ]
%15 = phi i64 [ 0, %11 ], [ %36, %13 ]
%16 = trunc i64 %14 to i32
%17 = sitofp i32 %16 to double
%18 = fmul double %4, %17
%19 = tail call double @cos(double %18)
%20 = tail call double @llvm.fmuladd.f64(double %19, double -4.936400e-01, double 4.495900e-01)
%21 = fmul double %7, %17
%22 = tail call double @cos(double %21)
%23 = tail call double @llvm.fmuladd.f64(double %22, double 5.677000e-02, double %20)
%24 = getelementptr inbounds double, double* %1, i64 %14
store double %23, double* %24
%25 = or i64 %14, 1
%26 = trunc i64 %25 to i32
%27 = sitofp i32 %26 to double
%28 = fmul double %4, %27
%29 = tail call double @cos(double %28)
%30 = tail call double @llvm.fmuladd.f64(double %29, double -4.936400e-01, double 4.495900e-01)
%31 = fmul double %7, %27
%32 = tail call double @cos(double %31)
%33 = tail call double @llvm.fmuladd.f64(double %32, double 5.677000e-02, double %30)
%34 = getelementptr inbounds double, double* %1, i64 %25
store double %33, double* %34
%35 = add nuw nsw i64 %14, 2
%36 = add i64 %15, 2
%37 = icmp eq i64 %36, %12
br i1 %37, label %38, label %13
38: ; preds = %13, %6
%39 = phi i64 [ 0, %6 ], [ %35, %13 ]
%40 = icmp eq i64 %9, 0
br i1 %40, label %51, label %41
41: ; preds = %38
%42 = trunc i64 %39 to i32
%43 = sitofp i32 %42 to double
%44 = fmul double %4, %43
%45 = tail call double @cos(double %44)
%46 = tail call double @llvm.fmuladd.f64(double %45, double -4.936400e-01, double 4.495900e-01)
%47 = fmul double %7, %43
%48 = tail call double @cos(double %47)
%49 = tail call double @llvm.fmuladd.f64(double %48, double 5.677000e-02, double %46)
%50 = getelementptr inbounds double, double* %1, i64 %39
store double %49, double* %50
br label %51
51: ; preds = %41, %38, %2
ret void
}