#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(double *window, const int N) {
  int n;
  const double M = N - 1, a0 = 0.42, a1 = 0.5, a2 = 0.08;
  double term1 = 0.0, term2 = 0.0;
  for (n = 0; n < N; n++) {
    term1 = a1 * cos(2.0 * 3.14159265358979323846264338327 * (double)n / M);
    term2 = a2 * cos(4.0 * 3.14159265358979323846264338327 * (double)n / M);
    window[n] = a0 - term1 + term2;
  }
}


x86 assembly (clang, -O0):
<blackman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeda(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1203 <blackman+0xf3>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe9b(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe6a(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe64(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe33(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe32(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
addsd  -0x40(%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    116c <blackman+0x5c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blackman>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %esi,%esi
jle    11b0 <blackman+0xa0>
mov    %rdi,%r14
lea    -0x1(%rsi),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %esi,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x10(%rsp)
mulsd  0xeab(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xea0(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe94(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xe89(%rip),%xmm0
movsd  0x18(%rsp),%xmm1
addsd  0xe83(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <blackman+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @blackman(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
store double* %0, double** %3
store i32 %1, i32* %4
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = sitofp i32 %13 to double
store double %14, double* %6
store double 4.200000e-01, double* %7
store double 5.000000e-01, double* %8
store double 8.000000e-02, double* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store i32 0, i32* %5
br label %15
15: ; preds = %42, %2
%16 = load i32, i32* %5
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %45
19: ; preds = %15
%20 = load i32, i32* %5
%21 = sitofp i32 %20 to double
%22 = fmul double 0x401921FB54442D18, %21
%23 = load double, double* %6
%24 = fdiv double %22, %23
%25 = call double @cos(double %24)
%26 = fmul double 5.000000e-01, %25
store double %26, double* %10
%27 = load i32, i32* %5
%28 = sitofp i32 %27 to double
%29 = fmul double 0x402921FB54442D18, %28
%30 = load double, double* %6
%31 = fdiv double %29, %30
%32 = call double @cos(double %31)
%33 = fmul double 8.000000e-02, %32
store double %33, double* %11
%34 = load double, double* %10
%35 = fsub double 4.200000e-01, %34
%36 = load double, double* %11
%37 = fadd double %35, %36
%38 = load double*, double** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
br label %42
42: ; preds = %19
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %15
45: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @blackman(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 %25
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %23, %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, 5.000000e-01
%16 = fmul double %11, 0x402921FB54442D18
%17 = fdiv double %16, %4
%18 = tail call double @cos(double %17)
%19 = fmul double %18, 8.000000e-02
%20 = fsub double 4.200000e-01, %15
%21 = fadd double %20, %19
%22 = getelementptr inbounds double, double* %0, i64 %9
store double %21, double* %22
%23 = add nuw nsw i64 %9, 1
%24 = icmp eq i64 %23, %7
br i1 %24, label %25, label %8
25: ; preds = %8, %2
ret void
}