#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 factorial(double);
double choose(double n, double k) {
  if (k > n) {
    return 0;
  } else if (k == 0 || n == k) {
    return 1;
  }
  return factorial(n) / (factorial(k) * factorial(n - k));
}


x86 assembly (clang, -O0):
<choose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    113f <choose+0x2f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d0 <choose+0xc0>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115c <choose+0x4c>
jp     115c <choose+0x4c>
jmp    1172 <choose+0x62>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1184 <choose+0x74>
jp     1184 <choose+0x74>
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d0 <choose+0xc0>
jmp    1189 <choose+0x79>
movsd  -0x10(%rbp),%xmm0
call   1030 <factorial@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <factorial@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <factorial@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choose>:
sub    $0x28,%rsp
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm1
ja     118f <choose+0x7f>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movsd  0xece(%rip),%xmm0
jne    1136 <choose+0x26>
jnp    118f <choose+0x7f>
ucomisd %xmm1,%xmm2
jne    113e <choose+0x2e>
jnp    118f <choose+0x7f>
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <factorial@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <factorial@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
call   1030 <factorial@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @choose(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* %5
%7 = load double, double* %4
%8 = fcmp ogt double %6, %7
br i1 %8, label %9, label %10
9: ; preds = %2
store double 0.000000e+00, double* %3
br label %30
10: ; preds = %2
%11 = load double, double* %5
%12 = fcmp oeq double %11, 0.000000e+00
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fcmp oeq double %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13, %10
store double 1.000000e+00, double* %3
br label %30
18: ; preds = %13
br label %19
19: ; preds = %18
%20 = load double, double* %4
%21 = call double @factorial(double %20)
%22 = load double, double* %5
%23 = call double @factorial(double %22)
%24 = load double, double* %4
%25 = load double, double* %5
%26 = fsub double %24, %25
%27 = call double @factorial(double %26)
%28 = fmul double %23, %27
%29 = fdiv double %21, %28
store double %29, double* %3
br label %30
30: ; preds = %19, %17, %9
%31 = load double, double* %3
ret double %31
}

LLVM IR (-O2):
define double @choose(double %0, double %1) {
%3 = fcmp ogt double %1, %0
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = fcmp oeq double %1, 0.000000e+00
%6 = fcmp oeq double %0, %1
%7 = or i1 %5, %6
br i1 %7, label %15, label %8
8: ; preds = %4
%9 = tail call double @factorial(double %0)
%10 = tail call double @factorial(double %1)
%11 = fsub double %0, %1
%12 = tail call double @factorial(double %11)
%13 = fmul double %10, %12
%14 = fdiv double %9, %13
br label %15
15: ; preds = %4, %2, %8
%16 = phi double [ %14, %8 ], [ 0.000000e+00, %2 ], [ 1.000000e+00, %4 ]
ret double %16
}