#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 betai(double, double, double);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double invfisher(double nu1, double nu2, double conf) {
  int jmax = 40, j;
  double x1, x2, f, fmid, rtbis, dx, xmid;
  double xacc = 0.01 * nu2 / (nu2 + nu1 * 200.0);
  x1 = nu2 / (nu2 + nu1 * 10000.0);
  f = (1.0 - betai(nu2 / 2.0, nu1 / 2.0, x1)) - conf;
  x2 = nu2 / (nu2 + nu1 * 1.0);
  fmid = (1.0 - betai(nu2 / 2.0, nu1 / 2.0, x2)) - conf;
  if (f * fmid >= 0) {
    fprintf(stderr, "ERROR invfisher: root must be bracketed");
    exit(10);
  }
  if (f < 0) {
    rtbis = x1;
    dx = x2 - x1;
  } else {
    rtbis = x2;
    dx = x1 - x2;
  }
  j = 0;
  while (j < jmax) {
    dx = dx * 0.5;
    xmid = rtbis + dx;
    fmid = (1.0 - betai(nu2 / 2.0, nu1 / 2.0, xmid)) - conf;
    if (fmid <= 0)
      rtbis = xmid;
    j = j + 1;
    if (((dx) > (-dx) ? (dx) : (-dx)) < xacc || fmid == 0)
      break;
  }
  if (j > jmax)
    fprintf(stderr, "WARNING invfisher: root finding did not converge. Error "
                    "estimates likely to be meaningless");
  return (nu2 / xmid - nu2) / nu1;
}


