#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 erff_(double);
double fabs(double);
double sqrt(double);
double inverff(double p) {
  double xlow, xhigh, xtry, ptry;
  if (p == 0) {
    return 0.0;
  }
  if (p <= -1.0) {
    return -sqrt(-1.0);
  } else if (p >= 1.0) {
    return sqrt(1.0);
  }
  if (p < 0) {
    xhigh = 0.0;
    xlow = -0.5;
    while (erff_(xlow) > p) {
      xhigh = xlow;
      xlow = (xlow - 1.0) / 2.;
    }
    xtry = (xlow + xhigh) / 2.;
  } else {
    xlow = 0.0;
    xhigh = 0.5;
    while (erff_(xhigh) < p) {
      xlow = xhigh;
      xhigh = (xhigh + 1.0) / 2.;
    }
    xtry = (xlow + xhigh) / 2.;
  }
  do {
    ptry = erff_(xtry);
    if (fabs(ptry - p) < 3.0e-9)
      return xtry;
    if (ptry < p) {
      xlow = xtry;
      xtry = (xlow + xhigh) / 2.;
    } else {
      xhigh = xtry;
      xtry = (xlow + xhigh) / 2.;
    }
  } while (1);
}


x86 assembly (clang, -O0):
<inverff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1152 <inverff+0x32>
jp     1152 <inverff+0x32>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1389 <inverff+0x269>
movsd  0xea6(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1193 <inverff+0x73>
movsd  0xe93(%rip),%xmm0
call   1030 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1389 <inverff+0x269>
movsd  -0x10(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11c1 <inverff+0xa1>
movsd  0xe56(%rip),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1389 <inverff+0x269>
jmp    11c6 <inverff+0xa6>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    124f <inverff+0x12f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe3c(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <erff_@plt>
ucomisd -0x10(%rbp),%xmm0
jbe    122f <inverff+0x10f>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdf3(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdf7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11e9 <inverff+0xc9>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12c8 <inverff+0x1a8>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdb1(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <erff_@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ad <inverff+0x18d>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd76(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xd79(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1264 <inverff+0x144>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xd59(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12cd <inverff+0x1ad>
movsd  -0x28(%rbp),%xmm0
call   1040 <erff_@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movaps 0xd43(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd2f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1312 <inverff+0x1f2>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1389 <inverff+0x269>
movsd  -0x30(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1350 <inverff+0x230>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xcd6(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1375 <inverff+0x255>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xcac(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    137a <inverff+0x25a>
mov    $0x1,%al
test   $0x1,%al
jne    12cd <inverff+0x1ad>
jmp    1389 <inverff+0x269>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inverff>:
sub    $0x38,%rsp
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jne    1134 <inverff+0x14>
jnp    120f <inverff+0xef>
movapd %xmm0,%xmm1
movsd  0xec0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    11f6 <inverff+0xd6>
movsd  0xeb6(%rip),%xmm3
ucomisd %xmm3,%xmm1
jae    120f <inverff+0xef>
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
jbe    1218 <inverff+0xf8>
movsd  0xea0(%rip),%xmm0
call   1040 <erff_@plt>
movsd  0xe93(%rip),%xmm1
xorps  %xmm2,%xmm2
movsd  %xmm2,(%rsp)
movsd  0x8(%rsp),%xmm2
ucomisd %xmm2,%xmm0
jbe    11e2 <inverff+0xc2>
movsd  0xe77(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,(%rsp)
addsd  0xe43(%rip),%xmm1
mulsd  0xe4b(%rip),%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1040 <erff_@plt>
movapd 0x10(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm0
ja     11b0 <inverff+0x90>
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
addsd  (%rsp),%xmm0
jmp    1294 <inverff+0x174>
movsd  0xe02(%rip),%xmm0
call   1030 <sqrt@plt>
movapd %xmm0,%xmm3
xorpd  0xe21(%rip),%xmm3
movapd %xmm3,%xmm0
add    $0x38,%rsp
ret
movsd  0xdf0(%rip),%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm1,0x10(%rsp)
call   1040 <erff_@plt>
movsd  0xdd9(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
ucomisd %xmm0,%xmm2
jbe    1285 <inverff+0x165>
movsd  0xdc5(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movapd %xmm1,0x10(%rsp)
addsd  0xdaa(%rip),%xmm1
mulsd  0xdaa(%rip),%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1040 <erff_@plt>
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
ucomisd %xmm0,%xmm2
ja     1250 <inverff+0x130>
movapd 0x10(%rsp),%xmm0
movsd  %xmm1,(%rsp)
addsd  %xmm1,%xmm0
mulsd  0xd74(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
call   1040 <erff_@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm2,%xmm1
andpd  0xd83(%rip),%xmm1
movsd  0xd5b(%rip),%xmm3
ucomisd %xmm1,%xmm3
jbe    12d6 <inverff+0x1b6>
movapd 0x20(%rsp),%xmm3
jmp    120f <inverff+0xef>
movapd 0x20(%rsp),%xmm4
jmp    134d <inverff+0x22d>
xchg   %ax,%ax
movsd  %xmm1,(%rsp)
cmpltsd %xmm2,%xmm0
movapd %xmm0,%xmm1
andpd  %xmm4,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
addsd  %xmm4,%xmm5
mulsd  0xd04(%rip),%xmm5
movapd %xmm5,0x20(%rsp)
movapd %xmm5,%xmm0
call   1040 <erff_@plt>
movapd 0x20(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
andpd  0xd09(%rip),%xmm1
movsd  0xce1(%rip),%xmm4
ucomisd %xmm1,%xmm4
movapd %xmm3,%xmm4
ja     120f <inverff+0xef>
ucomisd %xmm0,%xmm2
movsd  (%rsp),%xmm1
movapd %xmm1,%xmm5
movapd 0x10(%rsp),%xmm3
ja     12e0 <inverff+0x1c0>
movapd %xmm4,%xmm1
movapd %xmm3,%xmm5
jmp    12e0 <inverff+0x1c0>

LLVM IR (-O0):
define double @inverff(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 oeq double %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %1
store double 0.000000e+00, double* %2
br label %87
11: ; preds = %1
%12 = load double, double* %3
%13 = fcmp ole double %12, -1.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call double @sqrt(double -1.000000e+00)
%16 = fneg double %15
store double %16, double* %2
br label %87
17: ; preds = %11
%18 = load double, double* %3
%19 = fcmp oge double %18, 1.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call double @sqrt(double 1.000000e+00)
store double %21, double* %2
br label %87
22: ; preds = %17
br label %23
23: ; preds = %22
%24 = load double, double* %3
%25 = fcmp olt double %24, 0.000000e+00
br i1 %25, label %26, label %42
26: ; preds = %23
store double 0.000000e+00, double* %5
store double -5.000000e-01, double* %4
br label %27
27: ; preds = %32, %26
%28 = load double, double* %4
%29 = call double @erff_(double %28)
%30 = load double, double* %3
%31 = fcmp ogt double %29, %30
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load double, double* %4
store double %33, double* %5
%34 = load double, double* %4
%35 = fsub double %34, 1.000000e+00
%36 = fdiv double %35, 2.000000e+00
store double %36, double* %4
br label %27
37: ; preds = %27
%38 = load double, double* %4
%39 = load double, double* %5
%40 = fadd double %38, %39
%41 = fdiv double %40, 2.000000e+00
store double %41, double* %6
br label %58
42: ; preds = %23
store double 0.000000e+00, double* %4
store double 5.000000e-01, double* %5
br label %43
43: ; preds = %48, %42
%44 = load double, double* %5
%45 = call double @erff_(double %44)
%46 = load double, double* %3
%47 = fcmp olt double %45, %46
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load double, double* %5
store double %49, double* %4
%50 = load double, double* %5
%51 = fadd double %50, 1.000000e+00
%52 = fdiv double %51, 2.000000e+00
store double %52, double* %5
br label %43
53: ; preds = %43
%54 = load double, double* %4
%55 = load double, double* %5
%56 = fadd double %54, %55
%57 = fdiv double %56, 2.000000e+00
store double %57, double* %6
br label %58
58: ; preds = %53, %37
br label %59
59: ; preds = %86, %58
%60 = load double, double* %6
%61 = call double @erff_(double %60)
store double %61, double* %7
%62 = load double, double* %7
%63 = load double, double* %3
%64 = fsub double %62, %63
%65 = call double @llvm.fabs.f64(double %64)
%66 = fcmp olt double %65, 3.000000e-09
br i1 %66, label %67, label %69
67: ; preds = %59
%68 = load double, double* %6
store double %68, double* %2
br label %87
69: ; preds = %59
%70 = load double, double* %7
%71 = load double, double* %3
%72 = fcmp olt double %70, %71
br i1 %72, label %73, label %79
73: ; preds = %69
%74 = load double, double* %6
store double %74, double* %4
%75 = load double, double* %4
%76 = load double, double* %5
%77 = fadd double %75, %76
%78 = fdiv double %77, 2.000000e+00
store double %78, double* %6
br label %85
79: ; preds = %69
%80 = load double, double* %6
store double %80, double* %5
%81 = load double, double* %4
%82 = load double, double* %5
%83 = fadd double %81, %82
%84 = fdiv double %83, 2.000000e+00
store double %84, double* %6
br label %85
85: ; preds = %79, %73
br label %86
86: ; preds = %85
br i1 true, label %59, label %87
87: ; preds = %10, %14, %20, %67, %86
%88 = load double, double* %2
ret double %88
}

LLVM IR (-O2):
define double @inverff(double %0) {
%2 = fcmp oeq double %0, 0.000000e+00
br i1 %2, label %62, label %3
3: ; preds = %1
%4 = fcmp ugt double %0, -1.000000e+00
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = tail call double @sqrt(double -1.000000e+00)
%7 = fneg double %6
br label %62
8: ; preds = %3
%9 = fcmp ult double %0, 1.000000e+00
br i1 %9, label %10, label %62
10: ; preds = %8
%11 = fcmp olt double %0, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = tail call double @erff_(double 5.000000e-01)
%14 = fcmp olt double %13, %0
br i1 %14, label %28, label %34
15: ; preds = %10
%16 = tail call double @erff_(double -5.000000e-01)
%17 = fcmp ogt double %16, %0
br i1 %17, label %18, label %24
18: ; preds = %15, %18
%19 = phi double [ %21, %18 ], [ -5.000000e-01, %15 ]
%20 = fadd double %19, -1.000000e+00
%21 = fmul double %20, 5.000000e-01
%22 = tail call double @erff_(double %21)
%23 = fcmp ogt double %22, %0
br i1 %23, label %18, label %24
24: ; preds = %18, %15
%25 = phi double [ -5.000000e-01, %15 ], [ %21, %18 ]
%26 = phi double [ 0.000000e+00, %15 ], [ %19, %18 ]
%27 = fadd double %25, %26
br label %38
28: ; preds = %12, %28
%29 = phi double [ %31, %28 ], [ 5.000000e-01, %12 ]
%30 = fadd double %29, 1.000000e+00
%31 = fmul double %30, 5.000000e-01
%32 = tail call double @erff_(double %31)
%33 = fcmp olt double %32, %0
br i1 %33, label %28, label %34
34: ; preds = %28, %12
%35 = phi double [ 0.000000e+00, %12 ], [ %29, %28 ]
%36 = phi double [ 5.000000e-01, %12 ], [ %31, %28 ]
%37 = fadd double %35, %36
br label %38
38: ; preds = %34, %24
%39 = phi double [ %25, %24 ], [ %35, %34 ]
%40 = phi double [ %26, %24 ], [ %36, %34 ]
%41 = phi double [ %27, %24 ], [ %37, %34 ]
%42 = fmul double %41, 5.000000e-01
%43 = tail call double @erff_(double %42)
%44 = fsub double %43, %0
%45 = tail call double @llvm.fabs.f64(double %44)
%46 = fcmp olt double %45, 3.000000e-09
br i1 %46, label %62, label %47
47: ; preds = %38, %47
%48 = phi double [ %58, %47 ], [ %43, %38 ]
%49 = phi double [ %57, %47 ], [ %42, %38 ]
%50 = phi double [ %54, %47 ], [ %40, %38 ]
%51 = phi double [ %53, %47 ], [ %39, %38 ]
%52 = fcmp olt double %48, %0
%53 = select i1 %52, double %49, double %51
%54 = select i1 %52, double %50, double %49
%55 = select i1 %52, double %50, double %51
%56 = fadd double %49, %55
%57 = fmul double %56, 5.000000e-01
%58 = tail call double @erff_(double %57)
%59 = fsub double %58, %0
%60 = tail call double @llvm.fabs.f64(double %59)
%61 = fcmp olt double %60, 3.000000e-09
br i1 %61, label %62, label %47
62: ; preds = %47, %38, %8, %1, %5
%63 = phi double [ %7, %5 ], [ 0.000000e+00, %1 ], [ 1.000000e+00, %8 ], [ %42, %38 ], [ %57, %47 ]
ret double %63
}