#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 M_PI;
double cos(float);
void af_window_hamming(int n, float *w) {
  int i;
  float k = 2 * M_PI / ((float)(n - 1));
  for (i = 0; i < n; i++)
    *w++ = 0.54 - 0.46 * cos(k * (float)i);
}


x86 assembly (clang, -O0):
<af_window_hamming>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm0
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a5 <af_window_hamming+0x95>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
mulss  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  0xe90(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
movss  %xmm0,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <af_window_hamming+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<af_window_hamming>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1203 <af_window_hamming+0xf3>
mov    %rsi,%r15
mov    %edi,%r14d
mov    0x2ebc(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
cvtsi2ss %eax,%xmm1
lea    -0x1(%r14),%eax
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cmp    $0x1,%edi
je     11d8 <af_window_hamming+0xc8>
mov    %r14d,%ebp
and    $0xfffffffe,%ebp
xor    %ebx,%ebx
movss  %xmm1,0x4(%rsp)
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  0xe88(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe84(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x4(%rsp),%xmm0
call   1030 <cos@plt>
movss  0x4(%rsp),%xmm1
mulsd  0xe4c(%rip),%xmm0
addsd  0xe4c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%r15)
add    $0x8,%r15
add    $0x2,%ebx
cmp    %ebp,%ebx
jne    1160 <af_window_hamming+0x50>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
test   $0x1,%r14b
je     1203 <af_window_hamming+0xf3>
mulss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0xe0e(%rip),%xmm0
addsd  0xe0e(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define void @af_window_hamming(i32 %0, float* %1) {
%3 = alloca i32
%4 = alloca float*
%5 = alloca i32
%6 = alloca float
store i32 %0, i32* %3
store float* %1, float** %4
%7 = load i32, i32* @M_PI
%8 = mul nsw i32 2, %7
%9 = sitofp i32 %8 to float
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 1
%12 = sitofp i32 %11 to float
%13 = fdiv float %9, %12
store float %13, float* %6
store i32 0, i32* %5
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = load float, float* %6
%20 = load i32, i32* %5
%21 = sitofp i32 %20 to float
%22 = fmul float %19, %21
%23 = call double @cos(float %22)
%24 = call double @llvm.fmuladd.f64(double -4.600000e-01, double %23, double 5.400000e-01)
%25 = fptrunc double %24 to float
%26 = load float*, float** %4
%27 = getelementptr inbounds float, float* %26, i32 1
store float* %27, float** %4
store float %25, float* %26
br label %28
28: ; preds = %18
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %14
31: ; preds = %14
ret void
}

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