x86 assembly (clang, -O0):
<invfisher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movl   $0x28,-0x1c(%rbp)
movsd  0xeca(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
movsd  0xeab(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
movsd  0xe7b(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe55(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xe44(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm2
call   1040 <betai@plt>
movaps %xmm0,%xmm1
movsd  0xe23(%rip),%xmm0
subsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdf4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xde3(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x30(%rbp),%xmm2
call   1040 <betai@plt>
movaps %xmm0,%xmm1
movsd  0xdc2(%rip),%xmm0
subsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1282 <invfisher+0x152>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
lea    0xdbd(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xa,%edi
call   1050 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    12ae <invfisher+0x17e>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12c7 <invfisher+0x197>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    13f2 <invfisher+0x2c2>
movsd  0xd46(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd00(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xcef(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x58(%rbp),%xmm2
call   1040 <betai@plt>
movaps %xmm0,%xmm1
movsd  0xcce(%rip),%xmm0
subsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jb     1358 <invfisher+0x228>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
ucomisd %xmm1,%xmm0
jbe    139b <invfisher+0x26b>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    13bc <invfisher+0x28c>
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     13e8 <invfisher+0x2b8>
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13ed <invfisher+0x2bd>
jp     13ed <invfisher+0x2bd>
jmp    13f2 <invfisher+0x2c2>
jmp    12ce <invfisher+0x19e>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1413 <invfisher+0x2e3>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
lea    0xc4a(%rip),%rsi
call   1030 <fprintf@plt>
movsd  -0x10(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invfisher>:
push   %rbx
sub    $0x70,%rsp
movaps %xmm2,0x60(%rsp)
movapd %xmm1,%xmm4
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  0xebe(%rip),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
movapd %xmm1,%xmm2
divsd  %xmm3,%xmm2
movsd  0xeae(%rip),%xmm3
mulsd  %xmm3,%xmm4
movsd  %xmm4,0x28(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x20(%rsp)
movapd %xmm4,%xmm0
movapd %xmm2,0x50(%rsp)
call   1040 <betai@plt>
movapd %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm2
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  %xmm2,0x30(%rsp)
call   1040 <betai@plt>
movapd 0x40(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movapd 0xe5c(%rip),%xmm5
subpd  %xmm1,%xmm5
movapd 0x60(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
subpd  %xmm0,%xmm5
movapd %xmm5,%xmm1
unpckhpd %xmm5,%xmm1
mulsd  %xmm5,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jae    133b <invfisher+0x20b>
movsd  0xdf8(%rip),%xmm1
movsd  0x8(%rsp),%xmm3
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0xde8(%rip),%xmm2
mulsd  0x10(%rsp),%xmm2
addsd  %xmm3,%xmm2
ucomisd %xmm5,%xmm0
movsd  0x30(%rsp),%xmm6
movapd %xmm6,%xmm1
movapd 0x50(%rsp),%xmm4
subsd  %xmm4,%xmm1
movapd %xmm4,%xmm3
subsd  %xmm6,%xmm3
ja     1250 <invfisher+0x120>
movapd %xmm6,%xmm4
movsd  0x18(%rsp),%xmm6
divsd  %xmm2,%xmm6
movsd  %xmm6,0x18(%rsp)
cmpltsd %xmm0,%xmm5
andpd  %xmm5,%xmm1
andnpd %xmm3,%xmm5
orpd   %xmm1,%xmm5
mov    $0x28,%ebx
cs nopw 0x0(%rax,%rax,1)
movapd %xmm4,0x50(%rsp)
mulsd  0xd8a(%rip),%xmm5
movapd %xmm5,0x40(%rsp)
movapd %xmm4,%xmm2
addsd  %xmm5,%xmm2
movapd %xmm2,0x30(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <betai@plt>
movapd 0x30(%rsp),%xmm3
movapd 0x40(%rsp),%xmm5
movapd 0x50(%rsp),%xmm4
movapd %xmm5,%xmm1
xorpd  0xd6f(%rip),%xmm1
movapd %xmm5,%xmm2
maxsd  %xmm1,%xmm2
movsd  0x18(%rsp),%xmm1
ucomisd %xmm2,%xmm1
xorpd  %xmm2,%xmm2
ja     131d <invfisher+0x1ed>
movsd  0xd2f(%rip),%xmm1
subsd  %xmm0,%xmm1
subsd  0x60(%rsp),%xmm1
ucomisd %xmm2,%xmm1
jne    1303 <invfisher+0x1d3>
jnp    131d <invfisher+0x1ed>
cmpnlesd %xmm2,%xmm1
andpd  %xmm1,%xmm4
andnpd %xmm3,%xmm1
orpd   %xmm1,%xmm4
add    $0xffffffff,%ebx
jne    1280 <invfisher+0x150>
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
divsd  %xmm3,%xmm0
subsd  %xmm1,%xmm0
divsd  0x10(%rsp),%xmm0
add    $0x70,%rsp
pop    %rbx
ret
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
lea    0xd05(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xa,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [40 x i8] c"ERROR invfisher: root must be bracketed\00"
@.str.1 = [91 x i8] c"WARNING invfisher: root finding did not converge. Error estimates likely to be meaningless\00"
define double @invfisher(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%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* %4
store double %1, double* %5
store double %2, double* %6
store i32 40, i32* %7
%17 = load double, double* %5
%18 = fmul double 1.000000e-02, %17
%19 = load double, double* %5
%20 = load double, double* %4
%21 = call double @llvm.fmuladd.f64(double %20, double 2.000000e+02, double %19)
%22 = fdiv double %18, %21
store double %22, double* %16
%23 = load double, double* %5
%24 = load double, double* %5
%25 = load double, double* %4
%26 = call double @llvm.fmuladd.f64(double %25, double 1.000000e+04, double %24)
%27 = fdiv double %23, %26
store double %27, double* %9
%28 = load double, double* %5
%29 = fdiv double %28, 2.000000e+00
%30 = load double, double* %4
%31 = fdiv double %30, 2.000000e+00
%32 = load double, double* %9
%33 = call double @betai(double %29, double %31, double %32)
%34 = fsub double 1.000000e+00, %33
%35 = load double, double* %6
%36 = fsub double %34, %35
store double %36, double* %11
%37 = load double, double* %5
%38 = load double, double* %5
%39 = load double, double* %4
%40 = call double @llvm.fmuladd.f64(double %39, double 1.000000e+00, double %38)
%41 = fdiv double %37, %40
store double %41, double* %10
%42 = load double, double* %5
%43 = fdiv double %42, 2.000000e+00
%44 = load double, double* %4
%45 = fdiv double %44, 2.000000e+00
%46 = load double, double* %10
%47 = call double @betai(double %43, double %45, double %46)
%48 = fsub double 1.000000e+00, %47
%49 = load double, double* %6
%50 = fsub double %48, %49
store double %50, double* %12
%51 = load double, double* %11
%52 = load double, double* %12
%53 = fmul double %51, %52
%54 = fcmp oge double %53, 0.000000e+00
br i1 %54, label %55, label %59
55: ; preds = %3
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%58 = call i32 @exit(i32 10)
unreachable
59: ; preds = %3
%60 = load double, double* %11
%61 = fcmp olt double %60, 0.000000e+00
br i1 %61, label %62, label %67
62: ; preds = %59
%63 = load double, double* %9
store double %63, double* %13
%64 = load double, double* %10
%65 = load double, double* %9
%66 = fsub double %64, %65
store double %66, double* %14
br label %72
67: ; preds = %59
%68 = load double, double* %10
store double %68, double* %13
%69 = load double, double* %9
%70 = load double, double* %10
%71 = fsub double %69, %70
store double %71, double* %14
br label %72
72: ; preds = %67, %62
store i32 0, i32* %8
br label %73
73: ; preds = %116, %72
%74 = load i32, i32* %8
%75 = load i32, i32* %7
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %117
77: ; preds = %73
%78 = load double, double* %14
%79 = fmul double %78, 5.000000e-01
store double %79, double* %14
%80 = load double, double* %13
%81 = load double, double* %14
%82 = fadd double %80, %81
store double %82, double* %15
%83 = load double, double* %5
%84 = fdiv double %83, 2.000000e+00
%85 = load double, double* %4
%86 = fdiv double %85, 2.000000e+00
%87 = load double, double* %15
%88 = call double @betai(double %84, double %86, double %87)
%89 = fsub double 1.000000e+00, %88
%90 = load double, double* %6
%91 = fsub double %89, %90
store double %91, double* %12
%92 = load double, double* %12
%93 = fcmp ole double %92, 0.000000e+00
br i1 %93, label %94, label %96
94: ; preds = %77
%95 = load double, double* %15
store double %95, double* %13
br label %96
96: ; preds = %94, %77
%97 = load i32, i32* %8
%98 = add nsw i32 %97, 1
store i32 %98, i32* %8
%99 = load double, double* %14
%100 = load double, double* %14
%101 = fneg double %100
%102 = fcmp ogt double %99, %101
br i1 %102, label %103, label %105
103: ; preds = %96
%104 = load double, double* %14
br label %108
105: ; preds = %96
%106 = load double, double* %14
%107 = fneg double %106
br label %108
108: ; preds = %105, %103
%109 = phi double [ %104, %103 ], [ %107, %105 ]
%110 = load double, double* %16
%111 = fcmp olt double %109, %110
br i1 %111, label %115, label %112
112: ; preds = %108
%113 = load double, double* %12
%114 = fcmp oeq double %113, 0.000000e+00
br i1 %114, label %115, label %116
115: ; preds = %112, %108
br label %117
116: ; preds = %112
br label %73
117: ; preds = %115, %73
%118 = load i32, i32* %8
%119 = load i32, i32* %7
%120 = icmp sgt i32 %118, %119
br i1 %120, label %121, label %124
121: ; preds = %117
%122 = load i32, i32* @stderr
%123 = call i32 @fprintf(i32 %122, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.1, i64 0, i64 0))
br label %124
124: ; preds = %121, %117
%125 = load double, double* %5
%126 = load double, double* %15
%127 = fdiv double %125, %126
%128 = load double, double* %5
%129 = fsub double %127, %128
%130 = load double, double* %4
%131 = fdiv double %129, %130
ret double %131
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"ERROR invfisher: root must be bracketed\00"
define double @invfisher(double %0, double %1, double %2) {
%4 = fmul double %1, 1.000000e-02
%5 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+02, double %1)
%6 = fdiv double %4, %5
%7 = tail call double @llvm.fmuladd.f64(double %0, double 1.000000e+04, double %1)
%8 = fdiv double %1, %7
%9 = fmul double %1, 5.000000e-01
%10 = fmul double %0, 5.000000e-01
%11 = tail call double @betai(double %9, double %10, double %8)
%12 = fadd double %0, %1
%13 = fdiv double %1, %12
%14 = tail call double @betai(double %9, double %10, double %13)
%15 = insertelement <2 x double> poison, double %11, i64 0
%16 = insertelement <2 x double> %15, double %14, i64 1
%17 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %16
%18 = insertelement <2 x double> poison, double %2, i64 0
%19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%20 = fsub <2 x double> %17, %19
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%22 = fmul <2 x double> %20, %21
%23 = extractelement <2 x double> %22, i64 0
%24 = fcmp ult double %23, 0.000000e+00
br i1 %24, label %29, label %25
25: ; preds = %3
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%28 = tail call i32 @exit(i32 10)
unreachable
29: ; preds = %3
%30 = extractelement <2 x double> %20, i64 0
%31 = fcmp olt double %30, 0.000000e+00
%32 = fsub double %13, %8
%33 = fsub double %8, %13
%34 = select i1 %31, double %8, double %13
%35 = select i1 %31, double %32, double %33
br label %40
36: ; preds = %40
%37 = fcmp ugt double %48, 0.000000e+00
%38 = select i1 %37, double %43, double %45
%39 = icmp eq i32 %49, 40
br i1 %39, label %56, label %40
40: ; preds = %29, %36
%41 = phi i32 [ 0, %29 ], [ %49, %36 ]
%42 = phi double [ %35, %29 ], [ %44, %36 ]
%43 = phi double [ %34, %29 ], [ %38, %36 ]
%44 = fmul double %42, 5.000000e-01
%45 = fadd double %43, %44
%46 = tail call double @betai(double %9, double %10, double %45)
%47 = fsub double 1.000000e+00, %46
%48 = fsub double %47, %2
%49 = add nuw nsw i32 %41, 1
%50 = fneg double %44
%51 = fcmp ogt double %44, %50
%52 = select i1 %51, double %44, double %50
%53 = fcmp olt double %52, %6
%54 = fcmp oeq double %48, 0.000000e+00
%55 = select i1 %53, i1 true, i1 %54
br i1 %55, label %56, label %36
56: ; preds = %40, %36
%57 = fdiv double %1, %45
%58 = fsub double %57, %1
%59 = fdiv double %58, %0
ret double %59
}