#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 dspl_win_blackman_nuttall(double *w, int n, int win_type) {
  double y;
  double x = 0.0;
  double a0 = 0.3635819;
  double a1 = 0.4891775;
  double a2 = 0.1365995;
  double a3 = 0.0106411;
  int i;
  if ((win_type & 0x00000100) == 0x00000000)
    x = 6.283185307179586476925286766559 / (double)(n - 1);
  if ((win_type & 0x00000100) == 0x00000100)
    x = 6.283185307179586476925286766559 / (double)n;
  y = 0.0;
  for (i = 0; i < n; i++) {
    w[i] = a0 - a1 * cos(y) + a2 * cos(2.0 * y) - a3 * cos(3.0 * y);
    y += x;
  }
}


x86 assembly (clang, -O0):
<dspl_win_blackman_nuttall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xee3(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    118d <dspl_win_blackman_nuttall+0x7d>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe9c(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x100,%eax
jne    11b6 <dspl_win_blackman_nuttall+0xa6>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe73(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12c8 <dspl_win_blackman_nuttall+0x1b8>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x78(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xdfe(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdc0(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11c5 <dspl_win_blackman_nuttall+0xb5>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_blackman_nuttall>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %esi,%esi
jle    11da <dspl_win_blackman_nuttall+0xca>
mov    %rdi,%r14
shr    $0x8,%edx
and    $0x1,%edx
lea    (%rdx,%rsi,1),%eax
add    $0xffffffff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xec4(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    %esi,%r15d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nop
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xe9f(%rip),%xmm0
addsd  0xe9f(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <cos@plt>
mulsd  0xe8a(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe78(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xe73(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <dspl_win_blackman_nuttall+0x40>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @dspl_win_blackman_nuttall(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %8
store double 0x3FD744ED047AB904, double* %9
store double 0x3FDF4EAF251C193B, double* %10
store double 0x3FC17C17A89331A1, double* %11
store double 1.064110e-02, double* %12
%14 = load i32, i32* %6
%15 = and i32 %14, 256
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %3
%18 = load i32, i32* %5
%19 = sub nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fdiv double 0x401921FB54442D18, %20
store double %21, double* %8
br label %22
22: ; preds = %17, %3
%23 = load i32, i32* %6
%24 = and i32 %23, 256
%25 = icmp eq i32 %24, 256
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %5
%28 = sitofp i32 %27 to double
%29 = fdiv double 0x401921FB54442D18, %28
store double %29, double* %8
br label %30
30: ; preds = %26, %22
store double 0.000000e+00, double* %7
store i32 0, i32* %13
br label %31
31: ; preds = %60, %30
%32 = load i32, i32* %13
%33 = load i32, i32* %5
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %63
35: ; preds = %31
%36 = load double, double* %9
%37 = load double, double* %10
%38 = load double, double* %7
%39 = call double @cos(double %38)
%40 = fneg double %37
%41 = call double @llvm.fmuladd.f64(double %40, double %39, double %36)
%42 = load double, double* %11
%43 = load double, double* %7
%44 = fmul double 2.000000e+00, %43
%45 = call double @cos(double %44)
%46 = call double @llvm.fmuladd.f64(double %42, double %45, double %41)
%47 = load double, double* %12
%48 = load double, double* %7
%49 = fmul double 3.000000e+00, %48
%50 = call double @cos(double %49)
%51 = fneg double %47
%52 = call double @llvm.fmuladd.f64(double %51, double %50, double %46)
%53 = load double*, double** %4
%54 = load i32, i32* %13
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
store double %52, double* %56
%57 = load double, double* %8
%58 = load double, double* %7
%59 = fadd double %58, %57
store double %59, double* %7
br label %60
60: ; preds = %35
%61 = load i32, i32* %13
%62 = add nsw i32 %61, 1
store i32 %62, i32* %13
br label %31
63: ; preds = %31
ret void
}

LLVM IR (-O2):
define void @dspl_win_blackman_nuttall(double* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = lshr i32 %2, 8
%5 = and i32 %4, 1
%6 = add nsw i32 %5, -1
%7 = add nsw i32 %6, %1
%8 = sitofp i32 %7 to double
%9 = fdiv double 0x401921FB54442D18, %8
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %28
11: ; preds = %3
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %26, %13 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %25, %13 ]
%16 = tail call double @cos(double %15)
%17 = tail call double @llvm.fmuladd.f64(double %16, double 0xBFDF4EAF251C193B, double 0x3FD744ED047AB904)
%18 = fmul double %15, 2.000000e+00
%19 = tail call double @cos(double %18)
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0x3FC17C17A89331A1, double %17)
%21 = fmul double %15, 3.000000e+00
%22 = tail call double @cos(double %21)
%23 = tail call double @llvm.fmuladd.f64(double %22, double -1.064110e-02, double %20)
%24 = getelementptr inbounds double, double* %0, i64 %14
store double %23, double* %24
%25 = fadd double %9, %15
%26 = add nuw nsw i64 %14, 1
%27 = icmp eq i64 %26, %12
br i1 %27, label %28, label %13
28: ; preds = %13, %3
ret void
}