#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 betainv(double, double, double);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
double finv(double p, int num, int den) {
  double x, k1, k2, a, b;
  if (p < 0. || p > 1.0) {
    printf("Probablity Values can only take values between 0.0 and 1.0");
    exit(1);
  }
  if (num <= 0 || den <= 0) {
    printf("Degrees Of Freedom should be positive real integers");
    exit(1);
  }
  k1 = (double)num;
  k2 = (double)den;
  a = betainv(p, k1 / 2., k2 / 2.);
  b = 1. - a;
  x = (k2 * a) / (k1 * b);
  if (p == 1.) {
    x = 1.79e+308;
  }
  return x;
}


x86 assembly (clang, -O0):
<finv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
ja     1168 <finv+0x38>
movsd  -0x8(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117e <finv+0x4e>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1192 <finv+0x62>
cmpl   $0x0,-0x10(%rbp)
jg     11a8 <finv+0x78>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe3a(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  0xe29(%rip),%xmm3
divsd  %xmm3,%xmm2
call   1040 <betainv@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe0b(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1246 <finv+0x116>
jp     1246 <finv+0x116>
movsd  0xdcf(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finv>:
sub    $0x18,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11d0 <finv+0xa0>
ucomisd 0xeb6(%rip),%xmm0
ja     11d0 <finv+0xa0>
test   %edi,%edi
jle    11d9 <finv+0xa9>
test   %esi,%esi
jle    11d9 <finv+0xa9>
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
cvtsi2sd %esi,%xmm3
movsd  0xe99(%rip),%xmm2
movsd  %xmm1,(%rsp)
mulsd  %xmm2,%xmm1
movsd  %xmm3,0x8(%rsp)
mulsd  %xmm3,%xmm2
movsd  %xmm0,0x10(%rsp)
call   1040 <betainv@plt>
movsd  0xe6b(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
ucomisd %xmm1,%xmm2
jne    11b0 <finv+0x80>
jp     11b0 <finv+0x80>
movsd  0xe65(%rip),%xmm0
add    $0x18,%rsp
ret
subsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
mulsd  (%rsp),%xmm1
divsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
lea    0xe41(%rip),%rdi
jmp    11e0 <finv+0xb0>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"Probablity Values can only take values between 0.0 and 1.0\00"
@.str.1 = [52 x i8] c"Degrees Of Freedom should be positive real integers\00"
define double @finv(double %0, i32 %1, i32 %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = load double, double* %4
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = load double, double* %4
%16 = fcmp ogt double %15, 1.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %14, %3
%18 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %14
%21 = load i32, i32* %5
%22 = icmp sle i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %6
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23, %20
%27 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %23
%30 = load i32, i32* %5
%31 = sitofp i32 %30 to double
store double %31, double* %8
%32 = load i32, i32* %6
%33 = sitofp i32 %32 to double
store double %33, double* %9
%34 = load double, double* %4
%35 = load double, double* %8
%36 = fdiv double %35, 2.000000e+00
%37 = load double, double* %9
%38 = fdiv double %37, 2.000000e+00
%39 = call double @betainv(double %34, double %36, double %38)
store double %39, double* %10
%40 = load double, double* %10
%41 = fsub double 1.000000e+00, %40
store double %41, double* %11
%42 = load double, double* %9
%43 = load double, double* %10
%44 = fmul double %42, %43
%45 = load double, double* %8
%46 = load double, double* %11
%47 = fmul double %45, %46
%48 = fdiv double %44, %47
store double %48, double* %7
%49 = load double, double* %4
%50 = fcmp oeq double %49, 1.000000e+00
br i1 %50, label %51, label %52
51: ; preds = %29
store double 1.790000e+308, double* %7
br label %52
52: ; preds = %51, %29
%53 = load double, double* %7
ret double %53
}

LLVM IR (-O2):
@.str = [59 x i8] c"Probablity Values can only take values between 0.0 and 1.0\00"
@.str.1 = [52 x i8] c"Degrees Of Freedom should be positive real integers\00"
define double @finv(double %0, i32 %1, i32 %2) {
%4 = fcmp olt double %0, 0.000000e+00
%5 = fcmp ogt double %0, 1.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = icmp slt i32 %1, 1
%12 = icmp slt i32 %2, 1
%13 = or i1 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = sitofp i32 %1 to double
%19 = sitofp i32 %2 to double
%20 = fmul double %18, 5.000000e-01
%21 = fmul double %19, 5.000000e-01
%22 = tail call double @betainv(double %0, double %20, double %21)
%23 = fsub double 1.000000e+00, %22
%24 = fmul double %22, %19
%25 = fmul double %23, %18
%26 = fdiv double %24, %25
%27 = fcmp oeq double %0, 1.000000e+00
%28 = select i1 %27, double 1.790000e+308, double %26
ret double %28
}