#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 lgamma(double);
double log(double);
double log_dgamma(double x, double shape, double rate) {
  return shape * log(rate) + (shape - 1) * log(x) - rate * x - lgamma(shape);
}


x86 assembly (clang, -O0):
<log_dgamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_dgamma>:
sub    $0x28,%rsp
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
movaps %xmm2,%xmm0
call   1040 <log@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xeb5(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1040 <log@plt>
movapd %xmm0,%xmm2
mulsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm1,%xmm2
movsd  0x20(%rsp),%xmm1
mulsd  (%rsp),%xmm1
subsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
call   1030 <lgamma@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @log_dgamma(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 = load double, double* %6
%9 = call double @log(double %8)
%10 = load double, double* %5
%11 = fsub double %10, 1.000000e+00
%12 = load double, double* %4
%13 = call double @log(double %12)
%14 = fmul double %11, %13
%15 = call double @llvm.fmuladd.f64(double %7, double %9, double %14)
%16 = load double, double* %6
%17 = load double, double* %4
%18 = fneg double %16
%19 = call double @llvm.fmuladd.f64(double %18, double %17, double %15)
%20 = load double, double* %5
%21 = call double @lgamma(double %20)
%22 = fsub double %19, %21
ret double %22
}

LLVM IR (-O2):
define double @log_dgamma(double %0, double %1, double %2) {
%4 = tail call double @log(double %2)
%5 = fadd double %1, -1.000000e+00
%6 = tail call double @log(double %0)
%7 = fmul double %5, %6
%8 = tail call double @llvm.fmuladd.f64(double %1, double %4, double %7)
%9 = fneg double %2
%10 = tail call double @llvm.fmuladd.f64(double %9, double %0, double %8)
%11 = tail call double @lgamma(double %1)
%12 = fsub double %10, %11
ret double %12
}