#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 flattop(int n, int N) {
  return (1 - 1.93 * cos(2 * 3.14 * (double)n / (double)(N - 1)) +
          1.29 * cos(4 * 3.14 * (double)n / (double)(N - 1)) -
          0.338 * cos(6 * 3.14 * (double)n / (double)(N - 1)) +
          0.028 * cos(8 * 3.14 * (double)n / (double)(N - 1)));
}


x86 assembly (clang, -O0):
<flattop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xf15(%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  0xee2(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xede(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xeb8(%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  -0x20(%rbp),%xmm1
movsd  0xe88(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe66(%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  0xe36(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe14(%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  0xde4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define double @flattop(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 -1.930000e+00, double %13, double 1.000000e+00)
%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.290000e+00, 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 -3.380000e-01, double %33, double %24)
%35 = load i32, i32* %3
%36 = sitofp i32 %35 to double
%37 = fmul double 2.512000e+01, %36
%38 = load i32, i32* %4
%39 = sub nsw i32 %38, 1
%40 = sitofp i32 %39 to double
%41 = fdiv double %37, %40
%42 = fptosi double %41 to i32
%43 = call double @cos(i32 %42)
%44 = call double @llvm.fmuladd.f64(double 2.800000e-02, double %43, double %34)
ret double %44
}

LLVM IR (-O2):
define double @flattop(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 -1.930000e+00, double 1.000000e+00)
%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.290000e+00, 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 -3.380000e-01, double %15)
%21 = fmul double %3, 2.512000e+01
%22 = fdiv double %21, %6
%23 = fptosi double %22 to i32
%24 = tail call double @cos(i32 %23)
%25 = tail call double @llvm.fmuladd.f64(double %24, double 2.800000e-02, double %20)
ret double %25
}