#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(int);
double lbinom(int n, int k) {
  if (k == 0 || n == k)
    return 0;
  return lgamma(n + 1) - lgamma(k + 1) - lgamma(n - k + 1);
}


x86 assembly (clang, -O0):
<lbinom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1134 <lbinom+0x24>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1141 <lbinom+0x31>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    118c <lbinom+0x7c>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1030 <lgamma@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
call   1030 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
sub    -0x10(%rbp),%edi
add    $0x1,%edi
call   1030 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lbinom>:
push   %r14
push   %rbx
push   %rax
xorpd  %xmm0,%xmm0
test   %esi,%esi
je     1162 <lbinom+0x52>
mov    %esi,%r14d
mov    %edi,%ebx
cmp    %esi,%edi
je     1162 <lbinom+0x52>
add    $0x1,%ebx
mov    %ebx,%edi
call   1030 <lgamma@plt>
movsd  %xmm0,(%rsp)
lea    0x1(%r14),%edi
call   1030 <lgamma@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
sub    %r14d,%ebx
mov    %ebx,%edi
call   1030 <lgamma@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @lbinom(i32 %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %8, %2
store double 0.000000e+00, double* %3
br label %27
13: ; preds = %8
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
%16 = call double @lgamma(i32 %15)
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
%19 = call double @lgamma(i32 %18)
%20 = fsub double %16, %19
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = sub nsw i32 %21, %22
%24 = add nsw i32 %23, 1
%25 = call double @lgamma(i32 %24)
%26 = fsub double %20, %25
store double %26, double* %3
br label %27
27: ; preds = %13, %12
%28 = load double, double* %3
ret double %28
}

LLVM IR (-O2):
define double @lbinom(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = icmp eq i32 %0, %1
%5 = or i1 %3, %4
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = add i32 %0, 1
%8 = tail call double @lgamma(i32 %7)
%9 = add nsw i32 %1, 1
%10 = tail call double @lgamma(i32 %9)
%11 = fsub double %8, %10
%12 = sub i32 %7, %1
%13 = tail call double @lgamma(i32 %12)
%14 = fsub double %11, %13
br label %15
15: ; preds = %2, %6
%16 = phi double [ %14, %6 ], [ 0.000000e+00, %2 ]
ret double %16
}