#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 Gamma_Function(double);
double Gamma_Function_Max_Arg();
double Ln_Gamma_Function(double);
double exp(double);
double log(double);
double pow(double, double);
double Gamma_Density(double x, double nu) {
  if (x <= 0.0)
    return 0.0;
  if (nu <= Gamma_Function_Max_Arg())
    return pow(x, nu - 1.0) * exp(-x) / Gamma_Function(nu);
  else
    return exp((nu - 1.0) * log(x) - x - Ln_Gamma_Function(nu));
}


x86 assembly (clang, -O0):
<Gamma_Density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     118d <Gamma_Density+0x2d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1290 <Gamma_Density+0x130>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <Gamma_Function_Max_Arg@plt>
movsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jb     121f <Gamma_Density+0xbf>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe41(%rip),%xmm2
subsd  %xmm2,%xmm1
call   1070 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <Gamma_Function@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1290 <Gamma_Density+0x130>
movsd  -0x18(%rbp),%xmm0
movsd  0xdd4(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1080 <Ln_Gamma_Function@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Gamma_Density>:
sub    $0x28,%rsp
movsd  %xmm1,0x20(%rsp)
xorpd  %xmm1,%xmm1
movapd %xmm0,(%rsp)
ucomisd %xmm0,%xmm1
jae    121d <Gamma_Density+0xbd>
xor    %eax,%eax
call   1040 <Gamma_Function_Max_Arg@plt>
movsd  0x20(%rsp),%xmm2
ucomisd %xmm2,%xmm0
movsd  0xe6a(%rip),%xmm1
addsd  %xmm2,%xmm1
jae    11dd <Gamma_Density+0x7d>
movapd (%rsp),%xmm0
movsd  %xmm1,0x18(%rsp)
call   1060 <log@plt>
mulsd  0x18(%rsp),%xmm0
subsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm0
call   1080 <Ln_Gamma_Function@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
jmp    1050 <exp@plt>
movaps (%rsp),%xmm0
call   1070 <pow@plt>
movsd  %xmm0,0x18(%rsp)
movapd (%rsp),%xmm0
xorpd  0xe17(%rip),%xmm0
call   1050 <exp@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <Gamma_Function@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @Gamma_Density(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp ole double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %2
store double 0.000000e+00, double* %3
br label %37
9: ; preds = %2
%10 = load double, double* %5
%11 = call double (...) @Gamma_Function_Max_Arg()
%12 = fcmp ole double %10, %11
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fsub double %15, 1.000000e+00
%17 = call double @pow(double %14, double %16)
%18 = load double, double* %4
%19 = fneg double %18
%20 = call double @exp(double %19)
%21 = fmul double %17, %20
%22 = load double, double* %5
%23 = call double @Gamma_Function(double %22)
%24 = fdiv double %21, %23
store double %24, double* %3
br label %37
25: ; preds = %9
%26 = load double, double* %5
%27 = fsub double %26, 1.000000e+00
%28 = load double, double* %4
%29 = call double @log(double %28)
%30 = load double, double* %4
%31 = fneg double %30
%32 = call double @llvm.fmuladd.f64(double %27, double %29, double %31)
%33 = load double, double* %5
%34 = call double @Ln_Gamma_Function(double %33)
%35 = fsub double %32, %34
%36 = call double @exp(double %35)
store double %36, double* %3
br label %37
37: ; preds = %25, %13, %8
%38 = load double, double* %3
ret double %38
}

LLVM IR (-O2):
define double @Gamma_Density(double %0, double %1) {
%3 = fcmp ugt double %0, 0.000000e+00
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = tail call double (...) @Gamma_Function_Max_Arg()
%6 = fcmp ult double %5, %1
%7 = fadd double %1, -1.000000e+00
br i1 %6, label %15, label %8
8: ; preds = %4
%9 = tail call double @pow(double %0, double %7)
%10 = fneg double %0
%11 = tail call double @exp(double %10)
%12 = fmul double %9, %11
%13 = tail call double @Gamma_Function(double %1)
%14 = fdiv double %12, %13
br label %22
15: ; preds = %4
%16 = tail call double @log(double %0)
%17 = fneg double %0
%18 = tail call double @llvm.fmuladd.f64(double %7, double %16, double %17)
%19 = tail call double @Ln_Gamma_Function(double %1)
%20 = fsub double %18, %19
%21 = tail call double @exp(double %20)
br label %22
22: ; preds = %2, %15, %8
%23 = phi double [ %14, %8 ], [ %21, %15 ], [ 0.000000e+00, %2 ]
ret double %23
}