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


x86 assembly (clang, -O0):
<fa_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     11bd <fa_hamming+0xad>
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
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <fa_hamming+0x1f>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fa_hamming>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
test   %esi,%esi
jle    1192 <fa_hamming+0x82>
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
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15,%rbx,4)
movss  %xmm0,0x4(%r15,%r12,4)
lea    0x1(%rbx),%rax
lea    -0x1(%r12),%rcx
cmp    %r12,%rbx
mov    %rcx,%r12
mov    %rax,%rbx
jl     1140 <fa_hamming+0x30>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @fa_hamming(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store float* %0, float** %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 = %38, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %43
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 = fptrunc double %23 to float
%25 = load float*, float** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %25, i64 %27
store float %24, float* %28
%29 = load float*, float** %3
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
%33 = load float, float* %32
%34 = load float*, float** %3
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds float, float* %34, i64 %36
store float %33, float* %37
br label %38
38: ; preds = %13
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
%41 = load i32, i32* %6
%42 = add nsw i32 %41, -1
store i32 %42, i32* %6
br label %9
43: ; preds = %9
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
define i32 @fa_hamming(float* nocapture writeonly %0, i32 returned %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %25, 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 ], [ %22, %9 ]
%11 = phi i64 [ %8, %4 ], [ %23, %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 = fptrunc double %18 to float
%20 = getelementptr inbounds float, float* %0, i64 %10
store float %19, float* %20
%21 = getelementptr inbounds float, float* %0, i64 %11
store float %19, float* %21
%22 = add nuw nsw i64 %10, 1
%23 = add nsw i64 %11, -1
%24 = icmp slt i64 %10, %23
br i1 %24, label %9, label %25
25: ; preds = %9, %2
ret i32 %1
}