#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 */
scalar_t__ LnGamma(double);
int /*<<< orphan*/ error2(char *);
double exp(scalar_t__);
double pow(double, double);
int /*<<< orphan*/ printf(char *, double, double, double);
double PDFinvGamma(double x, double alpha, double beta) {
  if (x <= 0 || alpha <= 0 || beta <= 0) {
    printf("x=%.6f a=%.6f b=%.6f", x, alpha, beta);
    error2("x a b outside range in PDF_IGamma()");
  }
  if (alpha > 100)
    error2("large alpha in PDF_IGamma()");
  return pow(beta / x, alpha) / x * exp(-beta / x - LnGamma(alpha));
}


x86 assembly (clang, -O0):
<PDFinvGamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jae    1191 <PDFinvGamma+0x41>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    1191 <PDFinvGamma+0x41>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11b8 <PDFinvGamma+0x68>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
call   1040 <error2@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe3b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11db <PDFinvGamma+0x8b>
lea    0xe6b(%rip),%rdi
call   1040 <error2@plt>
movsd  -0x18(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1060 <pow@plt>
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <LnGamma@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PDFinvGamma>:
sub    $0x28,%rsp
xorpd  %xmm3,%xmm3
movsd  %xmm0,0x8(%rsp)
ucomisd %xmm0,%xmm3
movapd %xmm2,0x10(%rsp)
movsd  %xmm1,(%rsp)
jae    117f <PDFinvGamma+0x2f>
ucomisd %xmm1,%xmm3
jae    117f <PDFinvGamma+0x2f>
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jb     11b2 <PDFinvGamma+0x62>
lea    0xe9a(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
movaps 0x10(%rsp),%xmm2
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
call   1040 <error2@plt>
movsd  (%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
ucomisd 0xe46(%rip),%xmm1
jbe    11d3 <PDFinvGamma+0x83>
lea    0xe96(%rip),%rdi
call   1040 <error2@plt>
movsd  (%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
divsd  0x8(%rsp),%xmm0
call   1060 <pow@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
movapd 0x10(%rsp),%xmm0
xorpd  0xe10(%rip),%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1070 <LnGamma@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1050 <exp@plt>
mulsd  0x20(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"x=%.6f a=%.6f b=%.6f\00"
@.str.1 = [36 x i8] c"x a b outside range in PDF_IGamma()\00"
@.str.2 = [28 x i8] c"large alpha in PDF_IGamma()\00"
define double @PDFinvGamma(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%7 = load double, double* %4
%8 = fcmp ole double %7, 0.000000e+00
br i1 %8, label %15, label %9
9: ; preds = %3
%10 = load double, double* %5
%11 = fcmp ole double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load double, double* %6
%14 = fcmp ole double %13, 0.000000e+00
br i1 %14, label %15, label %21
15: ; preds = %12, %9, %3
%16 = load double, double* %4
%17 = load double, double* %5
%18 = load double, double* %6
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %16, double %17, double %18)
%20 = call i32 @error2(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %15, %12
%22 = load double, double* %5
%23 = fcmp ogt double %22, 1.000000e+02
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @error2(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = load double, double* %6
%28 = load double, double* %4
%29 = fdiv double %27, %28
%30 = load double, double* %5
%31 = call double @pow(double %29, double %30)
%32 = load double, double* %4
%33 = fdiv double %31, %32
%34 = load double, double* %6
%35 = fneg double %34
%36 = load double, double* %4
%37 = fdiv double %35, %36
%38 = load double, double* %5
%39 = call i64 @LnGamma(double %38)
%40 = sitofp i64 %39 to double
%41 = fsub double %37, %40
%42 = fptosi double %41 to i64
%43 = call double @exp(i64 %42)
%44 = fmul double %33, %43
ret double %44
}

LLVM IR (-O2):
@.str = [21 x i8] c"x=%.6f a=%.6f b=%.6f\00"
@.str.1 = [36 x i8] c"x a b outside range in PDF_IGamma()\00"
@.str.2 = [28 x i8] c"large alpha in PDF_IGamma()\00"
define double @PDFinvGamma(double %0, double %1, double %2) {
%4 = fcmp ole double %0, 0.000000e+00
%5 = fcmp ole double %1, 0.000000e+00
%6 = or i1 %4, %5
%7 = fcmp ole double %2, 0.000000e+00
%8 = or i1 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %0, double %1, double %2)
%11 = tail call i32 @error2(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %3, %9
%13 = fcmp ogt double %1, 1.000000e+02
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 @error2(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = fdiv double %2, %0
%18 = tail call double @pow(double %17, double %1)
%19 = fdiv double %18, %0
%20 = fneg double %2
%21 = fdiv double %20, %0
%22 = tail call i64 @LnGamma(double %1)
%23 = sitofp i64 %22 to double
%24 = fsub double %21, %23
%25 = fptosi double %24 to i64
%26 = tail call double @exp(i64 %25)
%27 = fmul double %19, %26
ret double %27
}