#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 log(int);
double sqrt(int);
double standardGaussianInvCDF(double prob) {
  static double C[3] = {2.515517, 0.802853, 0.010328};
  static double d[4] = {0, 1.432788, 0.189269, 0.001308};
  double W, WW, WWW, resul;
  if (prob <= 0.5)
    W = sqrt(-2 * log(prob));
  else
    W = sqrt(-2 * log(1 - prob));
  WW = W * W;
  WWW = WW * W;
  resul = W - (C[0] + C[1] * W + C[2] * WW) /
                  (1 + d[1] * W + d[2] * WW + d[3] * WWW);
  if (prob > 0.5)
    resul = -resul;
  return resul;
}


x86 assembly (clang, -O0):
<standardGaussianInvCDF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     115f <standardGaussianInvCDF+0x3f>
cvttsd2si -0x8(%rbp),%edi
call   1030 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
jmp    1185 <standardGaussianInvCDF+0x65>
movsd  0xea1(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0x2e90(%rip),%xmm1
movsd  0x2e90(%rip),%xmm2
movsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  0x2e83(%rip),%xmm1
movsd  -0x18(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0x2e86(%rip),%xmm2
movsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe15(%rip),%xmm3
addsd  %xmm3,%xmm2
movsd  0x2e71(%rip),%xmm3
movsd  -0x18(%rbp),%xmm4
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
movsd  0x2e64(%rip),%xmm2
movsd  -0x20(%rbp),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xdc5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1266 <standardGaussianInvCDF+0x146>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<standardGaussianInvCDF>:
sub    $0x18,%rsp
movapd %xmm0,(%rsp)
movsd  0xecf(%rip),%xmm2
subsd  %xmm0,%xmm2
movsd  0xecb(%rip),%xmm3
movapd %xmm0,%xmm1
cmpnlesd %xmm3,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <log@plt>
lea    (%rax,%rax,1),%edi
neg    %edi
call   1040 <sqrt@plt>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movsd  0xe93(%rip),%xmm3
mulsd  %xmm0,%xmm3
addsd  0xe77(%rip),%xmm3
movapd %xmm0,%xmm4
unpcklpd %xmm1,%xmm4
movapd 0xe87(%rip),%xmm5
unpcklpd %xmm3,%xmm5
mulpd  0xe8b(%rip),%xmm4
addpd  %xmm5,%xmm4
unpcklpd %xmm2,%xmm1
mulpd  0xe8b(%rip),%xmm1
addpd  %xmm4,%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movapd 0xe7f(%rip),%xmm1
xorpd  %xmm0,%xmm1
movsd  0xe2b(%rip),%xmm3
cmpltsd (%rsp),%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,%xmm0
add    $0x18,%rsp
ret

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

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