#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, int, int);
int /*<<< orphan*/ printf(char *);
double tcdf(double t, int df) {
  double oup, x, I;
  if (df <= 0) {
    printf("Degree Of Freedom should be a positive real integer");
    exit(1);
  }
  x = df / (df + t * t);
  I = 0.5 * ibeta(x, df / 2.0, 1. / 2.);
  oup = 1. - I;
  if (t < 0.) {
    oup = 1. - oup;
  }
  if (x == 0.) {
    oup = 0.5;
  }
  return oup;
}


x86 assembly (clang, -O0):
<tcdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1160 <tcdf+0x30>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe79(%rip),%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
xor    %esi,%esi
call   1040 <ibeta@plt>
movaps %xmm0,%xmm1
movsd  0xe57(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe3e(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11ec <tcdf+0xbc>
movsd  0xe1e(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1211 <tcdf+0xe1>
jp     1211 <tcdf+0xe1>
movsd  0xdfc(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcdf>:
sub    $0x28,%rsp
test   %edi,%edi
jle    11d8 <tcdf+0xa8>
cvtsi2sd %edi,%xmm2
movapd %xmm0,%xmm1
movapd %xmm0,0x10(%rsp)
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm2,%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
movsd  0xe99(%rip),%xmm1
mulsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
xor    %esi,%esi
call   1040 <ibeta@plt>
movsd  0xe82(%rip),%xmm5
mulsd  %xmm5,%xmm0
movsd  0xe7e(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
xorpd  %xmm0,%xmm0
movapd 0x10(%rsp),%xmm4
cmpltsd %xmm0,%xmm4
movapd %xmm4,%xmm3
andnpd %xmm2,%xmm3
andpd  %xmm1,%xmm4
orpd   %xmm3,%xmm4
movapd (%rsp),%xmm1
cmpeqsd %xmm0,%xmm1
movapd %xmm1,%xmm0
andnpd %xmm4,%xmm0
andpd  %xmm5,%xmm1
orpd   %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"Degree Of Freedom should be a positive real integer\00"
define double @tcdf(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i32, i32* %4
%15 = sitofp i32 %14 to double
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to double
%18 = load double, double* %3
%19 = load double, double* %3
%20 = call double @llvm.fmuladd.f64(double %18, double %19, double %17)
%21 = fdiv double %15, %20
store double %21, double* %6
%22 = load double, double* %6
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to double
%25 = fdiv double %24, 2.000000e+00
%26 = fptosi double %25 to i32
%27 = call double @ibeta(double %22, i32 %26, i32 0)
%28 = fmul double 5.000000e-01, %27
store double %28, double* %7
%29 = load double, double* %7
%30 = fsub double 1.000000e+00, %29
store double %30, double* %5
%31 = load double, double* %3
%32 = fcmp olt double %31, 0.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %13
%34 = load double, double* %5
%35 = fsub double 1.000000e+00, %34
store double %35, double* %5
br label %36
36: ; preds = %33, %13
%37 = load double, double* %6
%38 = fcmp oeq double %37, 0.000000e+00
br i1 %38, label %39, label %40
39: ; preds = %36
store double 5.000000e-01, double* %5
br label %40
40: ; preds = %39, %36
%41 = load double, double* %5
ret double %41
}

LLVM IR (-O2):
@.str = [52 x i8] c"Degree Of Freedom should be a positive real integer\00"
define double @tcdf(double %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = sitofp i32 %1 to double
%9 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %8)
%10 = fdiv double %8, %9
%11 = fmul double %8, 5.000000e-01
%12 = fptosi double %11 to i32
%13 = tail call double @ibeta(double %10, i32 %12, i32 0)
%14 = fmul double %13, 5.000000e-01
%15 = fsub double 1.000000e+00, %14
%16 = fcmp olt double %0, 0.000000e+00
%17 = fsub double 1.000000e+00, %15
%18 = select i1 %16, double %17, double %15
%19 = fcmp oeq double %10, 0.000000e+00
%20 = select i1 %19, double 5.000000e-01, double %18
ret double %20
}