#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 cosf(int);
void hanning_window(float Sn[], float Wn[], int Nsam) {
  int i;
  for (i = 0; i < Nsam; i++)
    Wn[i] = Sn[i] * (0.5 - 0.5 * cosf(2 * 3.141592654 * (float)i / (Nsam - 1)));
}


x86 assembly (clang, -O0):
<hanning_window>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bb <hanning_window+0xab>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xeb3(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cosf@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe78(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe74(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <hanning_window+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hanning_window>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    119b <hanning_window+0x8b>
mov    %rsi,%r14
mov    %rdi,%r15
lea    -0x1(%rdx),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movss  (%r15,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe9d(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cosf@plt>
mulsd  0xe8e(%rip),%xmm0
addsd  0xe8e(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <hanning_window+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hanning_window(float* %0, float* %1, i32 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %36, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %39
12: ; preds = %8
%13 = load float*, float** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds float, float* %13, i64 %15
%17 = load float, float* %16
%18 = fpext float %17 to double
%19 = load i32, i32* %7
%20 = sitofp i32 %19 to float
%21 = fpext float %20 to double
%22 = fmul double 0x401921FB54524550, %21
%23 = load i32, i32* %6
%24 = sub nsw i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fdiv double %22, %25
%27 = fptosi double %26 to i32
%28 = call double @cosf(i32 %27)
%29 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %28, double 5.000000e-01)
%30 = fmul double %18, %29
%31 = fptrunc double %30 to float
%32 = load float*, float** %5
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds float, float* %32, i64 %34
store float %31, float* %35
br label %36
36: ; preds = %12
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %8
39: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @hanning_window(float* nocapture %0, float* nocapture writeonly %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %27
5: ; preds = %3
%6 = add nsw i32 %2, -1
%7 = sitofp i32 %6 to double
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %25, %9 ]
%11 = getelementptr inbounds float, float* %0, i64 %10
%12 = load float, float* %11
%13 = fpext float %12 to double
%14 = trunc i64 %10 to i32
%15 = sitofp i32 %14 to float
%16 = fpext float %15 to double
%17 = fmul double %16, 0x401921FB54524550
%18 = fdiv double %17, %7
%19 = fptosi double %18 to i32
%20 = tail call double @cosf(i32 %19)
%21 = tail call double @llvm.fmuladd.f64(double %20, double -5.000000e-01, double 5.000000e-01)
%22 = fmul double %21, %13
%23 = fptrunc double %22 to float
%24 = getelementptr inbounds float, float* %1, i64 %10
store float %23, float* %24
%25 = add nuw nsw i64 %10, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %9
27: ; preds = %9, %3
ret void
}