#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 */
double log(double);
double sqrt(double);
double CSPL_Special_Erf_inverse1(double x) {
  double sgn = (((x) > 0) ? 1 : ((x < 0) ? -1 : 0));
  double a = 0.147;
  double v1, v2, v3;
  v1 = 2.0 / (3.14159265359 * a);
  v2 = log(1.0 - x * x) / 2.0;
  v3 = log(1.0 - x * x) / a;
  return (sgn * sqrt(sqrt((v1 + v2) * (v1 + v2) - v3) - (v1 + v2)));
}


x86 assembly (clang, -O0):
<CSPL_Special_Erf_inverse1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    114c <CSPL_Special_Erf_inverse1+0x2c>
mov    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1165 <CSPL_Special_Erf_inverse1+0x45>
movsd  -0x8(%rbp),%xmm1
xorps  %xmm0,%xmm0
xor    %eax,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe8a(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xe75(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe37(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  0xe2e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdf0(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <log@plt>
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
addsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  -0x20(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CSPL_Special_Erf_inverse1>:
sub    $0x38,%rsp
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm1
cmpltsd %xmm2,%xmm1
movsd  0xec7(%rip),%xmm2
andpd  %xmm1,%xmm2
xorpd  %xmm3,%xmm3
cmpltsd %xmm0,%xmm3
movapd %xmm3,%xmm1
andnpd %xmm2,%xmm1
movsd  0xeb2(%rip),%xmm2
andpd  %xmm2,%xmm3
orpd   %xmm1,%xmm3
movapd %xmm3,0x20(%rsp)
mulsd  %xmm0,%xmm0
subsd  %xmm0,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
call   1030 <log@plt>
mulsd  0xe8d(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
call   1030 <log@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  0xe72(%rip),%xmm0
divsd  0xe72(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd 0xe64(%rip),%xmm0
jb     11cc <CSPL_Special_Erf_inverse1+0xac>
sqrtsd %xmm0,%xmm0
jmp    11d1 <CSPL_Special_Erf_inverse1+0xb1>
call   1040 <sqrt@plt>
subsd  0x8(%rsp),%xmm0
ucomisd 0xe49(%rip),%xmm0
jb     11e7 <CSPL_Special_Erf_inverse1+0xc7>
sqrtsd %xmm0,%xmm0
jmp    11ec <CSPL_Special_Erf_inverse1+0xcc>
call   1040 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @CSPL_Special_Erf_inverse1(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %2
%8 = load double, double* %2
%9 = fcmp ogt double %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %1
br label %16
11: ; preds = %1
%12 = load double, double* %2
%13 = fcmp olt double %12, 0.000000e+00
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 -1, i32 0
br label %16
16: ; preds = %11, %10
%17 = phi i32 [ 1, %10 ], [ %15, %11 ]
%18 = sitofp i32 %17 to double
store double %18, double* %3
store double 1.470000e-01, double* %4
%19 = load double, double* %4
%20 = fmul double 0x400921FB54442EEA, %19
%21 = fdiv double 2.000000e+00, %20
store double %21, double* %5
%22 = load double, double* %2
%23 = load double, double* %2
%24 = fneg double %22
%25 = call double @llvm.fmuladd.f64(double %24, double %23, double 1.000000e+00)
%26 = call double @log(double %25)
%27 = fdiv double %26, 2.000000e+00
store double %27, double* %6
%28 = load double, double* %2
%29 = load double, double* %2
%30 = fneg double %28
%31 = call double @llvm.fmuladd.f64(double %30, double %29, double 1.000000e+00)
%32 = call double @log(double %31)
%33 = load double, double* %4
%34 = fdiv double %32, %33
store double %34, double* %7
%35 = load double, double* %3
%36 = load double, double* %5
%37 = load double, double* %6
%38 = fadd double %36, %37
%39 = load double, double* %5
%40 = load double, double* %6
%41 = fadd double %39, %40
%42 = load double, double* %7
%43 = fneg double %42
%44 = call double @llvm.fmuladd.f64(double %38, double %41, double %43)
%45 = call double @sqrt(double %44)
%46 = load double, double* %5
%47 = load double, double* %6
%48 = fadd double %46, %47
%49 = fsub double %45, %48
%50 = call double @sqrt(double %49)
%51 = fmul double %35, %50
ret double %51
}

LLVM IR (-O2):
define double @CSPL_Special_Erf_inverse1(double %0) {
%2 = fcmp ogt double %0, 0.000000e+00
%3 = fcmp olt double %0, 0.000000e+00
%4 = sitofp i1 %3 to double
%5 = select i1 %2, double 1.000000e+00, double %4
%6 = fneg double %0
%7 = tail call double @llvm.fmuladd.f64(double %6, double %0, double 1.000000e+00)
%8 = tail call double @log(double %7)
%9 = fmul double %8, 5.000000e-01
%10 = tail call double @log(double %7)
%11 = fadd double %9, 0x401152AF46B7C51D
%12 = fdiv double %10, -1.470000e-01
%13 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %12)
%14 = tail call double @sqrt(double %13)
%15 = fsub double %14, %11
%16 = tail call double @sqrt(double %15)
%17 = fmul double %5, %16
ret double %17
}