#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 binopdf_mat(int, int, double);
double binocdf_mat(int n, int k, double p) {
  int i;
  double binoc = 0.0;
  double t;
  if (k > n) {
    k = n;
  }
  for (i = 0; i <= k; i++) {
    t = binopdf_mat(n, i, p);
    binoc += t;
  }
  return binoc;
}


x86 assembly (clang, -O0):
<binocdf_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    113d <binocdf_mat+0x2d>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1182 <binocdf_mat+0x72>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
call   1030 <binopdf_mat@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <binocdf_mat+0x34>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binocdf_mat>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
cmp    %edi,%esi
cmovg  %edi,%ebx
test   %ebx,%ebx
js     1168 <binocdf_mat+0x58>
mov    %edi,%r14d
add    $0x1,%ebx
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm1,0x8(%rsp)
mov    %r14d,%edi
mov    %ebp,%esi
movsd  (%rsp),%xmm0
call   1030 <binopdf_mat@plt>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1140 <binocdf_mat+0x30>
jmp    116c <binocdf_mat+0x5c>
xorpd  %xmm1,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define double @binocdf_mat(i32 %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, %0
%5 = select i1 %4, i32 %0, i32 %1
%6 = icmp slt i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %3, %7
%8 = phi double [ %11, %7 ], [ 0.000000e+00, %3 ]
%9 = phi i32 [ %12, %7 ], [ 0, %3 ]
%10 = tail call double @binopdf_mat(i32 %0, i32 %9, double %2)
%11 = fadd double %8, %10
%12 = add nuw i32 %9, 1
%13 = icmp eq i32 %9, %5
br i1 %13, label %14, label %7
14: ; preds = %7, %3
%15 = phi double [ 0.000000e+00, %3 ], [ %11, %7 ]
ret double %15
}