#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);
double fabs(double);
void dspl_win_bartlett_hann(double *w, int n, int win_type) {
  double y;
  double x = 0.0;
  int i;
  if ((win_type & 0x00000100) == 0x00000000)
    x = 1.0 / (double)(n - 1);
  if ((win_type & 0x00000100) == 0x00000100)
    x = 1.0 / (double)n;
  y = 0.0;
  for (i = 0; i < n; i++) {
    w[i] = 0.62 - 0.48 * fabs(y - 0.5) -
           0.38 * cos(6.283185307179586476925286766559 * y);
    y += x;
  }
}


x86 assembly (clang, -O0):
<dspl_win_bartlett_hann>:
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_bartlett_hann+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_bartlett_hann+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    1224 <dspl_win_bartlett_hann+0x114>
movsd  -0x18(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
subsd  %xmm1,%xmm0
movaps 0xe7e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe5a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe56(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe35(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xe16(%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_bartlett_hann+0x7e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_bartlett_hann>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %esi,%esi
jle    12a6 <dspl_win_bartlett_hann+0x196>
mov    %rdi,%r14
mov    %esi,%r15d
cmp    $0x1,%esi
jne    1139 <dspl_win_bartlett_hann+0x29>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    1257 <dspl_win_bartlett_hann+0x147>
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,0x18(%rsp)
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
movsd  0xe87(%rip),%xmm0
addsd  %xmm0,%xmm1
movapd 0xea3(%rip),%xmm0
andpd  %xmm0,%xmm1
movsd  0xe77(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
addsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  (%rsp),%xmm0
movsd  0xe64(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  0xe5b(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movsd  (%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
addsd  0xe0e(%rip),%xmm0
andpd  0xe2e(%rip),%xmm0
mulsd  0xe06(%rip),%xmm0
addsd  0xe06(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xdfb(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xdf6(%rip),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%r14,%rbx,8)
movsd  (%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1170 <dspl_win_bartlett_hann+0x60>
test   $0x1,%r15b
je     12a6 <dspl_win_bartlett_hann+0x196>
movsd  0xda3(%rip),%xmm1
addsd  %xmm0,%xmm1
andpd  0xdbf(%rip),%xmm1
mulsd  0xd97(%rip),%xmm1
addsd  0xd97(%rip),%xmm1
movapd %xmm1,(%rsp)
mulsd  0xd92(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xd8d(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @dspl_win_bartlett_hann(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 1.000000e+00, %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 1.000000e+00, %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 = %47, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %5
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %50
31: ; preds = %27
%32 = load double, double* %7
%33 = fsub double %32, 5.000000e-01
%34 = call double @llvm.fabs.f64(double %33)
%35 = call double @llvm.fmuladd.f64(double -4.800000e-01, double %34, double 6.200000e-01)
%36 = load double, double* %7
%37 = fmul double 0x401921FB54442D18, %36
%38 = call double @cos(double %37)
%39 = call double @llvm.fmuladd.f64(double -3.800000e-01, double %38, double %35)
%40 = load double*, double** %4
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double %39, double* %43
%44 = load double, double* %8
%45 = load double, double* %7
%46 = fadd double %45, %44
store double %46, double* %7
br label %47
47: ; preds = %31
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %27
50: ; preds = %27
ret void
}

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