#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 M_PI;
int log(int);
double sqrt(double);
double erfinv(double x) {
  if (x < 0)
    return -erfinv(-x);
  double a = .147;
  double y1 = (2 / (M_PI * a) + log(1 - x * x) / 2.0);
  double y2 = sqrt(y1 * y1 - (1 / a) * log(1 - x * x));
  double y3 = sqrt(y2 - y1);
  return y3;
}


x86 assembly (clang, -O0):
<erfinv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    118d <erfinv+0x5d>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <erfinv@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d1 <erfinv+0x1a1>
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e47(%rip),%rax
movsd  (%rax),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xe56(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe18(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
movsd  0xe02(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdd1(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd9a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<erfinv>:
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1159 <erfinv+0x29>
xorpd  0xee9(%rip),%xmm0
call   1030 <erfinv@plt>
xorpd  0xedc(%rip),%xmm0
jmp    1201 <erfinv+0xd1>
mov    0x2e88(%rip),%rax
movsd  (%rax),%xmm1
mulsd  0xe94(%rip),%xmm1
movsd  0xe94(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm0,%xmm0
movsd  0xe86(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebx
mov    %ebx,%edi
call   1040 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe70(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <log@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe56(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd 0xe48(%rip),%xmm0
jb     11e8 <erfinv+0xb8>
sqrtsd %xmm0,%xmm0
jmp    11ed <erfinv+0xbd>
call   1050 <sqrt@plt>
subsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1207 <erfinv+0xd7>
sqrtsd %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
ret
add    $0x10,%rsp
pop    %rbx
jmp    1050 <sqrt@plt>

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @erfinv(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %5, label %9
3: ; preds = %9, %5
%4 = phi double [ %8, %5 ], [ %26, %9 ]
ret double %4
5: ; preds = %1
%6 = fneg double %0
%7 = tail call double @erfinv(double %6)
%8 = fneg double %7
br label %3
9: ; preds = %1
%10 = load double, double* @M_PI
%11 = fmul double %10, 1.470000e-01
%12 = fdiv double 2.000000e+00, %11
%13 = fneg double %0
%14 = tail call double @llvm.fmuladd.f64(double %13, double %0, double 1.000000e+00)
%15 = fptosi double %14 to i32
%16 = tail call i32 @log(i32 %15)
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 5.000000e-01
%19 = fadd double %12, %18
%20 = tail call i32 @log(i32 %15)
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 0xC01B35FC845A8ECE
%23 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %22)
%24 = tail call double @sqrt(double %23)
%25 = fsub double %24, %19
%26 = tail call double @sqrt(double %25)
br label %3
}