#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 */
scalar_t__ dbivnorm1(double, double, double);
double dbivnorm(double lower1, double lower2, double upper1, double upper2,
                double cor) {
  double out = 0;
  if (upper1 < 100 && upper2 < 100)
    out += dbivnorm1(upper1, upper2, cor);
  if (lower1 > -100 && upper2 < 100)
    out -= dbivnorm1(lower1, upper2, cor);
  if (upper1 < 100 && lower2 > -100)
    out -= dbivnorm1(upper1, lower2, cor);
  if (lower1 > -100 && lower2 > -100)
    out += dbivnorm1(lower1, lower2, cor);
  return out;
}


x86 assembly (clang, -O0):
<dbivnorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xebf(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1182 <dbivnorm+0x72>
movsd  0xeac(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1182 <dbivnorm+0x72>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1030 <dbivnorm1@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe79(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d3 <dbivnorm+0xc3>
movsd  0xe5f(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11d3 <dbivnorm+0xc3>
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1030 <dbivnorm1@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe25(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1224 <dbivnorm+0x114>
movsd  -0x10(%rbp),%xmm0
movsd  0xe15(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1224 <dbivnorm+0x114>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1030 <dbivnorm1@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1275 <dbivnorm+0x165>
movsd  -0x10(%rbp),%xmm0
movsd  0xdc0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1275 <dbivnorm+0x165>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1030 <dbivnorm1@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbivnorm>:
sub    $0x28,%rsp
movsd  %xmm4,0x8(%rsp)
movapd %xmm2,%xmm5
movapd %xmm0,%xmm2
movsd  0xed6(%rip),%xmm4
ucomisd %xmm5,%xmm4
xorpd  %xmm0,%xmm0
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm5,0x20(%rsp)
jbe    118b <dbivnorm+0x7b>
ucomisd %xmm3,%xmm4
jbe    118b <dbivnorm+0x7b>
movapd %xmm5,%xmm0
movapd %xmm3,%xmm1
movsd  0x8(%rsp),%xmm2
movsd  %xmm3,(%rsp)
call   1030 <dbivnorm1@plt>
movsd  (%rsp),%xmm3
movsd  0xe8f(%rip),%xmm4
movsd  0x20(%rsp),%xmm5
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
ucomisd 0xe75(%rip),%xmm2
jbe    11e8 <dbivnorm+0xd8>
ucomisd %xmm3,%xmm4
jbe    11e8 <dbivnorm+0xd8>
movsd  %xmm0,(%rsp)
movapd %xmm2,%xmm0
movapd %xmm3,%xmm1
movsd  0x8(%rsp),%xmm2
call   1030 <dbivnorm1@plt>
movsd  0xe45(%rip),%xmm4
movsd  0x20(%rsp),%xmm5
movsd  0x10(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm1
movsd  (%rsp),%xmm0
ucomisd 0xe18(%rip),%xmm1
jbe    122d <dbivnorm+0x11d>
ucomisd %xmm5,%xmm4
jbe    122d <dbivnorm+0x11d>
movsd  %xmm0,(%rsp)
movapd %xmm5,%xmm0
movsd  0x8(%rsp),%xmm2
call   1030 <dbivnorm1@plt>
movsd  0x10(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
ucomisd 0xdd3(%rip),%xmm2
jbe    1276 <dbivnorm+0x166>
movsd  0x18(%rsp),%xmm1
ucomisd 0xdc3(%rip),%xmm1
jbe    1276 <dbivnorm+0x166>
movsd  %xmm0,(%rsp)
movapd %xmm2,%xmm0
movsd  0x8(%rsp),%xmm2
call   1030 <dbivnorm1@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @dbivnorm(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
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
store double 0.000000e+00, double* %11
%12 = load double, double* %8
%13 = fcmp olt double %12, 1.000000e+02
br i1 %13, label %14, label %25
14: ; preds = %5
%15 = load double, double* %9
%16 = fcmp olt double %15, 1.000000e+02
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load double, double* %8
%19 = load double, double* %9
%20 = load double, double* %10
%21 = call i64 @dbivnorm1(double %18, double %19, double %20)
%22 = sitofp i64 %21 to double
%23 = load double, double* %11
%24 = fadd double %23, %22
store double %24, double* %11
br label %25
25: ; preds = %17, %14, %5
%26 = load double, double* %6
%27 = fcmp ogt double %26, -1.000000e+02
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = load double, double* %9
%30 = fcmp olt double %29, 1.000000e+02
br i1 %30, label %31, label %39
31: ; preds = %28
%32 = load double, double* %6
%33 = load double, double* %9
%34 = load double, double* %10
%35 = call i64 @dbivnorm1(double %32, double %33, double %34)
%36 = sitofp i64 %35 to double
%37 = load double, double* %11
%38 = fsub double %37, %36
store double %38, double* %11
br label %39
39: ; preds = %31, %28, %25
%40 = load double, double* %8
%41 = fcmp olt double %40, 1.000000e+02
br i1 %41, label %42, label %53
42: ; preds = %39
%43 = load double, double* %7
%44 = fcmp ogt double %43, -1.000000e+02
br i1 %44, label %45, label %53
45: ; preds = %42
%46 = load double, double* %8
%47 = load double, double* %7
%48 = load double, double* %10
%49 = call i64 @dbivnorm1(double %46, double %47, double %48)
%50 = sitofp i64 %49 to double
%51 = load double, double* %11
%52 = fsub double %51, %50
store double %52, double* %11
br label %53
53: ; preds = %45, %42, %39
%54 = load double, double* %6
%55 = fcmp ogt double %54, -1.000000e+02
br i1 %55, label %56, label %67
56: ; preds = %53
%57 = load double, double* %7
%58 = fcmp ogt double %57, -1.000000e+02
br i1 %58, label %59, label %67
59: ; preds = %56
%60 = load double, double* %6
%61 = load double, double* %7
%62 = load double, double* %10
%63 = call i64 @dbivnorm1(double %60, double %61, double %62)
%64 = sitofp i64 %63 to double
%65 = load double, double* %11
%66 = fadd double %65, %64
store double %66, double* %11
br label %67
67: ; preds = %59, %56, %53
%68 = load double, double* %11
ret double %68
}

LLVM IR (-O2):
define double @dbivnorm(double %0, double %1, double %2, double %3, double %4) {
%6 = fcmp olt double %2, 1.000000e+02
%7 = fcmp olt double %3, 1.000000e+02
%8 = and i1 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call i64 @dbivnorm1(double %2, double %3, double %4)
%11 = sitofp i64 %10 to double
br label %12
12: ; preds = %9, %5
%13 = phi double [ %11, %9 ], [ 0.000000e+00, %5 ]
%14 = fcmp ogt double %0, -1.000000e+02
%15 = and i1 %14, %7
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = tail call i64 @dbivnorm1(double %0, double %3, double %4)
%18 = sitofp i64 %17 to double
%19 = fsub double %13, %18
br label %20
20: ; preds = %16, %12
%21 = phi double [ %19, %16 ], [ %13, %12 ]
%22 = fcmp ogt double %1, -1.000000e+02
%23 = and i1 %22, %6
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = tail call i64 @dbivnorm1(double %2, double %1, double %4)
%26 = sitofp i64 %25 to double
%27 = fsub double %21, %26
br label %28
28: ; preds = %24, %20
%29 = phi double [ %27, %24 ], [ %21, %20 ]
%30 = and i1 %14, %22
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = tail call i64 @dbivnorm1(double %0, double %1, double %4)
%33 = sitofp i64 %32 to double
%34 = fadd double %29, %33
br label %35
35: ; preds = %31, %28
%36 = phi double [ %34, %31 ], [ %29, %28 ]
ret double %36
}