#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 */
long double combination_eff(int, int);
long double powl(int, int);
long double proba_less_than(int n, int k, long double proba) {
  long double result = 0.0;
  while (k >= 0) {
    result +=
        combination_eff(k, n) * powl(proba, k) * powl((1 - proba), (n - k));
    k--;
  }
  return result;
}


x86 assembly (clang, -O0):
<proba_less_than>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x10(%rbp)
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
fstpt  -0x20(%rbp)
fldz
fstpt  -0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11cd <proba_less_than+0xad>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <combination_eff@plt>
fstpt  -0x58(%rbp)
fldt   -0x20(%rbp)
fnstcw -0x3a(%rbp)
movzwl -0x3a(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x3c(%rbp)
fldcw  -0x3c(%rbp)
fistpl -0x38(%rbp)
fldcw  -0x3a(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <powl@plt>
fldt   -0x58(%rbp)
fmulp  %st,%st(1)
fstpt  -0x4c(%rbp)
fldt   -0x20(%rbp)
fld1
fsubp  %st,%st(1)
fnstcw -0x3e(%rbp)
movzwl -0x3e(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x40(%rbp)
fldcw  -0x40(%rbp)
fistpl -0x34(%rbp)
fldcw  -0x3e(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%eax
sub    %eax,%esi
call   1030 <powl@plt>
fldt   -0x4c(%rbp)
fldt   -0x30(%rbp)
fxch   %st(1)
fmulp  %st,%st(2)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <proba_less_than+0x19>
fldt   -0x30(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proba_less_than>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
fldt   0x60(%rsp)
fldz
test   %esi,%esi
js     11ea <proba_less_than+0xca>
mov    %esi,%ebx
mov    %edi,%r14d
fstp   %st(0)
fnstcw 0xa(%rsp)
movzwl 0xa(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0xe(%rsp)
fldcw  0xe(%rsp)
fistl  0x10(%rsp)
fldcw  0xa(%rsp)
mov    0x10(%rsp),%r15d
fld1
fsubp  %st,%st(1)
fnstcw 0x8(%rsp)
movzwl 0x8(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0xc(%rsp)
fldcw  0xc(%rsp)
fistpl 0x14(%rsp)
fldcw  0x8(%rsp)
mov    0x14(%rsp),%r12d
mov    %edi,%ebp
sub    %esi,%ebp
fldz
fldz
fxch   %st(1)
nopw   0x0(%rax,%rax,1)
fstp   %st(1)
fstpt  0x24(%rsp)
mov    %ebx,%edi
mov    %r14d,%esi
call   1040 <combination_eff@plt>
fstpt  0x18(%rsp)
mov    %r15d,%edi
mov    %ebx,%esi
call   1030 <powl@plt>
fldt   0x18(%rsp)
fmulp  %st,%st(1)
fstpt  0x18(%rsp)
mov    %r12d,%edi
mov    %ebp,%esi
call   1030 <powl@plt>
fldt   0x24(%rsp)
fldt   0x18(%rsp)
fmulp  %st,%st(2)
faddp  %st,%st(1)
add    $0x1,%ebp
add    $0xffffffff,%ebx
fldz
fxch   %st(1)
jb     11a0 <proba_less_than+0x80>
fstp   %st(1)
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define x86_fp80 @proba_less_than(i32 %0, i32 %1, x86_fp80 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca x86_fp80
%7 = alloca x86_fp80
store i32 %0, i32* %4
store i32 %1, i32* %5
store x86_fp80 %2, x86_fp80* %6
store x86_fp80 0xK00000000000000000000, x86_fp80* %7
br label %8
8: ; preds = %11, %3
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %8
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = call x86_fp80 @combination_eff(i32 %12, i32 %13)
%15 = load x86_fp80, x86_fp80* %6
%16 = fptosi x86_fp80 %15 to i32
%17 = load i32, i32* %5
%18 = call x86_fp80 @powl(i32 %16, i32 %17)
%19 = fmul x86_fp80 %14, %18
%20 = load x86_fp80, x86_fp80* %6
%21 = fsub x86_fp80 0xK3FFF8000000000000000, %20
%22 = fptosi x86_fp80 %21 to i32
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = sub nsw i32 %23, %24
%26 = call x86_fp80 @powl(i32 %22, i32 %25)
%27 = load x86_fp80, x86_fp80* %7
%28 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %19, x86_fp80 %26, x86_fp80 %27)
store x86_fp80 %28, x86_fp80* %7
%29 = load i32, i32* %5
%30 = add nsw i32 %29, -1
store i32 %30, i32* %5
br label %8
31: ; preds = %8
%32 = load x86_fp80, x86_fp80* %7
ret x86_fp80 %32
}

LLVM IR (-O2):
define x86_fp80 @proba_less_than(i32 %0, i32 %1, x86_fp80 %2) {
%4 = icmp sgt i32 %1, -1
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = fptosi x86_fp80 %2 to i32
%7 = fsub x86_fp80 0xK3FFF8000000000000000, %2
%8 = fptosi x86_fp80 %7 to i32
br label %9
9: ; preds = %5, %9
%10 = phi x86_fp80 [ 0xK00000000000000000000, %5 ], [ %17, %9 ]
%11 = phi i32 [ %1, %5 ], [ %18, %9 ]
%12 = tail call x86_fp80 @combination_eff(i32 %11, i32 %0)
%13 = tail call x86_fp80 @powl(i32 %6, i32 %11)
%14 = fmul x86_fp80 %12, %13
%15 = sub nsw i32 %0, %11
%16 = tail call x86_fp80 @powl(i32 %8, i32 %15)
%17 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %14, x86_fp80 %16, x86_fp80 %10)
%18 = add nsw i32 %11, -1
%19 = icmp eq i32 %11, 0
br i1 %19, label %20, label %9
20: ; preds = %9, %3
%21 = phi x86_fp80 [ 0xK00000000000000000000, %3 ], [ %17, %9 ]
ret x86_fp80 %21
}