#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 erf(double);
double erfc(double);
double sqrt(double);
double ighmm_rand_normal_right_cdf(double x, double mean, double u, double a) {
  if (x <= a)
    return (0.0);
  if (u <= a) {
    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_right_cdf"
        "("
        "703"
        "): ",
        "u <= a not allowed\n");
    goto STOP;
  }
  return 1.0 +
         (erf((x - mean) / sqrt(u * 2)) - 1.0) / erfc((a - mean) / sqrt(u * 2));
STOP:
  return (-1.0);
}


x86 assembly (clang, -O0):
<ighmm_rand_normal_right_cdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     117d <ighmm_rand_normal_right_cdf+0x3d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124f <ighmm_rand_normal_right_cdf+0x10f>
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11ae <ighmm_rand_normal_right_cdf+0x6e>
mov    $0x2,%edi
lea    0xe7b(%rip),%rsi
lea    0xf46(%rip),%rdx
call   1030 <GHMM_LOG_PRINTF@plt>
jmp    1242 <ighmm_rand_normal_right_cdf+0x102>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe43(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1050 <erf@plt>
movsd  0xe18(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe00(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1060 <erfc@plt>
movsd  -0x30(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  0xdcc(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124f <ighmm_rand_normal_right_cdf+0x10f>
movsd  0xdc6(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ighmm_rand_normal_right_cdf>:
sub    $0x28,%rsp
movapd %xmm0,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm4,%xmm3
jae    1219 <ighmm_rand_normal_right_cdf+0xd9>
ucomisd %xmm2,%xmm3
jae    121e <ighmm_rand_normal_right_cdf+0xde>
movsd  %xmm3,0x8(%rsp)
movsd  %xmm1,0x20(%rsp)
subsd  %xmm1,%xmm4
addsd  %xmm2,%xmm2
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
xorpd  %xmm1,%xmm1
movsd  %xmm2,0x10(%rsp)
ucomisd %xmm1,%xmm2
movsd  %xmm0,0x18(%rsp)
jae    11a6 <ighmm_rand_normal_right_cdf+0x66>
movsd  0x10(%rsp),%xmm0
movsd  %xmm4,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm4
divsd  %xmm0,%xmm4
movapd %xmm4,%xmm0
call   1050 <erf@plt>
addsd  0xe45(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm1
subsd  0x20(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd 0xe36(%rip),%xmm0
movsd  0x18(%rsp),%xmm2
jae    11f7 <ighmm_rand_normal_right_cdf+0xb7>
movsd  %xmm1,0x8(%rsp)
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1060 <erfc@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  0xdef(%rip),%xmm0
add    $0x28,%rsp
ret
lea    0xdf3(%rip),%rsi
lea    0xebe(%rip),%rdx
mov    $0x2,%edi
call   1030 <GHMM_LOG_PRINTF@plt>
movsd  0xdc2(%rip),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [210 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_right_cdf(703): \00"
@.str.1 = [20 x i8] c"u <= a not allowed\0A\00"
define double @ighmm_rand_normal_right_cdf(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
%10 = load double, double* %6
%11 = load double, double* %9
%12 = fcmp ole double %10, %11
br i1 %12, label %13, label %14
13: ; preds = %4
store double 0.000000e+00, double* %5
br label %41
14: ; preds = %4
%15 = load double, double* %8
%16 = load double, double* %9
%17 = fcmp ole double %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @GHMM_LOG_PRINTF(i32 2, i8* getelementptr inbounds ([210 x i8], [210 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %40
20: ; preds = %14
%21 = load double, double* %6
%22 = load double, double* %7
%23 = fsub double %21, %22
%24 = load double, double* %8
%25 = fmul double %24, 2.000000e+00
%26 = call double @sqrt(double %25)
%27 = fdiv double %23, %26
%28 = call double @erf(double %27)
%29 = fsub double %28, 1.000000e+00
%30 = load double, double* %9
%31 = load double, double* %7
%32 = fsub double %30, %31
%33 = load double, double* %8
%34 = fmul double %33, 2.000000e+00
%35 = call double @sqrt(double %34)
%36 = fdiv double %32, %35
%37 = call double @erfc(double %36)
%38 = fdiv double %29, %37
%39 = fadd double 1.000000e+00, %38
store double %39, double* %5
br label %41
40: ; preds = %18
store double -1.000000e+00, double* %5
br label %41
41: ; preds = %40, %20, %13
%42 = load double, double* %5
ret double %42
}

LLVM IR (-O2):
@.str = [210 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_right_cdf(703): \00"
@.str.1 = [20 x i8] c"u <= a not allowed\0A\00"
define double @ighmm_rand_normal_right_cdf(double %0, double %1, double %2, double %3) {
%5 = fcmp ugt double %0, %3
br i1 %5, label %6, label %23
6: ; preds = %4
%7 = fcmp ugt double %2, %3
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 @GHMM_LOG_PRINTF(i32 2, i8* getelementptr inbounds ([210 x i8], [210 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %23
10: ; preds = %6
%11 = fsub double %0, %1
%12 = fmul double %2, 2.000000e+00
%13 = tail call double @sqrt(double %12)
%14 = fdiv double %11, %13
%15 = tail call double @erf(double %14)
%16 = fadd double %15, -1.000000e+00
%17 = fsub double %3, %1
%18 = tail call double @sqrt(double %12)
%19 = fdiv double %17, %18
%20 = tail call double @erfc(double %19)
%21 = fdiv double %16, %20
%22 = fadd double %21, 1.000000e+00
br label %23
23: ; preds = %4, %8, %10
%24 = phi double [ -1.000000e+00, %8 ], [ %22, %10 ], [ 0.000000e+00, %4 ]
ret double %24
}