#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 exp(double);
scalar_t__ malloc(int);
double *smileDsp_winGau(long _N, double sigma) {
  double i;
  double *ret = (double *)malloc(sizeof(double) * _N);
  double *x = ret;
  double NN = (double)_N;
  double tmp;
  if (sigma <= 0.0)
    sigma = 0.01;
  if (sigma > 0.5)
    sigma = 0.5;
  for (i = 0.0; i < NN; i += 1.0) {
    tmp = (i - (NN - 1.0) / 2.0) / (sigma * (NN - 1.0) / 2.0);
    *x = exp(-0.5 * (tmp * tmp));
    x++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<smileDsp_winGau>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1172 <smileDsp_winGau+0x52>
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1196 <smileDsp_winGau+0x76>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    124d <smileDsp_winGau+0x12d>
movsd  -0x18(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xe5c(%rip),%xmm2
subsd  %xmm2,%xmm1
movsd  0xe48(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  0xe36(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe1e(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  0xdf7(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
movsd  0xde2(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119e <smileDsp_winGau+0x7e>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smileDsp_winGau>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movapd %xmm0,(%rsp)
mov    %rdi,%rbx
lea    0x0(,%rdi,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r14
test   %rbx,%rbx
jle    1207 <smileDsp_winGau+0xe7>
cvtsi2sd %rbx,%xmm3
xorpd  %xmm4,%xmm4
movapd (%rsp),%xmm2
movapd %xmm2,%xmm0
cmpnlesd %xmm4,%xmm0
andpd  %xmm0,%xmm2
movsd  0xe96(%rip),%xmm1
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
movsd  0xe8e(%rip),%xmm1
movapd %xmm1,%xmm2
minsd  %xmm0,%xmm2
movsd  0xe86(%rip),%xmm0
movsd  %xmm3,0x20(%rsp)
addsd  %xmm3,%xmm0
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm3,0x10(%rsp)
mulsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm4,(%rsp)
movapd %xmm4,%xmm0
subsd  0x10(%rsp),%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  %xmm0,%xmm0
mulsd  0xe37(%rip),%xmm0
call   1040 <exp@plt>
movsd  (%rsp),%xmm4
movsd  %xmm0,(%rbx)
add    $0x8,%rbx
addsd  0xe25(%rip),%xmm4
movsd  0x20(%rsp),%xmm0
ucomisd %xmm4,%xmm0
ja     11c0 <smileDsp_winGau+0xa0>
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @smileDsp_winGau(i64 %0, double %1) {
%3 = alloca i64
%4 = alloca double
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
store i64 %0, i64* %3
store double %1, double* %4
%10 = load i64, i64* %3
%11 = mul i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to double*
store double* %14, double** %6
%15 = load double*, double** %6
store double* %15, double** %7
%16 = load i64, i64* %3
%17 = sitofp i64 %16 to double
store double %17, double* %8
%18 = load double, double* %4
%19 = fcmp ole double %18, 0.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %2
store double 1.000000e-02, double* %4
br label %21
21: ; preds = %20, %2
%22 = load double, double* %4
%23 = fcmp ogt double %22, 5.000000e-01
br i1 %23, label %24, label %25
24: ; preds = %21
store double 5.000000e-01, double* %4
br label %25
25: ; preds = %24, %21
store double 0.000000e+00, double* %5
br label %26
26: ; preds = %50, %25
%27 = load double, double* %5
%28 = load double, double* %8
%29 = fcmp olt double %27, %28
br i1 %29, label %30, label %53
30: ; preds = %26
%31 = load double, double* %5
%32 = load double, double* %8
%33 = fsub double %32, 1.000000e+00
%34 = fdiv double %33, 2.000000e+00
%35 = fsub double %31, %34
%36 = load double, double* %4
%37 = load double, double* %8
%38 = fsub double %37, 1.000000e+00
%39 = fmul double %36, %38
%40 = fdiv double %39, 2.000000e+00
%41 = fdiv double %35, %40
store double %41, double* %9
%42 = load double, double* %9
%43 = load double, double* %9
%44 = fmul double %42, %43
%45 = fmul double -5.000000e-01, %44
%46 = call double @exp(double %45)
%47 = load double*, double** %7
store double %46, double* %47
%48 = load double*, double** %7
%49 = getelementptr inbounds double, double* %48, i32 1
store double* %49, double** %7
br label %50
50: ; preds = %30
%51 = load double, double* %5
%52 = fadd double %51, 1.000000e+00
store double %52, double* %5
br label %26
53: ; preds = %26
%54 = load double*, double** %6
ret double* %54
}

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