#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 hann(double *window, const int N) {
  int n;
  const double M = N - 1;
  for (n = 0; n < N; n++)
    window[n] =
        0.5 *
        (1.0 - cos(2.0 * 3.14159265358979323846264338327 * (double)n / M));
}


x86 assembly (clang, -O0):
<hann>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118f <hann+0x7f>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xec2(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  0xea4(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe90(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1135 <hann+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hann>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    121c <hann+0x10c>
mov    %rdi,%r14
lea    -0x1(%rsi),%eax
cvtsi2sd %eax,%xmm0
mov    %esi,%r15d
cmp    $0x1,%esi
jne    1143 <hann+0x33>
xor    %ebx,%ebx
test   $0x1,%r15b
jne    11e6 <hann+0xd6>
jmp    121c <hann+0x10c>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xe91(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
movsd  0xe83(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe7f(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe53(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
movsd  0xe49(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe45(%rip),%xmm1
movsd  %xmm1,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %r12,%rbx
jne    1160 <hann+0x50>
movsd  (%rsp),%xmm0
test   $0x1,%r15b
je     121c <hann+0x10c>
movapd %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe07(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  0xdfe(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xdfa(%rip),%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hann(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = sub nsw i32 %7, 1
%9 = sitofp i32 %8 to double
store double %9, double* %6
store i32 0, i32* %5
br label %10
10: ; preds = %27, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to double
%17 = fmul double 0x401921FB54442D18, %16
%18 = load double, double* %6
%19 = fdiv double %17, %18
%20 = call double @cos(double %19)
%21 = fsub double 1.000000e+00, %20
%22 = fmul double 5.000000e-01, %21
%23 = load double*, double** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
br label %27
27: ; preds = %14
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %10
30: ; preds = %10
ret void
}

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