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


x86 assembly (clang, -O0):
<fa_blackman>:
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     11ff <fa_blackman+0xef>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xed8(%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  0xea5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea1(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe7b(%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  -0x20(%rbp),%xmm1
movsd  0xe4b(%rip),%xmm2
mulsd  %xmm2,%xmm0
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_blackman+0x1f>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fa_blackman>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
test   %esi,%esi
jle    11cc <fa_blackman+0xbc>
mov    %rdi,%r15
lea    -0x1(%r14),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
mov    %r14d,%r12d
add    $0xfffffffffffffffe,%r12
xor    %ebx,%ebx
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x10(%rsp)
mulsd  0xeab(%rip),%xmm0
divsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0xe9d(%rip),%xmm0
addsd  0xe9d(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe91(%rip),%xmm0
divsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0xe83(%rip),%xmm0
addsd  0x8(%rsp),%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_blackman+0x30>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @fa_blackman(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 = %48, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %53
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 -5.000000e-01, double %22, double 4.200000e-01)
%24 = load i32, i32* %5
%25 = sitofp i32 %24 to double
%26 = fmul double 0x402921FB54442D18, %25
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = sitofp i32 %28 to double
%30 = fdiv double %26, %29
%31 = fptosi double %30 to i32
%32 = call double @cos(i32 %31)
%33 = call double @llvm.fmuladd.f64(double 8.000000e-02, double %32, double %23)
%34 = fptrunc double %33 to float
%35 = load float*, float** %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds float, float* %35, i64 %37
store float %34, float* %38
%39 = load float*, float** %3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %39, i64 %41
%43 = load float, float* %42
%44 = load float*, float** %3
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds float, float* %44, i64 %46
store float %43, float* %47
br label %48
48: ; preds = %13
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
%51 = load i32, i32* %6
%52 = add nsw i32 %51, -1
store i32 %52, i32* %6
br label %9
53: ; preds = %9
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
define i32 @fa_blackman(float* nocapture writeonly %0, i32 returned %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %30, 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 ], [ %27, %9 ]
%11 = phi i64 [ %8, %4 ], [ %28, %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 -5.000000e-01, double 4.200000e-01)
%19 = fmul double %13, 0x402921FB54442D18
%20 = fdiv double %19, %6
%21 = fptosi double %20 to i32
%22 = tail call double @cos(i32 %21)
%23 = tail call double @llvm.fmuladd.f64(double %22, double 8.000000e-02, double %18)
%24 = fptrunc double %23 to float
%25 = getelementptr inbounds float, float* %0, i64 %10
store float %24, float* %25
%26 = getelementptr inbounds float, float* %0, i64 %11
store float %24, float* %26
%27 = add nuw nsw i64 %10, 1
%28 = add nsw i64 %11, -1
%29 = icmp slt i64 %10, %28
br i1 %29, label %9, label %30
30: ; preds = %9, %2
ret i32 %1
}