#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*/ pnorm_both(double, double *, double *, int, int);
double pnorm5(double x, double mu, double sigma, int lower_tail, int log_p) {
  double p, cp;
  p = (x - mu) / sigma;
  x = p;
  pnorm_both(x, &p, &cp, (lower_tail ? 0 : 1), log_p);
  return (lower_tail ? p : cp);
}


x86 assembly (clang, -O0):
<pnorm5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
xor    %eax,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x20(%rbp),%ecx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <pnorm_both@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1189 <pnorm5+0x79>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1193 <pnorm5+0x83>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pnorm5>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ecx
subsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,(%rsp)
xor    %edx,%edx
test   %edi,%edi
sete   %dl
lea    0x8(%rsp),%rsi
mov    %rsp,%rdi
mov    %rdi,%rbx
cmove  %rsi,%rbx
call   1030 <pnorm_both@plt>
movsd  (%rbx),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @pnorm5(double %0, double %1, double %2, i32 %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load double, double* %6
%14 = load double, double* %7
%15 = fsub double %13, %14
%16 = load double, double* %8
%17 = fdiv double %15, %16
store double %17, double* %11
%18 = load double, double* %11
store double %18, double* %6
%19 = load double, double* %6
%20 = load i32, i32* %9
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 0, i32 1
%24 = load i32, i32* %10
%25 = call i32 @pnorm_both(double %19, double* %11, double* %12, i32 %23, i32 %24)
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %5
%29 = load double, double* %11
br label %32
30: ; preds = %5
%31 = load double, double* %12
br label %32
32: ; preds = %30, %28
%33 = phi double [ %29, %28 ], [ %31, %30 ]
ret double %33
}

LLVM IR (-O2):
define double @pnorm5(double %0, double %1, double %2, i32 %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = bitcast double* %6 to i8*
%9 = bitcast double* %7 to i8*
%10 = fsub double %0, %1
%11 = fdiv double %10, %2
store double %11, double* %6
%12 = icmp eq i32 %3, 0
%13 = zext i1 %12 to i32
%14 = call i32 @pnorm_both(double %11, double* %6, double* %7, i32 %13, i32 %4)
%15 = load double, double* %6
%16 = load double, double* %7
%17 = select i1 %12, double %16, double %15
ret double %17
}