#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(int);
double sqrt(int /*<<< orphan*/);
double InverseCDFNormal(double prob) {
  double a0 = -.322232431088, a1 = -1, a2 = -.342242088547,
         a3 = -.0204231210245;
  double a4 = -.453642210148e-4, b0 = .0993484626060, b1 = .588581570495;
  double b2 = .531103462366, b3 = .103537752850, b4 = .0038560700634;
  double y, z = 0, p = prob, p1;
  p1 = (p < 0.5 ? p : 1 - p);
  if (p1 < 1e-20)
    z = 999;
  else {
    y = sqrt(log(1 / (p1 * p1)));
    z = y + ((((y * a4 + a3) * y + a2) * y + a1) * y + a0) /
                ((((y * b4 + b3) * y + b2) * y + b1) * y + b0);
  }
  return (p < 0.5 ? -z : z);
}


x86 assembly (clang, -O0):
<InverseCDFNormal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xf18(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xf03(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeee(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xec4(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe9a(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe70(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe5b(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe34(%rip),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    11e6 <InverseCDFNormal+0xc6>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    11f8 <InverseCDFNormal+0xd8>
movsd  0xe6a(%rip),%xmm0
subsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xe56(%rip),%xmm0
ucomisd -0x78(%rbp),%xmm0
jbe    1227 <InverseCDFNormal+0x107>
movsd  0xe4b(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    12fe <InverseCDFNormal+0x1de>
movsd  -0x78(%rbp),%xmm1
mulsd  -0x78(%rbp),%xmm1
movsd  0xe1f(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
mov    %eax,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x60(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x60(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x60(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm4
movsd  -0x50(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  -0x60(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  -0x60(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  -0x60(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xcfa(%rip),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    133a <InverseCDFNormal+0x21a>
movsd  -0x68(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1347 <InverseCDFNormal+0x227>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InverseCDFNormal>:
sub    $0x18,%rsp
movsd  0xed4(%rip),%xmm1
movapd %xmm1,%xmm3
subsd  %xmm0,%xmm3
movapd %xmm0,%xmm4
cmpltsd 0xec7(%rip),%xmm4
andpd  %xmm4,%xmm0
movapd %xmm4,%xmm2
andnpd %xmm3,%xmm2
orpd   %xmm0,%xmm2
movsd  0xebf(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    1169 <InverseCDFNormal+0x49>
movsd  0xea9(%rip),%xmm1
jmp    11db <InverseCDFNormal+0xbb>
mulsd  %xmm2,%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
movapd %xmm4,(%rsp)
call   1030 <log@plt>
mov    %eax,%edi
call   1040 <sqrt@plt>
movapd (%rsp),%xmm4
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
movapd 0xe85(%rip),%xmm1
mulpd  %xmm2,%xmm1
addpd  0xe89(%rip),%xmm1
mulpd  %xmm2,%xmm1
addpd  0xe8d(%rip),%xmm1
mulpd  %xmm2,%xmm1
addpd  0xe91(%rip),%xmm1
mulpd  %xmm2,%xmm1
addpd  0xe95(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movapd 0xe8d(%rip),%xmm0
xorpd  %xmm1,%xmm0
andpd  %xmm4,%xmm0
andnpd %xmm1,%xmm4
orpd   %xmm0,%xmm4
movapd %xmm4,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @InverseCDFNormal(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%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
store double %0, double* %2
store double 0xBFD49F74C64EF237, double* %3
store double -1.000000e+00, double* %4
store double 0xBFD5E74B5C67F146, double* %5
store double 0xBF94E9CC7387A830, double* %6
store double 0xBF07C8AEC3ED1A62, double* %7
store double 0x3FB96EE69DCCF754, double* %8
store double 0x3FE2D5A90489BD2F, double* %9
store double 0x3FE0FECCB034F054, double* %10
store double 0x3FBA81733E645F68, double* %11
store double 0x3F6F96C3DA074588, double* %12
store double 0.000000e+00, double* %14
%17 = load double, double* %2
store double %17, double* %15
%18 = load double, double* %15
%19 = fcmp olt double %18, 5.000000e-01
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = load double, double* %15
br label %25
22: ; preds = %1
%23 = load double, double* %15
%24 = fsub double 1.000000e+00, %23
br label %25
25: ; preds = %22, %20
%26 = phi double [ %21, %20 ], [ %24, %22 ]
store double %26, double* %16
%27 = load double, double* %16
%28 = fcmp olt double %27, 0x3BC79CA10C924223
br i1 %28, label %29, label %30
29: ; preds = %25
store double 9.990000e+02, double* %14
br label %67
30: ; preds = %25
%31 = load double, double* %16
%32 = load double, double* %16
%33 = fmul double %31, %32
%34 = fdiv double 1.000000e+00, %33
%35 = fptosi double %34 to i32
%36 = call i32 @log(i32 %35)
%37 = call double @sqrt(i32 %36)
store double %37, double* %13
%38 = load double, double* %13
%39 = load double, double* %13
%40 = load double, double* %7
%41 = load double, double* %6
%42 = call double @llvm.fmuladd.f64(double %39, double %40, double %41)
%43 = load double, double* %13
%44 = load double, double* %5
%45 = call double @llvm.fmuladd.f64(double %42, double %43, double %44)
%46 = load double, double* %13
%47 = load double, double* %4
%48 = call double @llvm.fmuladd.f64(double %45, double %46, double %47)
%49 = load double, double* %13
%50 = load double, double* %3
%51 = call double @llvm.fmuladd.f64(double %48, double %49, double %50)
%52 = load double, double* %13
%53 = load double, double* %12
%54 = load double, double* %11
%55 = call double @llvm.fmuladd.f64(double %52, double %53, double %54)
%56 = load double, double* %13
%57 = load double, double* %10
%58 = call double @llvm.fmuladd.f64(double %55, double %56, double %57)
%59 = load double, double* %13
%60 = load double, double* %9
%61 = call double @llvm.fmuladd.f64(double %58, double %59, double %60)
%62 = load double, double* %13
%63 = load double, double* %8
%64 = call double @llvm.fmuladd.f64(double %61, double %62, double %63)
%65 = fdiv double %51, %64
%66 = fadd double %38, %65
store double %66, double* %14
br label %67
67: ; preds = %30, %29
%68 = load double, double* %15
%69 = fcmp olt double %68, 5.000000e-01
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = load double, double* %14
%72 = fneg double %71
br label %75
73: ; preds = %67
%74 = load double, double* %14
br label %75
75: ; preds = %73, %70
%76 = phi double [ %72, %70 ], [ %74, %73 ]
ret double %76
}

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