#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 */
int /*<<< orphan*/ exit(int);
double ibeta(double, double, double);
double ibetac(double, double, double);
int /*<<< orphan*/ printf(char *);
double fcdf(double x, int num, int den) {
  double oup, k1, k2, y;
  if (num <= 0 || den <= 0) {
    printf("Degrees Of Freedom should be positive real integers");
    exit(1);
  }
  if (x < 0.) {
    printf("The range of distribution only takes non-negative and real values");
    exit(1);
  }
  k1 = (double)num;
  k2 = (double)den;
  if (k1 * x < k2) {
    y = k1 * x / (k2 + k1 * x);
    oup = ibeta(y, k1 / 2., k2 / 2.);
  } else {
    y = k2 / (k2 + k1 * x);
    oup = ibetac(y, k2 / 2., k1 / 2.);
  }
  return oup;
}


x86 assembly (clang, -O0):
<fcdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1167 <fcdf+0x27>
cmpl   $0x0,-0x10(%rbp)
jg     117d <fcdf+0x3d>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11a1 <fcdf+0x61>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122e <fcdf+0xee>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xdf6(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  0xde5(%rip),%xmm3
divsd  %xmm3,%xmm2
call   1050 <ibeta@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1284 <fcdf+0x144>
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xd9b(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xd8a(%rip),%xmm3
divsd  %xmm3,%xmm2
call   1030 <ibetac@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcdf>:
push   %rax
test   %edi,%edi
jle    11b1 <fcdf+0x71>
test   %esi,%esi
jle    11b1 <fcdf+0x71>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11ba <fcdf+0x7a>
cvtsi2sd %edi,%xmm2
cvtsi2sd %esi,%xmm3
mulsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm3
movapd %xmm0,%xmm1
addsd  %xmm3,%xmm1
jbe    118f <fcdf+0x4f>
divsd  %xmm1,%xmm0
movsd  0xe87(%rip),%xmm1
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm3
movapd %xmm2,%xmm1
movapd %xmm3,%xmm2
pop    %rax
jmp    1050 <ibeta@plt>
movapd %xmm3,%xmm0
divsd  %xmm1,%xmm0
movsd  0xe61(%rip),%xmm1
mulsd  %xmm1,%xmm3
mulsd  %xmm1,%xmm2
movapd %xmm3,%xmm1
pop    %rax
jmp    1030 <ibetac@plt>
lea    0xe50(%rip),%rdi
jmp    11c1 <fcdf+0x81>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"Degrees Of Freedom should be positive real integers\00"
@.str.1 = [66 x i8] c"The range of distribution only takes non-negative and real values\00"
define double @fcdf(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
store double %0, double* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %5
%12 = icmp sle i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = load i32, i32* %6
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13, %3
%17 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %13
%20 = load double, double* %4
%21 = fcmp olt double %20, 0.000000e+00
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %19
%26 = load i32, i32* %5
%27 = sitofp i32 %26 to double
store double %27, double* %8
%28 = load i32, i32* %6
%29 = sitofp i32 %28 to double
store double %29, double* %9
%30 = load double, double* %8
%31 = load double, double* %4
%32 = fmul double %30, %31
%33 = load double, double* %9
%34 = fcmp olt double %32, %33
br i1 %34, label %35, label %50
35: ; preds = %25
%36 = load double, double* %8
%37 = load double, double* %4
%38 = fmul double %36, %37
%39 = load double, double* %9
%40 = load double, double* %8
%41 = load double, double* %4
%42 = call double @llvm.fmuladd.f64(double %40, double %41, double %39)
%43 = fdiv double %38, %42
store double %43, double* %10
%44 = load double, double* %10
%45 = load double, double* %8
%46 = fdiv double %45, 2.000000e+00
%47 = load double, double* %9
%48 = fdiv double %47, 2.000000e+00
%49 = call double @ibeta(double %44, double %46, double %48)
store double %49, double* %7
br label %63
50: ; preds = %25
%51 = load double, double* %9
%52 = load double, double* %9
%53 = load double, double* %8
%54 = load double, double* %4
%55 = call double @llvm.fmuladd.f64(double %53, double %54, double %52)
%56 = fdiv double %51, %55
store double %56, double* %10
%57 = load double, double* %10
%58 = load double, double* %9
%59 = fdiv double %58, 2.000000e+00
%60 = load double, double* %8
%61 = fdiv double %60, 2.000000e+00
%62 = call double @ibetac(double %57, double %59, double %61)
store double %62, double* %7
br label %63
63: ; preds = %50, %35
%64 = load double, double* %7
ret double %64
}

LLVM IR (-O2):
@.str = [52 x i8] c"Degrees Of Freedom should be positive real integers\00"
@.str.1 = [66 x i8] c"The range of distribution only takes non-negative and real values\00"
define double @fcdf(double %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 1
%5 = icmp slt i32 %2, 1
%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 ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = fcmp olt double %0, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %10
%16 = sitofp i32 %1 to double
%17 = sitofp i32 %2 to double
%18 = fmul double %16, %0
%19 = fcmp olt double %18, %17
%20 = tail call double @llvm.fmuladd.f64(double %16, double %0, double %17)
br i1 %19, label %21, label %26
21: ; preds = %15
%22 = fdiv double %18, %20
%23 = fmul double %16, 5.000000e-01
%24 = fmul double %17, 5.000000e-01
%25 = tail call double @ibeta(double %22, double %23, double %24)
br label %31
26: ; preds = %15
%27 = fdiv double %17, %20
%28 = fmul double %17, 5.000000e-01
%29 = fmul double %16, 5.000000e-01
%30 = tail call double @ibetac(double %27, double %28, double %29)
br label %31
31: ; preds = %26, %21
%32 = phi double [ %25, %21 ], [ %30, %26 ]
ret double %32
}