#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 dspl_win_hamming(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.54 - 0.46 * cos(y);
    y += x;
  }
}


x86 assembly (clang, -O0):
<dspl_win_hamming>:
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_hamming+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_hamming+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    11e6 <dspl_win_hamming+0xd6>
movsd  -0x20(%rbp),%xmm0
call   1030 <cos@plt>
movsd  0xe5c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm1
addsd  %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_hamming+0x7e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_hamming>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    1209 <dspl_win_hamming+0xf9>
mov    %rdi,%r15
mov    %esi,%r14d
cmp    $0x1,%esi
jne    1139 <dspl_win_hamming+0x29>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    11e8 <dspl_win_hamming+0xd8>
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>
movsd  0xe7f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe7b(%rip),%xmm1
addsd  %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>
mulsd  0xe44(%rip),%xmm0
addsd  0xe44(%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_hamming+0x60>
test   $0x1,%r14b
je     1209 <dspl_win_hamming+0xf9>
call   1030 <cos@plt>
mulsd  0xe0d(%rip),%xmm0
addsd  0xe0d(%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_hamming(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 = %42, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %5
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %45
31: ; preds = %27
%32 = load double, double* %8
%33 = call double @cos(double %32)
%34 = call double @llvm.fmuladd.f64(double -4.600000e-01, double %33, double 5.400000e-01)
%35 = load double*, double** %4
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
store double %34, double* %38
%39 = load double, double* %7
%40 = load double, double* %8
%41 = fadd double %40, %39
store double %41, double* %8
br label %42
42: ; preds = %31
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %27
45: ; preds = %27
ret void
}

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