#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(double *w, int n, int win_type) {
  double y;
  double x = 0.0;
  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] = 0.42 - 0.5 * cos(y) + 0.08 * cos(2.0 * y);
    y += x;
  }
}


x86 assembly (clang, -O0):
<dspl_win_blackman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    1156 <dspl_win_blackman+0x46>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xeb3(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x100,%eax
jne    117f <dspl_win_blackman+0x6f>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe8a(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1212 <dspl_win_blackman+0x102>
movsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  0xe6c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe68(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe47(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xe28(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118e <dspl_win_blackman+0x7e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_blackman>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    127a <dspl_win_blackman+0x16a>
mov    %rdi,%r14
mov    %esi,%r15d
cmp    $0x1,%esi
jne    1139 <dspl_win_blackman+0x29>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    1232 <dspl_win_blackman+0x122>
shr    $0x8,%edx
and    $0x1,%edx
lea    (%rdx,%rsi,1),%eax
add    $0xffffffff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xeaf(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
call   1030 <cos@plt>
movapd %xmm0,%xmm1
movsd  0xe7d(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe79(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <cos@plt>
movsd  0xe61(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xe1f(%rip),%xmm0
addsd  0xe1f(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <cos@plt>
mulsd  0xe0b(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%r14,%rbx,8)
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1170 <dspl_win_blackman+0x60>
test   $0x1,%r15b
je     127a <dspl_win_blackman+0x16a>
movsd  %xmm0,(%rsp)
call   1030 <cos@plt>
mulsd  0xdbe(%rip),%xmm0
addsd  0xdbe(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <cos@plt>
mulsd  0xdaa(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @dspl_win_blackman(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 %50
11: ; preds = %3
%12 = zext i32 %1 to i64
%13 = and i64 %12, 1
%14 = icmp eq i32 %1, 1
br i1 %14, label %39, label %15
15: ; preds = %11
%16 = and i64 %12, 4294967294
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 0, %15 ], [ %36, %17 ]
%19 = phi double [ 0.000000e+00, %15 ], [ %35, %17 ]
%20 = phi i64 [ 0, %15 ], [ %37, %17 ]
%21 = tail call double @cos(double %19)
%22 = tail call double @llvm.fmuladd.f64(double %21, double -5.000000e-01, double 4.200000e-01)
%23 = fmul double %19, 2.000000e+00
%24 = tail call double @cos(double %23)
%25 = tail call double @llvm.fmuladd.f64(double %24, double 8.000000e-02, double %22)
%26 = getelementptr inbounds double, double* %0, i64 %18
store double %25, double* %26
%27 = fadd double %9, %19
%28 = or i64 %18, 1
%29 = tail call double @cos(double %27)
%30 = tail call double @llvm.fmuladd.f64(double %29, double -5.000000e-01, double 4.200000e-01)
%31 = fmul double %27, 2.000000e+00
%32 = tail call double @cos(double %31)
%33 = tail call double @llvm.fmuladd.f64(double %32, double 8.000000e-02, double %30)
%34 = getelementptr inbounds double, double* %0, i64 %28
store double %33, double* %34
%35 = fadd double %9, %27
%36 = add nuw nsw i64 %18, 2
%37 = add i64 %20, 2
%38 = icmp eq i64 %37, %16
br i1 %38, label %39, label %17
39: ; preds = %17, %11
%40 = phi i64 [ 0, %11 ], [ %36, %17 ]
%41 = phi double [ 0.000000e+00, %11 ], [ %35, %17 ]
%42 = icmp eq i64 %13, 0
br i1 %42, label %50, label %43
43: ; preds = %39
%44 = tail call double @cos(double %41)
%45 = tail call double @llvm.fmuladd.f64(double %44, double -5.000000e-01, double 4.200000e-01)
%46 = fmul double %41, 2.000000e+00
%47 = tail call double @cos(double %46)
%48 = tail call double @llvm.fmuladd.f64(double %47, double 8.000000e-02, double %45)
%49 = getelementptr inbounds double, double* %0, i64 %40
store double %48, double* %49
br label %50
50: ; preds = %43, %39, %3
ret void
}