#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 exp(scalar_t__);
scalar_t__ lchoose(int, int);
double ascprob_subsample(int k, int d, int min_obs, int n) {
  int i;
  double no_asc;
  no_asc = 0.;
  for (i = 0; i < min_obs; i++)
    no_asc += exp(lchoose(k, d - i) + lchoose(n - k, i)) +
              exp(lchoose(n - k, d - i) + lchoose(k, i));
  no_asc /= exp(lchoose(n, d));
  return 1.0 - no_asc;
}


x86 assembly (clang, -O0):
<ascprob_subsample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d0 <ascprob_subsample+0xb0>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    -0x14(%rbp),%esi
call   1030 <lchoose@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%edi
sub    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <lchoose@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
call   1040 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%edi
sub    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    -0x14(%rbp),%esi
call   1030 <lchoose@plt>
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <lchoose@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <ascprob_subsample+0x23>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <lchoose@plt>
mov    %rax,%rdi
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe04(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ascprob_subsample>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,0x4(%rsp)
test   %edx,%edx
mov    %ecx,0x18(%rsp)
mov    %esi,0x14(%rsp)
jle    11e2 <ascprob_subsample+0xc2>
mov    %edx,%r13d
sub    0x4(%rsp),%ecx
mov    %ecx,0x1c(%rsp)
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %esi,%r15d
mov    0x4(%rsp),%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r15d,%esi
call   1030 <lchoose@plt>
mov    %rax,%r14
mov    0x1c(%rsp),%ebx
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <lchoose@plt>
add    %rax,%r14
mov    %r14,%rdi
call   1040 <exp@plt>
movsd  %xmm0,0x20(%rsp)
mov    %ebx,%edi
mov    %r15d,%esi
call   1030 <lchoose@plt>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %ebp,%esi
call   1030 <lchoose@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1040 <exp@plt>
addsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%ebp
add    $0xffffffff,%r15d
cmp    %ebp,%r13d
jne    1170 <ascprob_subsample+0x50>
jmp    11ec <ascprob_subsample+0xcc>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rsp),%edi
mov    0x14(%rsp),%esi
call   1030 <lchoose@plt>
mov    %rax,%rdi
call   1040 <exp@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0xded(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @ascprob_subsample(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %10
store i32 0, i32* %9
br label %11
11: ; preds = %43, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %46
15: ; preds = %11
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = load i32, i32* %9
%19 = sub nsw i32 %17, %18
%20 = call i64 @lchoose(i32 %16, i32 %19)
%21 = load i32, i32* %8
%22 = load i32, i32* %5
%23 = sub nsw i32 %21, %22
%24 = load i32, i32* %9
%25 = call i64 @lchoose(i32 %23, i32 %24)
%26 = add nsw i64 %20, %25
%27 = call double @exp(i64 %26)
%28 = load i32, i32* %8
%29 = load i32, i32* %5
%30 = sub nsw i32 %28, %29
%31 = load i32, i32* %6
%32 = load i32, i32* %9
%33 = sub nsw i32 %31, %32
%34 = call i64 @lchoose(i32 %30, i32 %33)
%35 = load i32, i32* %5
%36 = load i32, i32* %9
%37 = call i64 @lchoose(i32 %35, i32 %36)
%38 = add nsw i64 %34, %37
%39 = call double @exp(i64 %38)
%40 = fadd double %27, %39
%41 = load double, double* %10
%42 = fadd double %41, %40
store double %42, double* %10
br label %43
43: ; preds = %15
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %11
46: ; preds = %11
%47 = load i32, i32* %8
%48 = load i32, i32* %6
%49 = call i64 @lchoose(i32 %47, i32 %48)
%50 = call double @exp(i64 %49)
%51 = load double, double* %10
%52 = fdiv double %51, %50
store double %52, double* %10
%53 = load double, double* %10
%54 = fsub double 1.000000e+00, %53
ret double %54
}

LLVM IR (-O2):
define double @ascprob_subsample(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %24
6: ; preds = %4
%7 = sub nsw i32 %3, %0
br label %8
8: ; preds = %6, %8
%9 = phi double [ 0.000000e+00, %6 ], [ %21, %8 ]
%10 = phi i32 [ 0, %6 ], [ %22, %8 ]
%11 = sub nsw i32 %1, %10
%12 = tail call i64 @lchoose(i32 %0, i32 %11)
%13 = tail call i64 @lchoose(i32 %7, i32 %10)
%14 = add nsw i64 %13, %12
%15 = tail call double @exp(i64 %14)
%16 = tail call i64 @lchoose(i32 %7, i32 %11)
%17 = tail call i64 @lchoose(i32 %0, i32 %10)
%18 = add nsw i64 %17, %16
%19 = tail call double @exp(i64 %18)
%20 = fadd double %15, %19
%21 = fadd double %9, %20
%22 = add nuw nsw i32 %10, 1
%23 = icmp eq i32 %22, %2
br i1 %23, label %24, label %8
24: ; preds = %8, %4
%25 = phi double [ 0.000000e+00, %4 ], [ %21, %8 ]
%26 = tail call i64 @lchoose(i32 %3, i32 %1)
%27 = tail call double @exp(i64 %26)
%28 = fdiv double %25, %27
%29 = fsub double 1.000000e+00, %28
ret double %29
}