#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*/ GHMM_LOG_PRINTF(int, char *, char *);
double exp(int);
int sqrt(int);
double ighmm_rand_normal_density(double x, double mean, double u) {
  double expo;
  if (u <= 0.0) {
    GHMM_LOG_PRINTF(
        2,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/lukefrasera/fatigueBSN/refs/heads/master/"
        "scripts/include/ghmm-0.9-rc3/ghmm/randvar.c"
        ":"
        "ighmm_rand_normal_density"
        "("
        "244"
        "): ",
        "u <= 0.0 not allowed\n");
    goto STOP;
  }
  expo = exp(-1 * ((mean - x) * (mean - x)) / (2 * u));
  return (1 / (sqrt(2 * 3.141592653589793116 * u)) * expo);
STOP:
  return (-1.0);
}


x86 assembly (clang, -O0):
<ighmm_rand_normal_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1172 <ighmm_rand_normal_density+0x42>
mov    $0x2,%edi
lea    0xeb7(%rip),%rsi
lea    0xf80(%rip),%rdx
call   1030 <GHMM_LOG_PRINTF@plt>
jmp    11e8 <ighmm_rand_normal_density+0xb8>
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe7e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe6a(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe43(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f5 <ighmm_rand_normal_density+0xc5>
movsd  0xe20(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ighmm_rand_normal_density>:
sub    $0x18,%rsp
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm3
jae    11a7 <ighmm_rand_normal_density+0x77>
subsd  %xmm0,%xmm1
movapd 0xec6(%rip),%xmm0
xorpd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm2,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  %xmm2,0x8(%rsp)
call   1040 <exp@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe87(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovb  %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
lea    0xe72(%rip),%rsi
lea    0xf3b(%rip),%rdx
mov    $0x2,%edi
call   1030 <GHMM_LOG_PRINTF@plt>
movsd  0xe39(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [208 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lukefrasera/fatigueBSN/refs/heads/master/scripts/include/ghmm-0.9-rc3/ghmm/randvar.c:ighmm_rand_normal_density(244): \00"
@.str.1 = [22 x i8] c"u <= 0.0 not allowed\0A\00"
define double @ighmm_rand_normal_density(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* %5
store double %1, double* %6
store double %2, double* %7
%9 = load double, double* %7
%10 = fcmp ole double %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @GHMM_LOG_PRINTF(i32 2, i8* getelementptr inbounds ([208 x i8], [208 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %35
13: ; preds = %3
%14 = load double, double* %6
%15 = load double, double* %5
%16 = fsub double %14, %15
%17 = load double, double* %6
%18 = load double, double* %5
%19 = fsub double %17, %18
%20 = fmul double %16, %19
%21 = fmul double -1.000000e+00, %20
%22 = load double, double* %7
%23 = fmul double 2.000000e+00, %22
%24 = fdiv double %21, %23
%25 = fptosi double %24 to i32
%26 = call double @exp(i32 %25)
store double %26, double* %8
%27 = load double, double* %7
%28 = fmul double 0x401921FB54442D18, %27
%29 = fptosi double %28 to i32
%30 = call i32 @sqrt(i32 %29)
%31 = sdiv i32 1, %30
%32 = sitofp i32 %31 to double
%33 = load double, double* %8
%34 = fmul double %32, %33
store double %34, double* %4
br label %36
35: ; preds = %11
store double -1.000000e+00, double* %4
br label %36
36: ; preds = %35, %13
%37 = load double, double* %4
ret double %37
}

LLVM IR (-O2):
@.str = [208 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lukefrasera/fatigueBSN/refs/heads/master/scripts/include/ghmm-0.9-rc3/ghmm/randvar.c:ighmm_rand_normal_density(244): \00"
@.str.1 = [22 x i8] c"u <= 0.0 not allowed\0A\00"
define double @ighmm_rand_normal_density(double %0, double %1, double %2) {
%4 = fcmp ugt double %2, 0.000000e+00
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @GHMM_LOG_PRINTF(i32 2, i8* getelementptr inbounds ([208 x i8], [208 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %23
7: ; preds = %3
%8 = fsub double %1, %0
%9 = fneg double %8
%10 = fmul double %8, %9
%11 = fmul double %2, 2.000000e+00
%12 = fdiv double %10, %11
%13 = fptosi double %12 to i32
%14 = tail call double @exp(i32 %13)
%15 = fmul double %2, 0x401921FB54442D18
%16 = fptosi double %15 to i32
%17 = tail call i32 @sqrt(i32 %16)
%18 = add i32 %17, 1
%19 = icmp ult i32 %18, 3
%20 = select i1 %19, i32 %17, i32 0
%21 = sitofp i32 %20 to double
%22 = fmul double %14, %21
br label %23
23: ; preds = %5, %7
%24 = phi double [ -1.000000e+00, %5 ], [ %22, %7 ]
ret double %24
}