#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);
double pow(double, int);
void gauss(double *window, const int N, const double sd) {
  int n;
  const double M = N - 1;
  double num, den, exponent;
  for (n = 0; n < N; n++) {
    num = n - M / 2.0;
    den = sd * M / 2.0;
    exponent = -0.5 * pow(num / den, 2);
    window[n] = exp(exponent);
  }
}


x86 assembly (clang, -O0):
<gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dd <gauss+0xbd>
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xea0(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe51(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <exp@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <gauss+0x2a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauss>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    1198 <gauss+0x78>
mov    %rdi,%r14
lea    -0x1(%rsi),%eax
cvtsi2sd %eax,%xmm2
movsd  0xec1(%rip),%xmm1
movapd %xmm2,%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
mulsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %esi,%r15d
xor    %ebx,%ebx
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
subsd  (%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mulsd  0xe84(%rip),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <gauss+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @gauss(double* %0, i32 %1, double %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store double %2, double* %6
%12 = load i32, i32* %5
%13 = sub nsw i32 %12, 1
%14 = sitofp i32 %13 to double
store double %14, double* %8
store i32 0, i32* %7
br label %15
15: ; preds = %40, %3
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %43
19: ; preds = %15
%20 = load i32, i32* %7
%21 = sitofp i32 %20 to double
%22 = load double, double* %8
%23 = fdiv double %22, 2.000000e+00
%24 = fsub double %21, %23
store double %24, double* %9
%25 = load double, double* %6
%26 = load double, double* %8
%27 = fmul double %25, %26
%28 = fdiv double %27, 2.000000e+00
store double %28, double* %10
%29 = load double, double* %9
%30 = load double, double* %10
%31 = fdiv double %29, %30
%32 = call double @pow(double %31, i32 2)
%33 = fmul double -5.000000e-01, %32
store double %33, double* %11
%34 = load double, double* %11
%35 = call double @exp(double %34)
%36 = load double*, double** %4
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double %35, double* %39
br label %40
40: ; preds = %19
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %15
43: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @gauss(double* nocapture writeonly %0, i32 %1, double %2) {
%4 = add nsw i32 %1, -1
%5 = sitofp i32 %4 to double
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %24
7: ; preds = %3
%8 = fmul double %5, 5.000000e-01
%9 = fmul double %5, %2
%10 = fmul double %9, 5.000000e-01
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %22, %12 ]
%14 = trunc i64 %13 to i32
%15 = sitofp i32 %14 to double
%16 = fsub double %15, %8
%17 = fdiv double %16, %10
%18 = tail call double @pow(double %17, i32 2)
%19 = fmul double %18, -5.000000e-01
%20 = tail call double @exp(double %19)
%21 = getelementptr inbounds double, double* %0, i64 %13
store double %20, double* %21
%22 = add nuw nsw i64 %13, 1
%23 = icmp eq i64 %22, %11
br i1 %23, label %24, label %12
24: ; preds = %12, %3
ret void
}