#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(int);
int llz_hamming(double *w, const int N) {
  int i, j;
  for (i = 0, j = N - 1; i <= j; i++, j--) {
    w[i] =
        (double)(0.54 - 0.46 * cos(2 * 3.14159265358979323846 * i / (N - 1)));
    w[j] = w[i];
  }
  return N;
}


x86 assembly (clang, -O0):
<llz_hamming>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11b9 <llz_hamming+0xa9>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xec8(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  0xe95(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe91(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <llz_hamming+0x1f>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llz_hamming>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
test   %esi,%esi
jle    118e <llz_hamming+0x7e>
mov    %rdi,%r15
lea    -0x1(%r14),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
mov    %r14d,%r12d
add    $0xfffffffffffffffe,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xeb1(%rip),%xmm0
divsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0xea3(%rip),%xmm0
addsd  0xea3(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  %xmm0,0x8(%r15,%r12,8)
lea    0x1(%rbx),%rax
lea    -0x1(%r12),%rcx
cmp    %r12,%rbx
mov    %rcx,%r12
mov    %rax,%rbx
jl     1140 <llz_hamming+0x30>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @llz_hamming(double* nocapture writeonly %0, i32 returned %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %24, label %4
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = sitofp i32 %5 to double
%7 = zext i32 %1 to i64
%8 = add nsw i64 %7, -1
br label %9
9: ; preds = %4, %9
%10 = phi i64 [ 0, %4 ], [ %21, %9 ]
%11 = phi i64 [ %8, %4 ], [ %22, %9 ]
%12 = trunc i64 %10 to i32
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 0x401921FB54442D18
%15 = fdiv double %14, %6
%16 = fptosi double %15 to i32
%17 = tail call double @cos(i32 %16)
%18 = tail call double @llvm.fmuladd.f64(double %17, double -4.600000e-01, double 5.400000e-01)
%19 = getelementptr inbounds double, double* %0, i64 %10
store double %18, double* %19
%20 = getelementptr inbounds double, double* %0, i64 %11
store double %18, double* %20
%21 = add nuw nsw i64 %10, 1
%22 = add nsw i64 %11, -1
%23 = icmp slt i64 %10, %22
br i1 %23, label %9, label %24
24: ; preds = %9, %2
ret i32 %1
}