#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 abs(double);
double cos(int);
double bartlett_hann(int n, int N) {
  return (0.62 - 0.48 * abs((double)n / (double)(N - 1) - 0.5) -
          0.38 * cos(2 * 3.14 * (double)n / (double)(N - 1)));
}


x86 assembly (clang, -O0):
<bartlett_hann>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  0xed7(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <abs@plt>
movsd  0xeb6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb2(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe8c(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
movsd  -0x10(%rbp),%xmm1
movsd  0xe5c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bartlett_hann>:
sub    $0x18,%rsp
cvtsi2sd %edi,%xmm0
movsd  %xmm0,(%rsp)
add    $0xffffffff,%esi
cvtsi2sd %esi,%xmm2
movsd  %xmm2,0x10(%rsp)
divsd  %xmm2,%xmm0
addsd  0xeba(%rip),%xmm0
call   1030 <abs@plt>
mulsd  0xeb5(%rip),%xmm0
addsd  0xeb5(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xeaa(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
mulsd  0xe9b(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @bartlett_hann(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = sitofp i32 %5 to double
%7 = load i32, i32* %4
%8 = sub nsw i32 %7, 1
%9 = sitofp i32 %8 to double
%10 = fdiv double %6, %9
%11 = fsub double %10, 5.000000e-01
%12 = call double @abs(double %11)
%13 = call double @llvm.fmuladd.f64(double -4.800000e-01, double %12, double 6.200000e-01)
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to double
%16 = fmul double 6.280000e+00, %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 -3.800000e-01, double %22, double %13)
ret double %23
}

LLVM IR (-O2):
define double @bartlett_hann(i32 %0, i32 %1) {
%3 = sitofp i32 %0 to double
%4 = add nsw i32 %1, -1
%5 = sitofp i32 %4 to double
%6 = fdiv double %3, %5
%7 = fadd double %6, -5.000000e-01
%8 = tail call double @abs(double %7)
%9 = tail call double @llvm.fmuladd.f64(double %8, double -4.800000e-01, double 6.200000e-01)
%10 = fmul double %3, 6.280000e+00
%11 = fdiv double %10, %5
%12 = fptosi double %11 to i32
%13 = tail call double @cos(i32 %12)
%14 = tail call double @llvm.fmuladd.f64(double %13, double -3.800000e-01, double %9)
ret double %14
}