#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*/ errmsg(char *, char *);
double exp(double);
double pow(double, double);
double tgamma(double);
double gammapdf3par(double alpha, double beta, double gamma, double x) {
  double g, lg;
  double gpdf;
  char *where = "gammapdf3par";
  if (x <= 0) {
    errmsg(where,
           "The Gamma distribution is only defined for positive values.");
    return (-1);
  }
  if (alpha > 170) {
    errmsg(where, "The alpha parameter is too large.");
    return (-2);
  }
  gpdf = (pow(x - gamma, (alpha - 1)) * exp(-(x - gamma) / beta)) /
         (pow(beta, alpha) * tgamma(alpha));
  return (gpdf);
}


x86 assembly (clang, -O0):
<gammapdf3par>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     1197 <gammapdf3par+0x57>
mov    -0x48(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1050 <errmsg@plt>
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1273 <gammapdf3par+0x133>
movsd  -0x10(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d0 <gammapdf3par+0x90>
mov    -0x48(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1050 <errmsg@plt>
movsd  0xe4a(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1273 <gammapdf3par+0x133>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe21(%rip),%xmm2
subsd  %xmm2,%xmm1
call   1060 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1060 <pow@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <tgamma@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammapdf3par>:
sub    $0x38,%rsp
movapd %xmm0,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
jae    117c <gammapdf3par+0x3c>
ucomisd 0xeae(%rip),%xmm4
jbe    119c <gammapdf3par+0x5c>
lea    0xecd(%rip),%rdi
lea    0xf0f(%rip),%rsi
call   1050 <errmsg@plt>
movsd  0xe99(%rip),%xmm0
add    $0x38,%rsp
ret
lea    0xead(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1050 <errmsg@plt>
movsd  0xe69(%rip),%xmm0
add    $0x38,%rsp
ret
subsd  %xmm2,%xmm3
movapd %xmm3,0x20(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  0xe4c(%rip),%xmm1
addsd  %xmm4,%xmm1
movapd %xmm3,%xmm0
movsd  %xmm4,0x18(%rsp)
call   1060 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movapd 0x20(%rsp),%xmm0
xorpd  0xe45(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
call   1040 <exp@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1060 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <tgamma@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"gammapdf3par\00"
@.str.1 = [60 x i8] c"The Gamma distribution is only defined for positive values.\00"
@.str.2 = [34 x i8] c"The alpha parameter is too large.\00"
define double @gammapdf3par(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i8*
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %13
%14 = load double, double* %9
%15 = fcmp ole double %14, 0.000000e+00
br i1 %15, label %16, label %19
16: ; preds = %4
%17 = load i8*, i8** %13
%18 = call i32 @errmsg(i8* %17, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
store double -1.000000e+00, double* %5
br label %48
19: ; preds = %4
%20 = load double, double* %6
%21 = fcmp ogt double %20, 1.700000e+02
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i8*, i8** %13
%24 = call i32 @errmsg(i8* %23, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store double -2.000000e+00, double* %5
br label %48
25: ; preds = %19
%26 = load double, double* %9
%27 = load double, double* %8
%28 = fsub double %26, %27
%29 = load double, double* %6
%30 = fsub double %29, 1.000000e+00
%31 = call double @pow(double %28, double %30)
%32 = load double, double* %9
%33 = load double, double* %8
%34 = fsub double %32, %33
%35 = fneg double %34
%36 = load double, double* %7
%37 = fdiv double %35, %36
%38 = call double @exp(double %37)
%39 = fmul double %31, %38
%40 = load double, double* %7
%41 = load double, double* %6
%42 = call double @pow(double %40, double %41)
%43 = load double, double* %6
%44 = call double @tgamma(double %43)
%45 = fmul double %42, %44
%46 = fdiv double %39, %45
store double %46, double* %12
%47 = load double, double* %12
store double %47, double* %5
br label %48
48: ; preds = %25, %22, %16
%49 = load double, double* %5
ret double %49
}

LLVM IR (-O2):
@.str = [13 x i8] c"gammapdf3par\00"
@.str.1 = [60 x i8] c"The Gamma distribution is only defined for positive values.\00"
@.str.2 = [34 x i8] c"The alpha parameter is too large.\00"
define double @gammapdf3par(double %0, double %1, double %2, double %3) {
%5 = fcmp ugt double %3, 0.000000e+00
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 @errmsg(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
br label %24
8: ; preds = %4
%9 = fcmp ogt double %0, 1.700000e+02
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @errmsg(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %24
12: ; preds = %8
%13 = fsub double %3, %2
%14 = fadd double %0, -1.000000e+00
%15 = tail call double @pow(double %13, double %14)
%16 = fneg double %13
%17 = fdiv double %16, %1
%18 = tail call double @exp(double %17)
%19 = fmul double %15, %18
%20 = tail call double @pow(double %1, double %0)
%21 = tail call double @tgamma(double %0)
%22 = fmul double %20, %21
%23 = fdiv double %19, %22
br label %24
24: ; preds = %12, %10, %6
%25 = phi double [ -1.000000e+00, %6 ], [ -2.000000e+00, %10 ], [ %23, %12 ]
ret double %25
}