#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 fabs(double);
void dspl_win_bartlett(double *w, int n, int win_type) {
  double x = 0.0;
  int i;
  if ((win_type & 0x00000100) == 0x00000000)
    x = (double)(n - 1);
  if ((win_type & 0x00000100) == 0x00000100)
    x = (double)n;
  for (i = 0; i < n; i++) {
    w[i] = 2.0 / x * (x * 0.5 - fabs((double)i - x * 0.5));
  }
}


x86 assembly (clang, -O0):
<dspl_win_bartlett>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    1136 <dspl_win_bartlett+0x36>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x100,%eax
jne    1153 <dspl_win_bartlett+0x53>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fa <dspl_win_bartlett+0xfa>
movsd  0xe9a(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  0xe5f(%rip),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movaps 0xe60(%rip),%xmm3
pand   %xmm3,%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  0xe2d(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <dspl_win_bartlett+0x5a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_bartlett>:
test   %esi,%esi
jle    129a <dspl_win_bartlett+0x19a>
shr    $0x8,%edx
and    $0x1,%edx
lea    (%rsi,%rdx,1),%eax
add    $0xffffffff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xedf(%rip),%xmm13
divsd  %xmm0,%xmm13
movapd 0xef2(%rip),%xmm2
xorpd  %xmm0,%xmm2
mov    %esi,%eax
cmp    $0x1,%esi
jne    1140 <dspl_win_bartlett+0x40>
xor    %ecx,%ecx
jmp    1253 <dspl_win_bartlett+0x153>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd %xmm2,%xmm9
unpcklpd %xmm2,%xmm9
movapd %xmm0,%xmm8
unpcklpd %xmm0,%xmm8
movapd %xmm13,%xmm5
unpcklpd %xmm13,%xmm5
lea    -0x2(%rcx),%rdx
mov    %rdx,%r8
shr    %r8
add    $0x1,%r8
test   %rdx,%rdx
je     129b <dspl_win_bartlett+0x19b>
mov    %r8,%rsi
and    $0xfffffffffffffffe,%rsi
movdqa 0xea7(%rip),%xmm6
xor    %edx,%edx
movapd 0xead(%rip),%xmm1
movapd %xmm9,%xmm3
mulpd  %xmm1,%xmm3
movapd 0xeab(%rip),%xmm12
mulpd  %xmm8,%xmm1
movdqa 0xead(%rip),%xmm10
movdqa 0xeb4(%rip),%xmm11
nopl   0x0(%rax)
cvtdq2pd %xmm6,%xmm4
addpd  %xmm3,%xmm4
andpd  %xmm12,%xmm4
movapd %xmm1,%xmm7
subpd  %xmm4,%xmm7
mulpd  %xmm5,%xmm7
movupd %xmm7,(%rdi,%rdx,8)
movdqa %xmm6,%xmm4
paddd  %xmm10,%xmm4
cvtdq2pd %xmm4,%xmm4
addpd  %xmm3,%xmm4
andpd  %xmm12,%xmm4
movapd %xmm1,%xmm7
subpd  %xmm4,%xmm7
mulpd  %xmm5,%xmm7
movupd %xmm7,0x10(%rdi,%rdx,8)
add    $0x4,%rdx
paddd  %xmm11,%xmm6
add    $0xfffffffffffffffe,%rsi
jne    11c0 <dspl_win_bartlett+0xc0>
cvtdq2pd %xmm6,%xmm3
test   $0x1,%r8b
je     124e <dspl_win_bartlett+0x14e>
movapd 0xe19(%rip),%xmm1
mulpd  %xmm1,%xmm9
addpd  %xmm3,%xmm9
andpd  0xe16(%rip),%xmm9
mulpd  %xmm1,%xmm8
subpd  %xmm9,%xmm8
mulpd  %xmm8,%xmm5
movupd %xmm5,(%rdi,%rdx,8)
cmp    %rax,%rcx
je     129a <dspl_win_bartlett+0x19a>
movsd  0xdb5(%rip),%xmm1
mulsd  %xmm1,%xmm2
movapd 0xde9(%rip),%xmm3
mulsd  %xmm1,%xmm0
nopl   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
addsd  %xmm2,%xmm1
andpd  %xmm3,%xmm1
movapd %xmm0,%xmm4
subsd  %xmm1,%xmm4
mulsd  %xmm13,%xmm4
movsd  %xmm4,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1270 <dspl_win_bartlett+0x170>
ret
xorpd  %xmm3,%xmm3
movhpd 0xd61(%rip),%xmm3
xor    %edx,%edx
test   $0x1,%r8b
jne    121f <dspl_win_bartlett+0x11f>
jmp    124e <dspl_win_bartlett+0x14e>

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

LLVM IR (-O2):
define void @dspl_win_bartlett(double* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = lshr i32 %2, 8
%5 = and i32 %4, 1
%6 = add i32 %1, -1
%7 = add i32 %6, %5
%8 = sitofp i32 %7 to double
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %86
10: ; preds = %3
%11 = fdiv double 2.000000e+00, %8
%12 = fneg double %8
%13 = zext i32 %1 to i64
%14 = icmp eq i32 %1, 1
br i1 %14, label %72, label %15
15: ; preds = %10
%16 = and i64 %13, 4294967294
%17 = insertelement <2 x double> poison, double %12, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
%19 = insertelement <2 x double> poison, double %8, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = insertelement <2 x double> poison, double %11, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = add nsw i64 %16, -2
%24 = lshr exact i64 %23, 1
%25 = add nuw i64 %24, 1
%26 = and i64 %25, 1
%27 = icmp eq i64 %23, 0
br i1 %27, label %58, label %28
28: ; preds = %15
%29 = and i64 %25, -2
br label %30
30: ; preds = %30, %28
%31 = phi i64 [ 0, %28 ], [ %52, %30 ]
%32 = phi <2 x i32> [ <i32 0, i32 1>, %28 ], [ %53, %30 ]
%33 = phi i64 [ 0, %28 ], [ %54, %30 ]
%34 = sitofp <2 x i32> %32 to <2 x double>
%35 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> <double 5.000000e-01, double 5.000000e-01>, <2 x double> %34)
%36 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %35)
%37 = fneg <2 x double> %36
%38 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> <double 5.000000e-01, double 5.000000e-01>, <2 x double> %37)
%39 = fmul <2 x double> %22, %38
%40 = getelementptr inbounds double, double* %0, i64 %31
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> %39, <2 x double>* %41
%42 = or i64 %31, 2
%43 = add <2 x i32> %32, <i32 2, i32 2>
%44 = sitofp <2 x i32> %43 to <2 x double>
%45 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> <double 5.000000e-01, double 5.000000e-01>, <2 x double> %44)
%46 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %45)
%47 = fneg <2 x double> %46
%48 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> <double 5.000000e-01, double 5.000000e-01>, <2 x double> %47)
%49 = fmul <2 x double> %22, %48
%50 = getelementptr inbounds double, double* %0, i64 %42
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %49, <2 x double>* %51
%52 = add nuw i64 %31, 4
%53 = add <2 x i32> %32, <i32 4, i32 4>
%54 = add nuw i64 %33, 2
%55 = icmp eq i64 %54, %29
br i1 %55, label %56, label %30
56: ; preds = %30
%57 = sitofp <2 x i32> %53 to <2 x double>
br label %58
58: ; preds = %56, %15
%59 = phi i64 [ 0, %15 ], [ %52, %56 ]
%60 = phi <2 x double> [ <double 0.000000e+00, double 1.000000e+00>, %15 ], [ %57, %56 ]
%61 = icmp eq i64 %26, 0
br i1 %61, label %70, label %62
62: ; preds = %58
%63 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> <double 5.000000e-01, double 5.000000e-01>, <2 x double> %60)
%64 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %63)
%65 = fneg <2 x double> %64
%66 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> <double 5.000000e-01, double 5.000000e-01>, <2 x double> %65)
%67 = fmul <2 x double> %22, %66
%68 = getelementptr inbounds double, double* %0, i64 %59
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> %67, <2 x double>* %69
br label %70
70: ; preds = %58, %62
%71 = icmp eq i64 %16, %13
br i1 %71, label %86, label %72
72: ; preds = %10, %70
%73 = phi i64 [ 0, %10 ], [ %16, %70 ]
br label %74
74: ; preds = %72, %74
%75 = phi i64 [ %84, %74 ], [ %73, %72 ]
%76 = trunc i64 %75 to i32
%77 = sitofp i32 %76 to double
%78 = tail call double @llvm.fmuladd.f64(double %12, double 5.000000e-01, double %77)
%79 = tail call double @llvm.fabs.f64(double %78)
%80 = fneg double %79
%81 = tail call double @llvm.fmuladd.f64(double %8, double 5.000000e-01, double %80)
%82 = fmul double %11, %81
%83 = getelementptr inbounds double, double* %0, i64 %75
store double %82, double* %83
%84 = add nuw nsw i64 %75, 1
%85 = icmp eq i64 %84, %13
br i1 %85, label %86, label %74
86: ; preds = %74, %70, %3
ret void
}