#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*/ error(char *);
double exp(double);
double pow(double, double);
double tgamma(double);
double gammapdf(double x, double shape, double rate) {
  if (shape <= 0 || rate <= 0)
    error("Both parameters must be larger than 0.");
  return pow(rate, shape) / tgamma(shape) * pow(x, shape - 1) * exp(-rate * x);
}


x86 assembly (clang, -O0):
<gammapdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    1173 <gammapdf+0x33>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     117f <gammapdf+0x3f>
lea    0xe8e(%rip),%rdi
call   1050 <error@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1060 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <tgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe40(%rip),%xmm2
subsd  %xmm2,%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammapdf>:
sub    $0x38,%rsp
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm1,0x8(%rsp)
ucomisd %xmm1,%xmm0
movapd %xmm2,0x20(%rsp)
jae    1166 <gammapdf+0x26>
ucomisd %xmm2,%xmm0
jb     1178 <gammapdf+0x38>
lea    0xeb3(%rip),%rdi
call   1050 <error@plt>
movapd 0x20(%rsp),%xmm2
movapd %xmm2,%xmm0
movsd  0x8(%rsp),%xmm1
call   1060 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <tgamma@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x8(%rsp),%xmm1
addsd  0xe4a(%rip),%xmm1
movsd  0x18(%rsp),%xmm0
call   1060 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd 0x20(%rsp),%xmm0
xorpd  0xe35(%rip),%xmm0
mulsd  0x18(%rsp),%xmm0
call   1040 <exp@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Both parameters must be larger than 0.\00"
define double @gammapdf(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* %5
%8 = fcmp ole double %7, 0.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load double, double* %6
%11 = fcmp ole double %10, 0.000000e+00
br i1 %11, label %12, label %14
12: ; preds = %9, %3
%13 = call i32 @error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = load double, double* %6
%16 = load double, double* %5
%17 = call double @pow(double %15, double %16)
%18 = load double, double* %5
%19 = call double @tgamma(double %18)
%20 = fdiv double %17, %19
%21 = load double, double* %4
%22 = load double, double* %5
%23 = fsub double %22, 1.000000e+00
%24 = call double @pow(double %21, double %23)
%25 = fmul double %20, %24
%26 = load double, double* %6
%27 = fneg double %26
%28 = load double, double* %4
%29 = fmul double %27, %28
%30 = call double @exp(double %29)
%31 = fmul double %25, %30
ret double %31
}

LLVM IR (-O2):
@.str = [39 x i8] c"Both parameters must be larger than 0.\00"
define double @gammapdf(double %0, double %1, double %2) {
%4 = fcmp ole double %1, 0.000000e+00
%5 = fcmp ole double %2, 0.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %3, %7
%10 = tail call double @pow(double %2, double %1)
%11 = tail call double @tgamma(double %1)
%12 = fdiv double %10, %11
%13 = fadd double %1, -1.000000e+00
%14 = tail call double @pow(double %0, double %13)
%15 = fmul double %12, %14
%16 = fneg double %2
%17 = fmul double %16, %0
%18 = tail call double @exp(double %17)
%19 = fmul double %15, %18
ret double %19
}