double normpdf(double x, double mu, double sig) {
  if (sig < 0)
    error("Parameter sig is smaller than 0.");
  return (0.3989422804014327 / sig) *
         exp(-0.5 * (x - mu) * (x - mu) / (sig) * (sig));
}


x86 assembly (clang, -O0):
<normpdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1153 <normpdf+0x33>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1040 <error@plt>
movsd  0xead(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe89(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normpdf>:
sub    $0x18,%rsp
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jbe    1162 <normpdf+0x42>
lea    0xed7(%rip),%rdi
xor    %eax,%eax
movsd  %xmm2,(%rsp)
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1040 <error@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
movsd  (%rsp),%xmm2
movsd  0xe96(%rip),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,(%rsp)
subsd  %xmm1,%xmm3
movsd  0xe89(%rip),%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Parameter sig is smaller than 0.\00"
define double @normpdf(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%7 = load double, double* %6
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %3
%12 = load double, double* %6
%13 = fdiv double 0x3FD9884533D43651, %12
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fsub double %14, %15
%17 = fmul double -5.000000e-01, %16
%18 = load double, double* %4
%19 = load double, double* %5
%20 = fsub double %18, %19
%21 = fmul double %17, %20
%22 = load double, double* %6
%23 = fdiv double %21, %22
%24 = load double, double* %6
%25 = fmul double %23, %24
%26 = call double @exp(double %25)
%27 = fmul double %13, %26
ret double %27
}

LLVM IR (-O2):
@.str = [33 x i8] c"Parameter sig is smaller than 0.\00"
define double @normpdf(double %0, double %1, double %2) {
%4 = fcmp olt double %2, 0.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = fdiv double 0x3FD9884533D43651, %2
%9 = fsub double %0, %1
%10 = fmul double %9, -5.000000e-01
%11 = fmul double %9, %10
%12 = fdiv double %11, %2
%13 = fmul double %12, %2
%14 = tail call double @exp(double %13)
%15 = fmul double %8, %14
ret double %15
}