#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 gammapdf(double, double, int);
int /*<<< orphan*/ printf(char *);
double chipdf(double x, int df) {
  double oup, k;
  if (df <= 0) {
    printf("Degree of freedom is a real positive integer");
    exit(1);
  }
  if (x < 0.) {
    printf("The range of distribution only takes non-negative and real values");
    exit(1);
  }
  k = (double)df;
  oup = gammapdf(x, k / 2, 2.);
  return oup;
}


x86 assembly (clang, -O0):
<chipdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1160 <chipdf+0x30>
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1184 <chipdf+0x54>
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe60(%rip),%xmm2
divsd  %xmm2,%xmm1
mov    $0x2,%edi
call   1030 <gammapdf@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chipdf>:
push   %rax
test   %edi,%edi
jle    1159 <chipdf+0x29>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1162 <chipdf+0x32>
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
mulsd  0xeb2(%rip),%xmm1
mov    $0x2,%edi
pop    %rax
jmp    1030 <gammapdf@plt>
lea    0xea8(%rip),%rdi
jmp    1169 <chipdf+0x39>
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"Degree of freedom is a real positive integer\00"
@.str.1 = [66 x i8] c"The range of distribution only takes non-negative and real values\00"
define double @chipdf(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load double, double* %3
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %12
%19 = load i32, i32* %4
%20 = sitofp i32 %19 to double
store double %20, double* %6
%21 = load double, double* %3
%22 = load double, double* %6
%23 = fdiv double %22, 2.000000e+00
%24 = call double @gammapdf(double %21, double %23, i32 2)
store double %24, double* %5
%25 = load double, double* %5
ret double %25
}

LLVM IR (-O2):
@.str = [45 x i8] c"Degree of freedom is a real positive integer\00"
@.str.1 = [66 x i8] c"The range of distribution only takes non-negative and real values\00"
define double @chipdf(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 ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = fcmp olt double %0, 0.000000e+00
br i1 %8, label %9, label %12
9: ; preds = %7
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %7
%13 = sitofp i32 %1 to double
%14 = fmul double %13, 5.000000e-01
%15 = tail call double @gammapdf(double %0, double %14, i32 2)
ret double %15
}