#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 */
float lgammaf(float);
float log_factorial_f(unsigned int);
float log_combination_k_r_f(unsigned int k, float r) {
  if (!k)
    return 0;
  float val = lgammaf(k + r) - lgammaf(r) - log_factorial_f(k);
  return val;
}


x86 assembly (clang, -O0):
<log_combination_k_r_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1147 <log_combination_k_r_f+0x27>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    119c <log_combination_k_r_f+0x7c>
mov    -0x8(%rbp),%eax
cvtsi2ss %rax,%xmm0
addss  -0xc(%rbp),%xmm0
call   1040 <lgammaf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <lgammaf@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <log_factorial_f@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_combination_k_r_f>:
test   %edi,%edi
je     1182 <log_combination_k_r_f+0x62>
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,%xmm1
mov    %edi,%ebx
mov    %edi,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  %xmm1,%xmm0
movss  %xmm1,0xc(%rsp)
call   1040 <lgammaf@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1040 <lgammaf@plt>
movss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
mov    %ebx,%edi
call   1030 <log_factorial_f@plt>
movss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @log_combination_k_r_f(i32 %0, float %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 %0, i32* %4
store float %1, float* %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %2
store float 0.000000e+00, float* %3
br label %23
10: ; preds = %2
%11 = load i32, i32* %4
%12 = uitofp i32 %11 to float
%13 = load float, float* %5
%14 = fadd float %12, %13
%15 = call float @lgammaf(float %14)
%16 = load float, float* %5
%17 = call float @lgammaf(float %16)
%18 = fsub float %15, %17
%19 = load i32, i32* %4
%20 = call float @log_factorial_f(i32 %19)
%21 = fsub float %18, %20
store float %21, float* %6
%22 = load float, float* %6
store float %22, float* %3
br label %23
23: ; preds = %10, %9
%24 = load float, float* %3
ret float %24
}

LLVM IR (-O2):
define float @log_combination_k_r_f(i32 %0, float %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = uitofp i32 %0 to float
%6 = fadd float %5, %1
%7 = tail call float @lgammaf(float %6)
%8 = tail call float @lgammaf(float %1)
%9 = fsub float %7, %8
%10 = tail call float @log_factorial_f(i32 %0)
%11 = fsub float %9, %10
br label %12
12: ; preds = %2, %4
%13 = phi float [ %11, %4 ], [ 0.000000e+00, %2 ]
ret float %13
}