double ighmm_rand_binormal_density(const double *x, double *mean, double *cov) {
  double rho;
  double numerator, part1, part2, part3;
  if (cov[0] <= 0.0 || cov[2 + 1] <= 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_binormal_density"
        "("
        "272"
        "): ",
        "variance <= 0.0 not allowed\n");
    goto STOP;
  }
  rho = cov[1] / (sqrt(cov[0]) * sqrt(cov[2 + 1]));
  part1 = (x[0] - mean[0]) / sqrt(cov[0]);
  part2 = (x[1] - mean[1]) / sqrt(cov[2 + 1]);
  part3 = ((part1) * (part1)) - 2 * part1 * part2 + ((part2) * (part2));
  numerator = exp(-1 * (part3) / (2 * (1 - ((rho) * (rho)))));
  return (numerator / (2 * 3.141592653589793116 * sqrt(1 - ((rho) * (rho)))));
STOP:
  return (-1.0);
}


x86 assembly (clang, -O0):
<ighmm_rand_binormal_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jae    1167 <ighmm_rand_binormal_density+0x37>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x18(%rax),%xmm0
jb     1186 <ighmm_rand_binormal_density+0x56>
mov    $0x2,%edi
lea    0xead(%rip),%rsi
lea    0xf78(%rip),%rdx
mov    $0x0,%al
call   1030 <GHMM_LOG_PRINTF@plt>
jmp    1343 <ighmm_rand_binormal_density+0x213>
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x18(%rax),%xmm0
call   1050 <sqrt@plt>
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x18(%rax),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  0xdc7(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd87(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm1,%xmm2
movsd  0xd45(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xd41(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xcf0(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  0xccf(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1350 <ighmm_rand_binormal_density+0x220>
movsd  0xccd(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ighmm_rand_binormal_density>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movsd  (%rdx),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1175 <ighmm_rand_binormal_density+0x45>
mov    %rdx,%rbx
ucomisd 0x18(%rdx),%xmm1
jae    1175 <ighmm_rand_binormal_density+0x45>
mov    %rsi,%r14
mov    %rdi,%r15
movsd  0x8(%rbx),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
jb     119c <ighmm_rand_binormal_density+0x6c>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    11a9 <ighmm_rand_binormal_density+0x79>
lea    0xeb4(%rip),%rsi
lea    0xf7f(%rip),%rdx
mov    $0x2,%edi
xor    %eax,%eax
call   1030 <GHMM_LOG_PRINTF@plt>
movsd  0xe69(%rip),%xmm1
jmp    1308 <ighmm_rand_binormal_density+0x1d8>
call   1050 <sqrt@plt>
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm1
movsd  0x18(%rbx),%xmm0
ucomisd %xmm2,%xmm0
jb     11ba <ighmm_rand_binormal_density+0x8a>
sqrtsd %xmm0,%xmm0
jmp    11cb <ighmm_rand_binormal_density+0x9b>
movsd  %xmm1,0x10(%rsp)
call   1050 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%r15),%xmm3
movsd  (%r14),%xmm6
movsd  (%rbx),%xmm0
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm0
jb     11ed <ighmm_rand_binormal_density+0xbd>
sqrtsd %xmm0,%xmm4
jmp    121e <ighmm_rand_binormal_density+0xee>
movapd %xmm3,0x20(%rsp)
movsd  %xmm1,0x10(%rsp)
movapd %xmm6,0x30(%rsp)
call   1050 <sqrt@plt>
movapd 0x30(%rsp),%xmm6
xorpd  %xmm5,%xmm5
movsd  0x10(%rsp),%xmm1
movapd 0x20(%rsp),%xmm3
movapd %xmm0,%xmm4
movsd  0x8(%rsp),%xmm2
divsd  %xmm1,%xmm2
movhpd 0x8(%r15),%xmm3
movhpd 0x8(%r14),%xmm6
subpd  %xmm6,%xmm3
movsd  0x18(%rbx),%xmm0
ucomisd %xmm5,%xmm0
jb     1249 <ighmm_rand_binormal_density+0x119>
sqrtsd %xmm0,%xmm0
jmp    1272 <ighmm_rand_binormal_density+0x142>
movsd  %xmm2,0x8(%rsp)
movapd %xmm3,0x20(%rsp)
movapd %xmm4,0x10(%rsp)
call   1050 <sqrt@plt>
movapd 0x10(%rsp),%xmm4
movapd 0x20(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
unpcklpd %xmm0,%xmm4
divpd  %xmm4,%xmm3
movsd  0xd86(%rip),%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm3,%xmm0
unpckhpd %xmm3,%xmm0
mulsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
xorpd  0xd76(%rip),%xmm0
mulsd  %xmm2,%xmm2
movsd  0xd5a(%rip),%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
call   1040 <exp@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm2
ucomisd %xmm0,%xmm2
movapd %xmm2,%xmm0
jb     12eb <ighmm_rand_binormal_density+0x1bb>
sqrtsd %xmm0,%xmm0
jmp    12fc <ighmm_rand_binormal_density+0x1cc>
movsd  %xmm1,0x8(%rsp)
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0xd14(%rip),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
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_binormal_density(272): \00"
@.str.1 = [29 x i8] c"variance <= 0.0 not allowed\0A\00"
define double @ighmm_rand_binormal_density(double* %0, double* %1, double* %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
%13 = load double*, double** %7
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
%16 = fcmp ole double %15, 0.000000e+00
br i1 %16, label %22, label %17
17: ; preds = %3
%18 = load double*, double** %7
%19 = getelementptr inbounds double, double* %18, i64 3
%20 = load double, double* %19
%21 = fcmp ole double %20, 0.000000e+00
br i1 %21, label %22, label %24
22: ; preds = %17, %3
%23 = call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @GHMM_LOG_PRINTF to i32 (i32, i8*, i8*, ...)*)(i32 2, i8* getelementptr inbounds ([210 x i8], [210 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %90
24: ; preds = %17
%25 = load double*, double** %7
%26 = getelementptr inbounds double, double* %25, i64 1
%27 = load double, double* %26
%28 = load double*, double** %7
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = call double @sqrt(double %30)
%32 = load double*, double** %7
%33 = getelementptr inbounds double, double* %32, i64 3
%34 = load double, double* %33
%35 = call double @sqrt(double %34)
%36 = fmul double %31, %35
%37 = fdiv double %27, %36
store double %37, double* %8
%38 = load double*, double** %5
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = load double*, double** %6
%42 = getelementptr inbounds double, double* %41, i64 0
%43 = load double, double* %42
%44 = fsub double %40, %43
%45 = load double*, double** %7
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = call double @sqrt(double %47)
%49 = fdiv double %44, %48
store double %49, double* %10
%50 = load double*, double** %5
%51 = getelementptr inbounds double, double* %50, i64 1
%52 = load double, double* %51
%53 = load double*, double** %6
%54 = getelementptr inbounds double, double* %53, i64 1
%55 = load double, double* %54
%56 = fsub double %52, %55
%57 = load double*, double** %7
%58 = getelementptr inbounds double, double* %57, i64 3
%59 = load double, double* %58
%60 = call double @sqrt(double %59)
%61 = fdiv double %56, %60
store double %61, double* %11
%62 = load double, double* %10
%63 = load double, double* %10
%64 = load double, double* %10
%65 = fmul double 2.000000e+00, %64
%66 = load double, double* %11
%67 = fmul double %65, %66
%68 = fneg double %67
%69 = call double @llvm.fmuladd.f64(double %62, double %63, double %68)
%70 = load double, double* %11
%71 = load double, double* %11
%72 = call double @llvm.fmuladd.f64(double %70, double %71, double %69)
store double %72, double* %12
%73 = load double, double* %12
%74 = fmul double -1.000000e+00, %73
%75 = load double, double* %8
%76 = load double, double* %8
%77 = fneg double %75
%78 = call double @llvm.fmuladd.f64(double %77, double %76, double 1.000000e+00)
%79 = fmul double 2.000000e+00, %78
%80 = fdiv double %74, %79
%81 = call double @exp(double %80)
store double %81, double* %9
%82 = load double, double* %9
%83 = load double, double* %8
%84 = load double, double* %8
%85 = fneg double %83
%86 = call double @llvm.fmuladd.f64(double %85, double %84, double 1.000000e+00)
%87 = call double @sqrt(double %86)
%88 = fmul double 0x401921FB54442D18, %87
%89 = fdiv double %82, %88
store double %89, double* %4
br label %91
90: ; preds = %22
store double -1.000000e+00, double* %4
br label %91
91: ; preds = %90, %24
%92 = load double, double* %4
ret double %92
}

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_binormal_density(272): \00"
@.str.1 = [29 x i8] c"variance <= 0.0 not allowed\0A\00"
define double @ighmm_rand_binormal_density(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = load double, double* %2
%5 = fcmp ugt double %4, 0.000000e+00
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = getelementptr inbounds double, double* %2, i64 3
%8 = load double, double* %7
%9 = fcmp ugt double %8, 0.000000e+00
br i1 %9, label %12, label %10
10: ; preds = %6, %3
%11 = tail call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @GHMM_LOG_PRINTF to i32 (i32, i8*, i8*, ...)*)(i32 2, i8* getelementptr inbounds ([210 x i8], [210 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %53
12: ; preds = %6
%13 = getelementptr inbounds double, double* %2, i64 1
%14 = load double, double* %13
%15 = tail call double @sqrt(double %4)
%16 = load double, double* %7
%17 = tail call double @sqrt(double %16)
%18 = fmul double %15, %17
%19 = fdiv double %14, %18
%20 = load double, double* %0
%21 = load double, double* %1
%22 = load double, double* %2
%23 = tail call double @sqrt(double %22)
%24 = getelementptr inbounds double, double* %0, i64 1
%25 = load double, double* %24
%26 = getelementptr inbounds double, double* %1, i64 1
%27 = load double, double* %26
%28 = insertelement <2 x double> poison, double %20, i64 0
%29 = insertelement <2 x double> %28, double %25, i64 1
%30 = insertelement <2 x double> poison, double %21, i64 0
%31 = insertelement <2 x double> %30, double %27, i64 1
%32 = fsub <2 x double> %29, %31
%33 = load double, double* %7
%34 = tail call double @sqrt(double %33)
%35 = insertelement <2 x double> poison, double %23, i64 0
%36 = insertelement <2 x double> %35, double %34, i64 1
%37 = fdiv <2 x double> %32, %36
%38 = extractelement <2 x double> %37, i64 0
%39 = fmul double %38, -2.000000e+00
%40 = extractelement <2 x double> %37, i64 1
%41 = fmul double %39, %40
%42 = tail call double @llvm.fmuladd.f64(double %38, double %38, double %41)
%43 = tail call double @llvm.fmuladd.f64(double %40, double %40, double %42)
%44 = fneg double %43
%45 = fneg double %19
%46 = tail call double @llvm.fmuladd.f64(double %45, double %19, double 1.000000e+00)
%47 = fmul double %46, 2.000000e+00
%48 = fdiv double %44, %47
%49 = tail call double @exp(double %48)
%50 = tail call double @sqrt(double %46)
%51 = fmul double %50, 0x401921FB54442D18
%52 = fdiv double %49, %51
br label %53
53: ; preds = %10, %12
%54 = phi double [ -1.000000e+00, %10 ], [ %52, %12 ]
ret double %54
}