#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 */
int M_PI;
double exp(double);
double pow(int, int);
int sqrt(int);
void Gaussian_probability_function(double *probs, int size, int mean,
                                   int sigma) {
  double xd, yd;
  int i;
  xd = 1 / (sigma * sqrt(2 * M_PI));
  yd = -(1 / (2 * pow(sigma, 2)));
  for (i = 0; i < size; i++)
    probs[i] = xd * exp(pow((i - mean), 2) * yd);
  return;
}


x86 assembly (clang, -O0):
<Gaussian_probability_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
shl    $0x1,%edi
call   1050 <sqrt@plt>
mov    -0x30(%rbp),%ecx
imul   %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
movsd  0xe80(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe6c(%rip),%xmm0
divsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1212 <Gaussian_probability_function+0xe2>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
sub    -0x10(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11bb <Gaussian_probability_function+0x8b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Gaussian_probability_function>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r14
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
add    %edi,%edi
call   1050 <sqrt@plt>
imul   %ebp,%eax
lea    0x1(%rax),%ecx
xor    %ebx,%ebx
cmp    $0x3,%ecx
cmovb  %eax,%ebx
mov    %ebp,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
test   %r15d,%r15d
jle    11cd <Gaussian_probability_function+0x9d>
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,0x8(%rsp)
addsd  %xmm0,%xmm0
movsd  0xe74(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %r15d,%ebp
neg    %r12d
xor    %ebx,%ebx
nopl   (%rax)
lea    (%r12,%rbx,1),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
call   1030 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <Gaussian_probability_function+0x70>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@M_PI = global i32 0
define void @Gaussian_probability_function(double* nocapture writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = load i32, i32* @M_PI
%6 = shl nsw i32 %5, 1
%7 = tail call i32 @sqrt(i32 %6)
%8 = mul nsw i32 %7, %3
%9 = add i32 %8, 1
%10 = icmp ult i32 %9, 3
%11 = select i1 %10, i32 %8, i32 0
%12 = sitofp i32 %11 to double
%13 = tail call double @pow(i32 %3, i32 2)
%14 = fmul double %13, 2.000000e+00
%15 = fdiv double -1.000000e+00, %14
%16 = icmp sgt i32 %1, 0
br i1 %16, label %17, label %30
17: ; preds = %4
%18 = zext i32 %1 to i64
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 0, %17 ], [ %28, %19 ]
%21 = trunc i64 %20 to i32
%22 = sub nsw i32 %21, %2
%23 = tail call double @pow(i32 %22, i32 2)
%24 = fmul double %15, %23
%25 = tail call double @exp(double %24)
%26 = fmul double %25, %12
%27 = getelementptr inbounds double, double* %0, i64 %20
store double %26, double* %27
%28 = add nuw nsw i64 %20, 1
%29 = icmp eq i64 %28, %18
br i1 %29, label %30, label %19
30: ; preds = %19, %4
ret void
}