#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(double);
void dspl_win_flat_top(double *w, int n, int win_type) {
  double y;
  double x = 0.0;
  double a0 = 1.0;
  double a1 = 1.93;
  double a2 = 1.29;
  double a3 = 0.388;
  double a4 = 0.032;
  int i;
  if ((win_type & 0x00000100) == 0x00000000)
    x = 6.283185307179586476925286766559 / (double)(n - 1);
  if ((win_type & 0x00000100) == 0x00000100)
    x = 6.283185307179586476925286766559 / (double)n;
  y = 0.0;
  for (i = 0; i < n; i++) {
    w[i] = a0 - a1 * cos(y) + a2 * cos(2.0 * y) - a3 * cos(3.0 * y) +
           a4 * cos(4.0 * y);
    y += x;
  }
}


x86 assembly (clang, -O0):
<dspl_win_flat_top>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeeb(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xed6(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xec1(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    119a <dspl_win_flat_top+0x8a>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe97(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x100,%eax
jne    11c3 <dspl_win_flat_top+0xb3>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe6e(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1317 <dspl_win_flat_top+0x207>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x90(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xdf5(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x80(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xdb7(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xd62(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11d2 <dspl_win_flat_top+0xc2>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_flat_top>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %esi,%esi
jle    1201 <dspl_win_flat_top+0xf1>
mov    %rdi,%r14
shr    $0x8,%edx
and    $0x1,%edx
lea    (%rdx,%rsi,1),%eax
add    $0xffffffff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xec4(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    %esi,%r15d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nop
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <cos@plt>
mulsd  0xe9f(%rip),%xmm0
addsd  0xe9f(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <cos@plt>
mulsd  0xe8a(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe78(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xe73(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe61(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xe5c(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <dspl_win_flat_top+0x40>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @dspl_win_flat_top(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %8
store double 1.000000e+00, double* %9
store double 1.930000e+00, double* %10
store double 1.290000e+00, double* %11
store double 3.880000e-01, double* %12
store double 3.200000e-02, double* %13
%15 = load i32, i32* %6
%16 = and i32 %15, 256
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %3
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = fdiv double 0x401921FB54442D18, %21
store double %22, double* %8
br label %23
23: ; preds = %18, %3
%24 = load i32, i32* %6
%25 = and i32 %24, 256
%26 = icmp eq i32 %25, 256
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* %5
%29 = sitofp i32 %28 to double
%30 = fdiv double 0x401921FB54442D18, %29
store double %30, double* %8
br label %31
31: ; preds = %27, %23
store double 0.000000e+00, double* %7
store i32 0, i32* %14
br label %32
32: ; preds = %66, %31
%33 = load i32, i32* %14
%34 = load i32, i32* %5
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %69
36: ; preds = %32
%37 = load double, double* %9
%38 = load double, double* %10
%39 = load double, double* %7
%40 = call double @cos(double %39)
%41 = fneg double %38
%42 = call double @llvm.fmuladd.f64(double %41, double %40, double %37)
%43 = load double, double* %11
%44 = load double, double* %7
%45 = fmul double 2.000000e+00, %44
%46 = call double @cos(double %45)
%47 = call double @llvm.fmuladd.f64(double %43, double %46, double %42)
%48 = load double, double* %12
%49 = load double, double* %7
%50 = fmul double 3.000000e+00, %49
%51 = call double @cos(double %50)
%52 = fneg double %48
%53 = call double @llvm.fmuladd.f64(double %52, double %51, double %47)
%54 = load double, double* %13
%55 = load double, double* %7
%56 = fmul double 4.000000e+00, %55
%57 = call double @cos(double %56)
%58 = call double @llvm.fmuladd.f64(double %54, double %57, double %53)
%59 = load double*, double** %4
%60 = load i32, i32* %14
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
store double %58, double* %62
%63 = load double, double* %8
%64 = load double, double* %7
%65 = fadd double %64, %63
store double %65, double* %7
br label %66
66: ; preds = %36
%67 = load i32, i32* %14
%68 = add nsw i32 %67, 1
store i32 %68, i32* %14
br label %32
69: ; preds = %32
ret void
}

LLVM IR (-O2):
define void @dspl_win_flat_top(double* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = lshr i32 %2, 8
%5 = and i32 %4, 1
%6 = add nsw i32 %5, -1
%7 = add nsw i32 %6, %1
%8 = sitofp i32 %7 to double
%9 = fdiv double 0x401921FB54442D18, %8
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %31
11: ; preds = %3
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %29, %13 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %28, %13 ]
%16 = tail call double @cos(double %15)
%17 = tail call double @llvm.fmuladd.f64(double %16, double -1.930000e+00, double 1.000000e+00)
%18 = fmul double %15, 2.000000e+00
%19 = tail call double @cos(double %18)
%20 = tail call double @llvm.fmuladd.f64(double %19, double 1.290000e+00, double %17)
%21 = fmul double %15, 3.000000e+00
%22 = tail call double @cos(double %21)
%23 = tail call double @llvm.fmuladd.f64(double %22, double -3.880000e-01, double %20)
%24 = fmul double %15, 4.000000e+00
%25 = tail call double @cos(double %24)
%26 = tail call double @llvm.fmuladd.f64(double %25, double 3.200000e-02, double %23)
%27 = getelementptr inbounds double, double* %0, i64 %14
store double %26, double* %27
%28 = fadd double %9, %15
%29 = add nuw nsw i64 %14, 1
%30 = icmp eq i64 %29, %12
br i1 %30, label %31, label %13
31: ; preds = %13, %3
ret void
}