#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 /*<<< orphan*/ exit(int);
double exp(double);
int /*<<< orphan*/ printf(char *);
double sqrt(int);
double normalpdf(double x, double mu, double sigma) {
  double oup, t;
  if (sigma < 0.) {
    printf("Standard Deviation (Sigma) must be non-negative");
    exit(1);
  }
  t = x - mu;
  t = t * t;
  oup = exp(-t / (2 * sigma * sigma)) /
        (sqrt(2 * 3.14159265358979323846264338327950288) * sigma);
  return oup;
}


x86 assembly (clang, -O0):
<normalpdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    117b <normalpdf+0x3b>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe43(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalpdf>:
sub    $0x18,%rsp
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm3
ja     11aa <normalpdf+0x6a>
subsd  %xmm1,%xmm0
movapd 0xea6(%rip),%xmm1
xorpd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  %xmm2,0x10(%rsp)
call   1040 <exp@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"Standard Deviation (Sigma) must be non-negative\00"
define double @normalpdf(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %6
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %3
%15 = load double, double* %4
%16 = load double, double* %5
%17 = fsub double %15, %16
store double %17, double* %8
%18 = load double, double* %8
%19 = load double, double* %8
%20 = fmul double %18, %19
store double %20, double* %8
%21 = load double, double* %8
%22 = fneg double %21
%23 = load double, double* %6
%24 = fmul double 2.000000e+00, %23
%25 = load double, double* %6
%26 = fmul double %24, %25
%27 = fdiv double %22, %26
%28 = call double @exp(double %27)
%29 = call double @sqrt(i32 6)
%30 = load double, double* %6
%31 = fmul double %29, %30
%32 = fdiv double %28, %31
store double %32, double* %7
%33 = load double, double* %7
ret double %33
}

LLVM IR (-O2):
@.str = [48 x i8] c"Standard Deviation (Sigma) must be non-negative\00"
define double @normalpdf(double %0, double %1, double %2) {
%4 = fcmp olt double %2, 0.000000e+00
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %3
%9 = fsub double %0, %1
%10 = fneg double %9
%11 = fmul double %9, %10
%12 = fmul double %2, 2.000000e+00
%13 = fmul double %12, %2
%14 = fdiv double %11, %13
%15 = tail call double @exp(double %14)
%16 = tail call double @sqrt(i32 6)
%17 = fmul double %16, %2
%18 = fdiv double %15, %17
ret double %18
}