#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*/ fabs(int);
int log(int /*<<< orphan*/);
double sqrt(int);
double inv_distr_N01(double p) {
  const double tlow = 1e-307;
  const double thgh = 1 - 1e-16;
  double x, t, n, d;
  if (p < tlow)
    p = tlow;
  if (p > thgh)
    p = thgh;
  t = sqrt(-2 * log(fabs((p > 0.5) - p)));
  n = 2.515517 + t * (0.802853 + t * 0.010328);
  d = 1 + t * (1.432788 + t * (0.189269 + t * 0.001308));
  x = t - (n / d);
  if (p <= 0.5)
    x *= -1;
  return (x);
}


x86 assembly (clang, -O0):
<inv_distr_N01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xebb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea1(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1177 <inv_distr_N01+0x47>
movsd  0xe8e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119b <inv_distr_N01+0x6b>
movsd  0xe72(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cvtsi2sd %eax,%xmm0
subsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe51(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe4d(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  0xdfd(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xdf9(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdd9(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdc1(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
divsd  -0x38(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xd90(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     129d <inv_distr_N01+0x16d>
movsd  0xdbd(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_distr_N01>:
sub    $0x18,%rsp
movsd  0xec4(%rip),%xmm1
maxsd  %xmm0,%xmm1
movsd  0xec0(%rip),%xmm2
minsd  %xmm1,%xmm2
movapd %xmm2,(%rsp)
movsd  0xeb7(%rip),%xmm0
cmpltsd %xmm2,%xmm0
movsd  0xeb2(%rip),%xmm1
andpd  %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
lea    (%rax,%rax,1),%edi
neg    %edi
call   1050 <sqrt@plt>
movsd  0xe90(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe8c(%rip),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
movapd 0xe84(%rip),%xmm3
unpcklpd %xmm1,%xmm3
mulpd  %xmm2,%xmm3
addpd  0xe84(%rip),%xmm3
mulpd  %xmm2,%xmm3
addpd  0xe88(%rip),%xmm3
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
divsd  %xmm1,%xmm3
subsd  %xmm3,%xmm0
movapd 0xe80(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd (%rsp),%xmm2
cmpnlesd 0xe1e(%rip),%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @inv_distr_N01(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %2
store double 0x31FA182C40C60D, double* %3
store double 0x3FEFFFFFFFFFFFFF, double* %4
%9 = load double, double* %2
%10 = fcmp olt double %9, 0x31FA182C40C60D
br i1 %10, label %11, label %12
11: ; preds = %1
store double 0x31FA182C40C60D, double* %2
br label %12
12: ; preds = %11, %1
%13 = load double, double* %2
%14 = fcmp ogt double %13, 0x3FEFFFFFFFFFFFFF
br i1 %14, label %15, label %16
15: ; preds = %12
store double 0x3FEFFFFFFFFFFFFF, double* %2
br label %16
16: ; preds = %15, %12
%17 = load double, double* %2
%18 = fcmp ogt double %17, 5.000000e-01
%19 = zext i1 %18 to i32
%20 = sitofp i32 %19 to double
%21 = load double, double* %2
%22 = fsub double %20, %21
%23 = fptosi double %22 to i32
%24 = call i32 @fabs(i32 %23)
%25 = call i32 @log(i32 %24)
%26 = mul nsw i32 -2, %25
%27 = call double @sqrt(i32 %26)
store double %27, double* %6
%28 = load double, double* %6
%29 = load double, double* %6
%30 = call double @llvm.fmuladd.f64(double %29, double 1.032800e-02, double 8.028530e-01)
%31 = call double @llvm.fmuladd.f64(double %28, double %30, double 0x40041FC7607C419A)
store double %31, double* %7
%32 = load double, double* %6
%33 = load double, double* %6
%34 = load double, double* %6
%35 = call double @llvm.fmuladd.f64(double %34, double 1.308000e-03, double 1.892690e-01)
%36 = call double @llvm.fmuladd.f64(double %33, double %35, double 0x3FF6ECB31C219EB6)
%37 = call double @llvm.fmuladd.f64(double %32, double %36, double 1.000000e+00)
store double %37, double* %8
%38 = load double, double* %6
%39 = load double, double* %7
%40 = load double, double* %8
%41 = fdiv double %39, %40
%42 = fsub double %38, %41
store double %42, double* %5
%43 = load double, double* %2
%44 = fcmp ole double %43, 5.000000e-01
br i1 %44, label %45, label %48
45: ; preds = %16
%46 = load double, double* %5
%47 = fmul double %46, -1.000000e+00
store double %47, double* %5
br label %48
48: ; preds = %45, %16
%49 = load double, double* %5
ret double %49
}

LLVM IR (-O2):
define double @inv_distr_N01(double %0) {
%2 = fcmp olt double %0, 0x31FA182C40C60D
%3 = select i1 %2, double 0x31FA182C40C60D, double %0
%4 = fcmp ogt double %3, 0x3FEFFFFFFFFFFFFF
%5 = select i1 %4, double 0x3FEFFFFFFFFFFFFF, double %3
%6 = fcmp ogt double %5, 5.000000e-01
%7 = uitofp i1 %6 to double
%8 = fsub double %7, %5
%9 = fptosi double %8 to i32
%10 = tail call i32 @fabs(i32 %9)
%11 = tail call i32 @log(i32 %10)
%12 = mul nsw i32 %11, -2
%13 = tail call double @sqrt(i32 %12)
%14 = tail call double @llvm.fmuladd.f64(double %13, double 1.308000e-03, double 1.892690e-01)
%15 = insertelement <2 x double> poison, double %13, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = insertelement <2 x double> <double 1.032800e-02, double poison>, double %14, i64 1
%18 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %16, <2 x double> %17, <2 x double> <double 8.028530e-01, double 0x3FF6ECB31C219EB6>)
%19 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %16, <2 x double> %18, <2 x double> <double 0x40041FC7607C419A, double 1.000000e+00>)
%20 = extractelement <2 x double> %19, i64 0
%21 = extractelement <2 x double> %19, i64 1
%22 = fdiv double %20, %21
%23 = fsub double %13, %22
%24 = fcmp ugt double %5, 5.000000e-01
%25 = fneg double %23
%26 = select i1 %24, double %23, double %25
ret double %26
}