#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*/ log(double);
double sqrt(int /*<<< orphan*/);
double gauinv(double p, int *ifault) {
  static double p0 = -0.322232431088, p1 = -1.0, p2 = -0.342242088547,
                p3 = -0.204231210245e-01, p4 = -0.453642210148e-04;
  static double q0 = 0.99348462606e-01, q1 = 0.588581560495,
                q2 = 0.531103462366, q3 = 0.103537752850,
                q4 = 0.38560700634e-02;
  double tem, ps, yi;
  tem = 0.0;
  ps = p;
  if (ps > 0.5)
    ps = 1.0 - ps;
  *ifault = 1;
  if (ps < 1.0e-20)
    return tem;
  *ifault = 0;
  if (ps == 0.5)
    return tem;
  yi = sqrt(log(1.0 / (ps * ps)));
  tem = yi + ((((yi * p4 + p3) * yi + p2) * yi + p1) * yi + p0) /
                 ((((yi * q4 + q3) * yi + q2) * yi + q1) * yi + q0);
  if (p < 0.5)
    tem = -tem;
  return tem;
}


x86 assembly (clang, -O0):
<gauinv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xeb0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    116c <gauinv+0x4c>
movsd  0xea6(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movsd  0xe92(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1198 <gauinv+0x78>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fd <gauinv+0x1dd>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  0xe51(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11ce <gauinv+0xae>
jp     11ce <gauinv+0xae>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fd <gauinv+0x1dd>
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xe28(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1030 <log@plt>
mov    %eax,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0x2e49(%rip),%xmm3
movsd  0x2e39(%rip),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x30(%rbp),%xmm3
movsd  0x2e1c(%rip),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x30(%rbp),%xmm3
movsd  0x2dff(%rip),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x30(%rbp),%xmm3
movsd  0x2de2(%rip),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  0x2e15(%rip),%xmm4
movsd  0x2e05(%rip),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  -0x30(%rbp),%xmm4
movsd  0x2de8(%rip),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  -0x30(%rbp),%xmm4
movsd  0x2dcb(%rip),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  -0x30(%rbp),%xmm4
movsd  0x2dae(%rip),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xd39(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12f3 <gauinv+0x1d3>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauinv>:
sub    $0x18,%rsp
movapd %xmm0,%xmm4
movsd  0xed0(%rip),%xmm0
movapd %xmm0,%xmm1
subsd  %xmm4,%xmm1
movsd  0xec8(%rip),%xmm2
cmpltsd %xmm4,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm4,%xmm2
orpd   %xmm1,%xmm2
movl   $0x1,(%rdi)
xorpd  %xmm1,%xmm1
movsd  0xead(%rip),%xmm3
ucomisd %xmm2,%xmm3
ja     121a <gauinv+0xfa>
movl   $0x0,(%rdi)
ucomisd 0xe8d(%rip),%xmm2
jne    1183 <gauinv+0x63>
jnp    121a <gauinv+0xfa>
mulsd  %xmm2,%xmm2
divsd  %xmm2,%xmm0
movapd %xmm4,(%rsp)
call   1030 <log@plt>
mov    %eax,%edi
call   1040 <sqrt@plt>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
movapd 0xe74(%rip),%xmm2
mulpd  %xmm1,%xmm2
addpd  0xe78(%rip),%xmm2
mulpd  %xmm1,%xmm2
addpd  0xe7c(%rip),%xmm2
mulpd  %xmm1,%xmm2
addpd  0xe80(%rip),%xmm2
mulpd  %xmm1,%xmm2
addpd  0xe84(%rip),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
divsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movapd 0xe7c(%rip),%xmm0
movapd (%rsp),%xmm3
cmpltsd 0xe06(%rip),%xmm3
xorpd  %xmm2,%xmm0
movapd %xmm3,%xmm1
andnpd %xmm2,%xmm1
andpd  %xmm0,%xmm3
orpd   %xmm1,%xmm3
movapd %xmm3,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@gauinv.p0 = internal global double 0xBFD49F74C64EF237
@gauinv.p1 = internal global double -1.000000e+00
@gauinv.p2 = internal global double 0xBFD5E74B5C67F146
@gauinv.p3 = internal global double 0xBF94E9CC7387A830
@gauinv.p4 = internal global double 0xBF07C8AEC3ED1A62
@gauinv.q0 = internal global double 0x3FB96EE69DCCF754
@gauinv.q1 = internal global double 0x3FE2D5A8FF2B5976
@gauinv.q2 = internal global double 0x3FE0FECCB034F054
@gauinv.q3 = internal global double 0x3FBA81733E645F68
@gauinv.q4 = internal global double 0x3F6F96C3DA074588
define double @gauinv(double %0, i32* %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32*
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store i32* %1, i32** %5
store double 0.000000e+00, double* %6
%9 = load double, double* %4
store double %9, double* %7
%10 = load double, double* %7
%11 = fcmp ogt double %10, 5.000000e-01
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load double, double* %7
%14 = fsub double 1.000000e+00, %13
store double %14, double* %7
br label %15
15: ; preds = %12, %2
%16 = load i32*, i32** %5
store i32 1, i32* %16
%17 = load double, double* %7
%18 = fcmp olt double %17, 0x3BC79CA10C924223
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load double, double* %6
store double %20, double* %3
br label %70
21: ; preds = %15
%22 = load i32*, i32** %5
store i32 0, i32* %22
%23 = load double, double* %7
%24 = fcmp oeq double %23, 5.000000e-01
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load double, double* %6
store double %26, double* %3
br label %70
27: ; preds = %21
%28 = load double, double* %7
%29 = load double, double* %7
%30 = fmul double %28, %29
%31 = fdiv double 1.000000e+00, %30
%32 = call i32 @log(double %31)
%33 = call double @sqrt(i32 %32)
store double %33, double* %8
%34 = load double, double* %8
%35 = load double, double* %8
%36 = load double, double* @gauinv.p4
%37 = load double, double* @gauinv.p3
%38 = call double @llvm.fmuladd.f64(double %35, double %36, double %37)
%39 = load double, double* %8
%40 = load double, double* @gauinv.p2
%41 = call double @llvm.fmuladd.f64(double %38, double %39, double %40)
%42 = load double, double* %8
%43 = load double, double* @gauinv.p1
%44 = call double @llvm.fmuladd.f64(double %41, double %42, double %43)
%45 = load double, double* %8
%46 = load double, double* @gauinv.p0
%47 = call double @llvm.fmuladd.f64(double %44, double %45, double %46)
%48 = load double, double* %8
%49 = load double, double* @gauinv.q4
%50 = load double, double* @gauinv.q3
%51 = call double @llvm.fmuladd.f64(double %48, double %49, double %50)
%52 = load double, double* %8
%53 = load double, double* @gauinv.q2
%54 = call double @llvm.fmuladd.f64(double %51, double %52, double %53)
%55 = load double, double* %8
%56 = load double, double* @gauinv.q1
%57 = call double @llvm.fmuladd.f64(double %54, double %55, double %56)
%58 = load double, double* %8
%59 = load double, double* @gauinv.q0
%60 = call double @llvm.fmuladd.f64(double %57, double %58, double %59)
%61 = fdiv double %47, %60
%62 = fadd double %34, %61
store double %62, double* %6
%63 = load double, double* %4
%64 = fcmp olt double %63, 5.000000e-01
br i1 %64, label %65, label %68
65: ; preds = %27
%66 = load double, double* %6
%67 = fneg double %66
store double %67, double* %6
br label %68
68: ; preds = %65, %27
%69 = load double, double* %6
store double %69, double* %3
br label %70
70: ; preds = %68, %25, %19
%71 = load double, double* %3
ret double %71
}

LLVM IR (-O2):
define double @gauinv(double %0, i32* nocapture writeonly %1) {
%3 = fcmp ogt double %0, 5.000000e-01
%4 = fsub double 1.000000e+00, %0
%5 = select i1 %3, double %4, double %0
store i32 1, i32* %1
%6 = fcmp olt double %5, 0x3BC79CA10C924223
br i1 %6, label %27, label %7
7: ; preds = %2
store i32 0, i32* %1
%8 = fcmp oeq double %5, 5.000000e-01
br i1 %8, label %27, label %9
9: ; preds = %7
%10 = fmul double %5, %5
%11 = fdiv double 1.000000e+00, %10
%12 = tail call i32 @log(double %11)
%13 = tail call double @sqrt(i32 %12)
%14 = insertelement <2 x double> poison, double %13, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> <double 0xBF07C8AEC3ED1A62, double 0x3F6F96C3DA074588>, <2 x double> <double 0xBF94E9CC7387A830, double 0x3FBA81733E645F68>)
%17 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %16, <2 x double> %15, <2 x double> <double 0xBFD5E74B5C67F146, double 0x3FE0FECCB034F054>)
%18 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %17, <2 x double> %15, <2 x double> <double -1.000000e+00, double 0x3FE2D5A8FF2B5976>)
%19 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %15, <2 x double> <double 0xBFD49F74C64EF237, double 0x3FB96EE69DCCF754>)
%20 = extractelement <2 x double> %19, i64 0
%21 = extractelement <2 x double> %19, i64 1
%22 = fdiv double %20, %21
%23 = fadd double %13, %22
%24 = fcmp olt double %0, 5.000000e-01
%25 = fneg double %23
%26 = select i1 %24, double %25, double %23
br label %27
27: ; preds = %7, %2, %9
%28 = phi double [ %26, %9 ], [ 0.000000e+00, %2 ], [ 0.000000e+00, %7 ]
ret double %28
}