#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 const cos(double);
void blackman_harris(double *window, const int N) {
  int n;
  const double M = N - 1, a0 = 0.35875, a1 = 0.48829, a2 = 0.14128,
               a3 = 0.01168;
  double term1 = 0.0, term2 = 0.0, term3 = 0.0;
  for (n = 0; n < N; n++) {
    term1 = a1 * cos(2.0 * 3.14159265358979323846264338327 * n / M);
    term2 = a2 * cos(4.0 * 3.14159265358979323846264338327 * n / M);
    term3 = a3 * cos(6.0 * 3.14159265358979323846264338327 * n / M);
    window[n] = a0 - term1 + term2 - term3;
  }
}


x86 assembly (clang, -O0):
<blackman_harris>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xee2(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xecd(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xea3(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    124c <blackman_harris+0x13c>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe96(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe5d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe5f(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe26(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe28(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xdef(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdf6(%rip),%xmm0
subsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1181 <blackman_harris+0x71>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blackman_harris>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %esi,%esi
jle    11de <blackman_harris+0xce>
mov    %rdi,%r14
lea    -0x1(%rsi),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
mov    %esi,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0xeab(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xea1(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe95(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xe8b(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe7f(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xe75(%rip),%xmm0
movsd  0x18(%rsp),%xmm1
addsd  0xe6f(%rip),%xmm1
addsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <blackman_harris+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @blackman_harris(double* nocapture writeonly %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = sitofp i32 %3 to double
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %30
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %28, %8 ]
%10 = trunc i64 %9 to i32
%11 = sitofp i32 %10 to double
%12 = fmul double %11, 0x401921FB54442D18
%13 = fdiv double %12, %4
%14 = tail call double @cos(double %13)
%15 = fmul double %14, 4.882900e-01
%16 = fmul double %11, 0x402921FB54442D18
%17 = fdiv double %16, %4
%18 = tail call double @cos(double %17)
%19 = fmul double %18, 1.412800e-01
%20 = fmul double %11, 0x4032D97C7F3321D2
%21 = fdiv double %20, %4
%22 = tail call double @cos(double %21)
%23 = fmul double %22, 1.168000e-02
%24 = fsub double 3.587500e-01, %15
%25 = fadd double %24, %19
%26 = fsub double %25, %23
%27 = getelementptr inbounds double, double* %0, i64 %9
store double %26, double* %27
%28 = add nuw nsw i64 %9, 1
%29 = icmp eq i64 %28, %7
br i1 %29, label %30, label %8
30: ; preds = %8, %2
ret void
}