#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 */
int cos(double);
void dspl_win_hann(double *w, int n, int win_type) {
  double x = 0.0;
  double y;
  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.5 * (1 - cos(y));
    y += x;
  }
}


x86 assembly (clang, -O0):
<dspl_win_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,-0x18(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    1156 <dspl_win_hann+0x46>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xeb3(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x100,%eax
jne    117f <dspl_win_hann+0x6f>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe8a(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e7 <dspl_win_hann+0xd7>
movsd  -0x20(%rbp),%xmm0
call   1030 <cos@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe4f(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118e <dspl_win_hann+0x7e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_hann>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    1217 <dspl_win_hann+0x107>
mov    %rdi,%r15
mov    %esi,%r14d
cmp    $0x1,%esi
jne    1139 <dspl_win_hann+0x29>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    11f0 <dspl_win_hann+0xe0>
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,0x10(%rsp)
mov    %r14d,%r12d
and    $0xfffffffe,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  0xe71(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xe34(%rip),%xmm0
movsd  %xmm0,0x8(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1170 <dspl_win_hann+0x60>
test   $0x1,%r14b
je     1217 <dspl_win_hann+0x107>
call   1030 <cos@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xdf7(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @dspl_win_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* %7
%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* %7
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* %7
br label %26
26: ; preds = %22, %18
store double 0.000000e+00, double* %8
store i32 0, i32* %9
br label %27
27: ; preds = %44, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %5
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %47
31: ; preds = %27
%32 = load double, double* %8
%33 = call i32 @cos(double %32)
%34 = sub nsw i32 1, %33
%35 = sitofp i32 %34 to double
%36 = fmul double 5.000000e-01, %35
%37 = load double*, double** %4
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %36, double* %40
%41 = load double, double* %7
%42 = load double, double* %8
%43 = fadd double %42, %41
store double %43, double* %8
br label %44
44: ; preds = %31
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %27
47: ; preds = %27
ret void
}

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