#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);
scalar_t__ malloc(int);
double *smileDsp_winHan(long _N) {
  double i;
  double *ret = (double *)malloc(sizeof(double) * _N);
  double *x = ret;
  double NN = (double)_N;
  for (i = 0.0; i < NN; i += 1.0) {
    *x = 0.5 * (1.0 - cos((2.0 * 3.14159265358979323846264338327950288 * i) /
                          (NN - 1.0)));
    x++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<smileDsp_winHan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d8 <smileDsp_winHan+0xb8>
movsd  0xe9a(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe80(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
movsd  0xe6b(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe57(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
movsd  0xe3f(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    115a <smileDsp_winHan+0x3a>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smileDsp_winHan>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0x0(,%rdi,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r14
test   %rbx,%rbx
jle    11cd <smileDsp_winHan+0xad>
cvtsi2sd %rbx,%xmm0
movsd  0xeb1(%rip),%xmm1
movsd  %xmm0,0x10(%rsp)
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xorpd  %xmm0,%xmm0
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xe86(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0xe7b(%rip),%xmm2
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe73(%rip),%xmm1
movsd  %xmm1,(%rbx)
add    $0x8,%rbx
movsd  (%rsp),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
ucomisd (%rsp),%xmm0
movsd  (%rsp),%xmm0
ja     1170 <smileDsp_winHan+0x50>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @smileDsp_winHan(i64 %0) {
%2 = alloca i64
%3 = alloca double
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
store i64 %0, i64* %2
%7 = load i64, i64* %2
%8 = mul i64 8, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to double*
store double* %11, double** %4
%12 = load double*, double** %4
store double* %12, double** %5
%13 = load i64, i64* %2
%14 = sitofp i64 %13 to double
store double %14, double* %6
store double 0.000000e+00, double* %3
br label %15
15: ; preds = %31, %1
%16 = load double, double* %3
%17 = load double, double* %6
%18 = fcmp olt double %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load double, double* %3
%21 = fmul double 0x401921FB54442D18, %20
%22 = load double, double* %6
%23 = fsub double %22, 1.000000e+00
%24 = fdiv double %21, %23
%25 = call double @cos(double %24)
%26 = fsub double 1.000000e+00, %25
%27 = fmul double 5.000000e-01, %26
%28 = load double*, double** %5
store double %27, double* %28
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i32 1
store double* %30, double** %5
br label %31
31: ; preds = %19
%32 = load double, double* %3
%33 = fadd double %32, 1.000000e+00
store double %33, double* %3
br label %15
34: ; preds = %15
%35 = load double*, double** %4
ret double* %35
}

LLVM IR (-O2):
define double* @smileDsp_winHan(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = shl i32 %2, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to double*
%6 = sitofp i64 %0 to double
%7 = icmp sgt i64 %0, 0
br i1 %7, label %8, label %21
8: ; preds = %1
%9 = fadd double %6, -1.000000e+00
br label %10
10: ; preds = %8, %10
%11 = phi double [ 0.000000e+00, %8 ], [ %19, %10 ]
%12 = phi double* [ %5, %8 ], [ %18, %10 ]
%13 = fmul double %11, 0x401921FB54442D18
%14 = fdiv double %13, %9
%15 = tail call double @cos(double %14)
%16 = fsub double 1.000000e+00, %15
%17 = fmul double %16, 5.000000e-01
store double %17, double* %12
%18 = getelementptr inbounds double, double* %12, i64 1
%19 = fadd double %11, 1.000000e+00
%20 = fcmp olt double %19, %6
br i1 %20, label %10, label %21
21: ; preds = %10, %1
ret double* %5
}