#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 */
double exp(double);
int sqrt(int);
double bivarnorm(double x, double y, double mu1, double mu2, double *cv) {
  double rho, s1, s1sq, s2, s2sq, m, e1, e2;
  s1sq = cv[(0) * (2) + (0)];
  s2sq = cv[(1) * (2) + (1)];
  s1 = sqrt(s1sq);
  s2 = sqrt(s2sq);
  rho = cv[(0) * (2) + (1)] / sqrt(s1sq * s2sq);
  m = 1 / (2 * 3.14 * s1 * s2 * sqrt(1 - (rho * rho)));
  e1 = (-1) / (2 * (1 - (rho * rho)));
  e2 = ((x - mu1) * (x - mu1)) / s1sq -
       (2 * rho * (x - mu1) * (y - mu2)) / (s1 * s2) +
       ((y - mu2) * (y - mu2)) / s2sq;
  return m * exp(e1 * e2);
}


x86 assembly (clang, -O0):
<bivarnorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvttsd2si -0x40(%rbp),%edi
call   1040 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x50(%rbp),%edi
call   1040 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  -0x80(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe59(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe15(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  -0x78(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm1
movsd  0xdf3(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdbd(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xda1(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xd9d(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  0xd67(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x38(%rbp),%xmm2
mulsd  -0x48(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  -0x50(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bivarnorm>:
push   %rbx
sub    $0xb0,%rsp
mov    %rdi,%rbx
movaps %xmm3,0xa0(%rsp)
movaps %xmm2,0x90(%rsp)
movaps %xmm1,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movsd  (%rdi),%xmm1
movapd %xmm1,0x50(%rsp)
movsd  0x18(%rdi),%xmm0
movaps %xmm0,0x20(%rsp)
cvttsd2si %xmm1,%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm0,0x40(%rsp)
cvttsd2si 0x20(%rsp),%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx),%xmm0
movaps %xmm0,0x10(%rsp)
movapd 0x50(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  0xe38(%rip),%xmm0
mulsd  0x40(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x38(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe1e(%rip),%xmm1
movsd  %xmm1,(%rsp)
subsd  %xmm0,%xmm1
movapd %xmm1,0x60(%rsp)
cvttsd2si %xmm1,%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x38(%rsp),%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movapd 0x60(%rsp),%xmm4
addsd  %xmm4,%xmm4
movapd 0x10(%rsp),%xmm1
addsd  %xmm1,%xmm1
movapd 0x70(%rsp),%xmm2
unpcklpd 0x80(%rsp),%xmm2
movapd 0x90(%rsp),%xmm0
unpcklpd 0xa0(%rsp),%xmm0
subpd  %xmm0,%xmm2
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
unpcklpd %xmm0,%xmm1
mulpd  %xmm2,%xmm1
movapd 0x40(%rsp),%xmm3
mulsd  0x8(%rsp),%xmm3
movapd 0x50(%rsp),%xmm0
unpcklpd %xmm3,%xmm0
mulpd  %xmm2,%xmm2
movlpd 0xd84(%rip),%xmm2
divpd  %xmm0,%xmm1
movapd %xmm4,%xmm0
unpcklpd 0x20(%rsp),%xmm0
divpd  %xmm0,%xmm2
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
subsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
add    $0xb0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @bivarnorm(double %0, double %1, double %2, double %3, double* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double* %4, double** %10
%19 = load double*, double** %10
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
store double %21, double* %13
%22 = load double*, double** %10
%23 = getelementptr inbounds double, double* %22, i64 3
%24 = load double, double* %23
store double %24, double* %15
%25 = load double, double* %13
%26 = fptosi double %25 to i32
%27 = call i32 @sqrt(i32 %26)
%28 = sitofp i32 %27 to double
store double %28, double* %12
%29 = load double, double* %15
%30 = fptosi double %29 to i32
%31 = call i32 @sqrt(i32 %30)
%32 = sitofp i32 %31 to double
store double %32, double* %14
%33 = load double*, double** %10
%34 = getelementptr inbounds double, double* %33, i64 1
%35 = load double, double* %34
%36 = load double, double* %13
%37 = load double, double* %15
%38 = fmul double %36, %37
%39 = fptosi double %38 to i32
%40 = call i32 @sqrt(i32 %39)
%41 = sitofp i32 %40 to double
%42 = fdiv double %35, %41
store double %42, double* %11
%43 = load double, double* %12
%44 = fmul double 6.280000e+00, %43
%45 = load double, double* %14
%46 = fmul double %44, %45
%47 = load double, double* %11
%48 = load double, double* %11
%49 = fneg double %47
%50 = call double @llvm.fmuladd.f64(double %49, double %48, double 1.000000e+00)
%51 = fptosi double %50 to i32
%52 = call i32 @sqrt(i32 %51)
%53 = sitofp i32 %52 to double
%54 = fmul double %46, %53
%55 = fdiv double 1.000000e+00, %54
store double %55, double* %16
%56 = load double, double* %11
%57 = load double, double* %11
%58 = fneg double %56
%59 = call double @llvm.fmuladd.f64(double %58, double %57, double 1.000000e+00)
%60 = fmul double 2.000000e+00, %59
%61 = fdiv double -1.000000e+00, %60
store double %61, double* %17
%62 = load double, double* %6
%63 = load double, double* %8
%64 = fsub double %62, %63
%65 = load double, double* %6
%66 = load double, double* %8
%67 = fsub double %65, %66
%68 = fmul double %64, %67
%69 = load double, double* %13
%70 = fdiv double %68, %69
%71 = load double, double* %11
%72 = fmul double 2.000000e+00, %71
%73 = load double, double* %6
%74 = load double, double* %8
%75 = fsub double %73, %74
%76 = fmul double %72, %75
%77 = load double, double* %7
%78 = load double, double* %9
%79 = fsub double %77, %78
%80 = fmul double %76, %79
%81 = load double, double* %12
%82 = load double, double* %14
%83 = fmul double %81, %82
%84 = fdiv double %80, %83
%85 = fsub double %70, %84
%86 = load double, double* %7
%87 = load double, double* %9
%88 = fsub double %86, %87
%89 = load double, double* %7
%90 = load double, double* %9
%91 = fsub double %89, %90
%92 = fmul double %88, %91
%93 = load double, double* %15
%94 = fdiv double %92, %93
%95 = fadd double %85, %94
store double %95, double* %18
%96 = load double, double* %16
%97 = load double, double* %17
%98 = load double, double* %18
%99 = fmul double %97, %98
%100 = call double @exp(double %99)
%101 = fmul double %96, %100
ret double %101
}

LLVM IR (-O2):
define double @bivarnorm(double %0, double %1, double %2, double %3, double* nocapture %4) {
%6 = load double, double* %4
%7 = getelementptr inbounds double, double* %4, i64 3
%8 = load double, double* %7
%9 = fptosi double %6 to i32
%10 = tail call i32 @sqrt(i32 %9)
%11 = sitofp i32 %10 to double
%12 = fptosi double %8 to i32
%13 = tail call i32 @sqrt(i32 %12)
%14 = sitofp i32 %13 to double
%15 = getelementptr inbounds double, double* %4, i64 1
%16 = load double, double* %15
%17 = fmul double %6, %8
%18 = fptosi double %17 to i32
%19 = tail call i32 @sqrt(i32 %18)
%20 = sitofp i32 %19 to double
%21 = fdiv double %16, %20
%22 = fmul double %11, 6.280000e+00
%23 = fmul double %22, %14
%24 = fneg double %21
%25 = tail call double @llvm.fmuladd.f64(double %24, double %21, double 1.000000e+00)
%26 = fptosi double %25 to i32
%27 = tail call i32 @sqrt(i32 %26)
%28 = sitofp i32 %27 to double
%29 = fmul double %23, %28
%30 = fdiv double 1.000000e+00, %29
%31 = fmul double %25, 2.000000e+00
%32 = fmul double %21, 2.000000e+00
%33 = insertelement <2 x double> poison, double %0, i64 0
%34 = insertelement <2 x double> %33, double %1, i64 1
%35 = insertelement <2 x double> poison, double %2, i64 0
%36 = insertelement <2 x double> %35, double %3, i64 1
%37 = fsub <2 x double> %34, %36
%38 = extractelement <2 x double> %37, i64 0
%39 = fmul double %38, %32
%40 = insertelement <2 x double> %37, double %39, i64 1
%41 = fmul <2 x double> %37, %40
%42 = fmul double %11, %14
%43 = insertelement <2 x double> poison, double %6, i64 0
%44 = insertelement <2 x double> %43, double %42, i64 1
%45 = fdiv <2 x double> %41, %44
%46 = shufflevector <2 x double> %45, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%47 = fsub <2 x double> %45, %46
%48 = fmul <2 x double> %37, %37
%49 = insertelement <2 x double> %48, double -1.000000e+00, i64 0
%50 = insertelement <2 x double> poison, double %31, i64 0
%51 = insertelement <2 x double> %50, double %8, i64 1
%52 = fdiv <2 x double> %49, %51
%53 = shufflevector <2 x double> %52, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%54 = fadd <2 x double> %53, %47
%55 = fmul <2 x double> %52, %54
%56 = extractelement <2 x double> %55, i64 0
%57 = tail call double @exp(double %56)
%58 = fmul double %57, %30
ret double %58
}