#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 betapdf(double, double, double);
int /*<<< orphan*/ exit(int);
double pow(double, double);
int /*<<< orphan*/ printf(char *);
double fpdf(double x, int num, int den) {
  double oup, k1, k2, y, z;
  if (num <= 0 || den <= 0) {
    printf("Degrees Of Freedom should be 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 = (k2 * k1) / ((k2 + k1 * x) * (k2 + k1 * x));
    oup = y * betapdf(k2 / (k2 + k1 * x), k2 / 2., k1 / 2.);
  } else {
    z = k2 + k1 * x;
    y = (z * k1 - x * k1 * k1) / (pow(z, 2.0));
    oup = y * betapdf(k1 * x / (k2 + k1 * x), k1 / 2., k2 / 2.);
  }
  return oup;
}


x86 assembly (clang, -O0):
<fpdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1167 <fpdf+0x27>
cmpl   $0x0,-0x10(%rbp)
jg     117d <fpdf+0x3d>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11a1 <fpdf+0x61>
lea    0xea1(%rip),%rdi
call   1030 <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),%xmm0
mulsd  -0x8(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1276 <fpdf+0x136>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
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  -0x28(%rbp),%xmm1
movsd  0xdba(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xda9(%rip),%xmm3
divsd  %xmm3,%xmm2
call   1040 <betapdf@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1359 <fpdf+0x219>
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xd24(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
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  -0x20(%rbp),%xmm1
movsd  0xcd2(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  0xcc1(%rip),%xmm3
divsd  %xmm3,%xmm2
call   1040 <betapdf@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fpdf>:
sub    $0x18,%rsp
test   %edi,%edi
jle    11f6 <fpdf+0xc6>
test   %esi,%esi
jle    11f6 <fpdf+0xc6>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11ff <fpdf+0xcf>
cvtsi2sd %edi,%xmm2
cvtsi2sd %esi,%xmm3
mulsd  %xmm2,%xmm0
ucomisd %xmm3,%xmm0
jbe    118e <fpdf+0x5e>
movapd %xmm2,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm3,%xmm0
movapd %xmm0,%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm3,%xmm5
unpcklpd %xmm1,%xmm5
unpcklpd %xmm4,%xmm0
divpd  %xmm0,%xmm5
movapd %xmm3,%xmm1
jmp    11c6 <fpdf+0x96>
movapd %xmm0,%xmm4
addsd  %xmm3,%xmm4
movapd %xmm4,%xmm5
mulsd  %xmm2,%xmm5
movapd %xmm2,%xmm1
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm5
movapd %xmm4,%xmm2
mulsd  %xmm4,%xmm2
unpcklpd %xmm5,%xmm0
unpcklpd %xmm2,%xmm4
divpd  %xmm4,%xmm0
movapd %xmm3,%xmm2
movapd %xmm0,%xmm5
movapd %xmm5,(%rsp)
movsd  0xe2d(%rip),%xmm0
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm2
movapd %xmm5,%xmm0
call   1040 <betapdf@plt>
movapd (%rsp),%xmm1
unpckhpd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
lea    0xe0b(%rip),%rdi
jmp    1206 <fpdf+0xd6>
lea    0xe2d(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"Degrees Of Freedom should be real integers\00"
@.str.1 = [66 x i8] c"The range of distribution only takes non-negative and real values\00"
define double @fpdf(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 i32, i32* %5
%13 = icmp sle i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = load i32, i32* %6
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14, %3
%18 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %14
%21 = load double, double* %4
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %20
%27 = load i32, i32* %5
%28 = sitofp i32 %27 to double
store double %28, double* %8
%29 = load i32, i32* %6
%30 = sitofp i32 %29 to double
store double %30, double* %9
%31 = load double, double* %8
%32 = load double, double* %4
%33 = fmul double %31, %32
%34 = load double, double* %9
%35 = fcmp ogt double %33, %34
br i1 %35, label %36, label %63
36: ; preds = %26
%37 = load double, double* %9
%38 = load double, double* %8
%39 = fmul double %37, %38
%40 = load double, double* %9
%41 = load double, double* %8
%42 = load double, double* %4
%43 = call double @llvm.fmuladd.f64(double %41, double %42, double %40)
%44 = load double, double* %9
%45 = load double, double* %8
%46 = load double, double* %4
%47 = call double @llvm.fmuladd.f64(double %45, double %46, double %44)
%48 = fmul double %43, %47
%49 = fdiv double %39, %48
store double %49, double* %10
%50 = load double, double* %10
%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
%57 = load double, double* %9
%58 = fdiv double %57, 2.000000e+00
%59 = load double, double* %8
%60 = fdiv double %59, 2.000000e+00
%61 = call double @betapdf(double %56, double %58, double %60)
%62 = fmul double %50, %61
store double %62, double* %7
br label %95
63: ; preds = %26
%64 = load double, double* %9
%65 = load double, double* %8
%66 = load double, double* %4
%67 = call double @llvm.fmuladd.f64(double %65, double %66, double %64)
store double %67, double* %11
%68 = load double, double* %11
%69 = load double, double* %8
%70 = load double, double* %4
%71 = load double, double* %8
%72 = fmul double %70, %71
%73 = load double, double* %8
%74 = fmul double %72, %73
%75 = fneg double %74
%76 = call double @llvm.fmuladd.f64(double %68, double %69, double %75)
%77 = load double, double* %11
%78 = call double @pow(double %77, double 2.000000e+00)
%79 = fdiv double %76, %78
store double %79, double* %10
%80 = load double, double* %10
%81 = load double, double* %8
%82 = load double, double* %4
%83 = fmul double %81, %82
%84 = load double, double* %9
%85 = load double, double* %8
%86 = load double, double* %4
%87 = call double @llvm.fmuladd.f64(double %85, double %86, double %84)
%88 = fdiv double %83, %87
%89 = load double, double* %8
%90 = fdiv double %89, 2.000000e+00
%91 = load double, double* %9
%92 = fdiv double %91, 2.000000e+00
%93 = call double @betapdf(double %88, double %90, double %92)
%94 = fmul double %80, %93
store double %94, double* %7
br label %95
95: ; preds = %63, %36
%96 = load double, double* %7
ret double %96
}

LLVM IR (-O2):
@.str = [43 x i8] c"Degrees Of Freedom should be real integers\00"
@.str.1 = [66 x i8] c"The range of distribution only takes non-negative and real values\00"
define double @fpdf(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 ([43 x i8], [43 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 ogt double %18, %17
br i1 %19, label %20, label %29
20: ; preds = %15
%21 = fmul double %16, %17
%22 = tail call double @llvm.fmuladd.f64(double %16, double %0, double %17)
%23 = fmul double %22, %22
%24 = insertelement <2 x double> poison, double %17, i64 0
%25 = insertelement <2 x double> %24, double %21, i64 1
%26 = insertelement <2 x double> poison, double %22, i64 0
%27 = insertelement <2 x double> %26, double %23, i64 1
%28 = fdiv <2 x double> %25, %27
br label %40
29: ; preds = %15
%30 = tail call double @llvm.fmuladd.f64(double %16, double %0, double %17)
%31 = fneg double %18
%32 = fmul double %16, %31
%33 = tail call double @llvm.fmuladd.f64(double %30, double %16, double %32)
%34 = fmul double %30, %30
%35 = insertelement <2 x double> poison, double %18, i64 0
%36 = insertelement <2 x double> %35, double %33, i64 1
%37 = insertelement <2 x double> poison, double %30, i64 0
%38 = insertelement <2 x double> %37, double %34, i64 1
%39 = fdiv <2 x double> %36, %38
br label %40
40: ; preds = %29, %20
%41 = phi double [ %16, %29 ], [ %17, %20 ]
%42 = phi double [ %17, %29 ], [ %16, %20 ]
%43 = phi <2 x double> [ %39, %29 ], [ %28, %20 ]
%44 = fmul double %41, 5.000000e-01
%45 = fmul double %42, 5.000000e-01
%46 = extractelement <2 x double> %43, i64 0
%47 = tail call double @betapdf(double %46, double %44, double %45)
%48 = extractelement <2 x double> %43, i64 1
%49 = fmul double %48, %47
ret double %49
}