#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);
double blackman_harris(int n, int N) {
  return (0.35875 - 0.48829 * cos(2 * 3.14 * (double)n / (double)(N - 1)) +
          0.14128 * cos(4 * 3.14 * (double)n / (double)(N - 1)) -
          0.01168 * cos(6 * 3.14 * (double)n / (double)(N - 1)));
}


x86 assembly (clang, -O0):
<blackman_harris>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xf05(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  0xed2(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xece(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xea8(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  -0x18(%rbp),%xmm1
movsd  0xe78(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe56(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  -0x10(%rbp),%xmm1
movsd  0xe26(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blackman_harris>:
sub    $0x18,%rsp
cvtsi2sd %edi,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xedb(%rip),%xmm0
add    $0xffffffff,%esi
cvtsi2sd %esi,%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0xebd(%rip),%xmm0
addsd  0xebd(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xeb7(%rip),%xmm0
mulsd  (%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0xea3(%rip),%xmm0
movsd  (%rsp),%xmm1
mulsd  0xe9e(%rip),%xmm1
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
divsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1030 <cos@plt>
mulsd  0xe84(%rip),%xmm0
addsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @blackman_harris(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 = fmul double 6.280000e+00, %6
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
%10 = sitofp i32 %9 to double
%11 = fdiv double %7, %10
%12 = fptosi double %11 to i32
%13 = call double @cos(i32 %12)
%14 = call double @llvm.fmuladd.f64(double -4.882900e-01, double %13, double 3.587500e-01)
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to double
%17 = fmul double 1.256000e+01, %16
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fdiv double %17, %20
%22 = fptosi double %21 to i32
%23 = call double @cos(i32 %22)
%24 = call double @llvm.fmuladd.f64(double 1.412800e-01, double %23, double %14)
%25 = load i32, i32* %3
%26 = sitofp i32 %25 to double
%27 = fmul double 1.884000e+01, %26
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 1
%30 = sitofp i32 %29 to double
%31 = fdiv double %27, %30
%32 = fptosi double %31 to i32
%33 = call double @cos(i32 %32)
%34 = call double @llvm.fmuladd.f64(double -1.168000e-02, double %33, double %24)
ret double %34
}

LLVM IR (-O2):
define double @blackman_harris(i32 %0, i32 %1) {
%3 = sitofp i32 %0 to double
%4 = fmul double %3, 6.280000e+00
%5 = add nsw i32 %1, -1
%6 = sitofp i32 %5 to double
%7 = fdiv double %4, %6
%8 = fptosi double %7 to i32
%9 = tail call double @cos(i32 %8)
%10 = tail call double @llvm.fmuladd.f64(double %9, double -4.882900e-01, double 3.587500e-01)
%11 = fmul double %3, 1.256000e+01
%12 = fdiv double %11, %6
%13 = fptosi double %12 to i32
%14 = tail call double @cos(i32 %13)
%15 = tail call double @llvm.fmuladd.f64(double %14, double 1.412800e-01, double %10)
%16 = fmul double %3, 1.884000e+01
%17 = fdiv double %16, %6
%18 = fptosi double %17 to i32
%19 = tail call double @cos(i32 %18)
%20 = tail call double @llvm.fmuladd.f64(double %19, double -1.168000e-02, double %15)
ret double %20
}