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


x86 assembly (clang, -O0):
<hamming>:
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 <hamming+0x7f>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xec2(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  0xe9c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe98(%rip),%xmm1
addsd  %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 <hamming+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamming>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1214 <hamming+0x104>
mov    %rdi,%r14
lea    -0x1(%rsi),%eax
cvtsi2sd %eax,%xmm0
mov    %esi,%r15d
cmp    $0x1,%esi
jne    1143 <hamming+0x33>
xor    %ebx,%ebx
test   $0x1,%r15b
jne    11e2 <hamming+0xd2>
jmp    1214 <hamming+0x104>
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
mulsd  %xmm1,%xmm0
movsd  0xe7f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe53(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xe49(%rip),%xmm0
addsd  0xe49(%rip),%xmm0
movsd  %xmm0,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %r12,%rbx
jne    1160 <hamming+0x50>
movsd  (%rsp),%xmm0
test   $0x1,%r15b
je     1214 <hamming+0x104>
movapd %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe0b(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0xe02(%rip),%xmm0
addsd  0xe02(%rip),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hamming(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 = %26, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %29
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 = call double @llvm.fmuladd.f64(double -4.616400e-01, double %20, double 5.383600e-01)
%22 = load double*, double** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
store double %21, double* %25
br label %26
26: ; preds = %14
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %10
29: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @hamming(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 %44
6: ; preds = %2
%7 = zext i32 %1 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %1, 1
br i1 %9, label %33, label %10
10: ; preds = %6
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %30, %12 ]
%14 = phi i64 [ 0, %10 ], [ %31, %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 = tail call double @llvm.fmuladd.f64(double %19, double -4.616400e-01, double 5.383600e-01)
%21 = getelementptr inbounds double, double* %0, i64 %13
store double %20, double* %21
%22 = or i64 %13, 1
%23 = trunc i64 %22 to i32
%24 = sitofp i32 %23 to double
%25 = fmul double %24, 0x401921FB54442D18
%26 = fdiv double %25, %4
%27 = tail call double @cos(double %26)
%28 = tail call double @llvm.fmuladd.f64(double %27, double -4.616400e-01, double 5.383600e-01)
%29 = getelementptr inbounds double, double* %0, i64 %22
store double %28, double* %29
%30 = add nuw nsw i64 %13, 2
%31 = add i64 %14, 2
%32 = icmp eq i64 %31, %11
br i1 %32, label %33, label %12
33: ; preds = %12, %6
%34 = phi i64 [ 0, %6 ], [ %30, %12 ]
%35 = icmp eq i64 %8, 0
br i1 %35, label %44, label %36
36: ; preds = %33
%37 = trunc i64 %34 to i32
%38 = sitofp i32 %37 to double
%39 = fmul double %38, 0x401921FB54442D18
%40 = fdiv double %39, %4
%41 = tail call double @cos(double %40)
%42 = tail call double @llvm.fmuladd.f64(double %41, double -4.616400e-01, double 5.383600e-01)
%43 = getelementptr inbounds double, double* %0, i64 %34
store double %42, double* %43
br label %44
44: ; preds = %36, %33, %2
ret void
}