#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 */
int /*<<< orphan*/ cdflib_beta_inc(double *, double *, double *, double *,
                                   double *, double *, int *);
void cdflib_cumf(const double *f, const double *dfn, const double *dfd,
                 double *cum, double *ccum) {
  static const double half = 0.5e0;
  static const double done = 1.0e0;
  double dsum, prod, xx, yy;
  int ierr;
  double T1, T2;
  if (!(*f <= 0.0e0)) {
    goto S10;
  }
  *cum = 0.0e0;
  *ccum = 1.0e0;
  return;
S10:
  prod = *dfn * *f;
  dsum = *dfd + prod;
  xx = *dfd / dsum;
  if (xx > half) {
    yy = prod / dsum;
    xx = done - yy;
  } else {
    yy = done - xx;
  }
  T1 = *dfd * half;
  T2 = *dfn * half;
  cdflib_beta_inc(&T1, &T2, &xx, &yy, ccum, cum, &ierr);
  return;
}


x86 assembly (clang, -O0):
<cdflib_cumf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jae    1142 <cdflib_cumf+0x32>
jmp    1162 <cdflib_cumf+0x52>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1239 <cdflib_cumf+0x129>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d8 <cdflib_cumf+0xc8>
movsd  -0x38(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe3f(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11ea <cdflib_cumf+0xda>
movsd  0xe28(%rip),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movsd  0xe0a(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xdf5(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    -0x58(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <cdflib_beta_inc@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdflib_cumf>:
sub    $0x38,%rsp
mov    %rcx,%r9
movsd  (%rdi),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jae    116f <cdflib_cumf+0x5f>
movsd  (%rsi),%xmm0
mulsd  %xmm0,%xmm2
movsd  (%rdx),%xmm1
movapd %xmm1,%xmm3
addsd  %xmm2,%xmm3
movapd %xmm1,%xmm4
divsd  %xmm3,%xmm4
movsd  %xmm4,0x18(%rsp)
ucomisd 0xeb1(%rip),%xmm4
jbe    1188 <cdflib_cumf+0x78>
divsd  %xmm3,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0xea5(%rip),%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x18(%rsp)
jmp    119a <cdflib_cumf+0x8a>
movq   $0x0,(%r9)
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r8)
add    $0x38,%rsp
ret
movsd  0xe78(%rip),%xmm2
subsd  %xmm4,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0xe5e(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x28(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0x34(%rsp),%rax
mov    %rax,(%rsp)
lea    0x28(%rsp),%rdi
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1030 <cdflib_beta_inc@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@cdflib_cumf.half = internal constant double 5.000000e-01
@cdflib_cumf.done = internal constant double 1.000000e+00
define void @cdflib_cumf(double* %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca double
%17 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%18 = load double*, double** %6
%19 = load double, double* %18
%20 = fcmp ole double %19, 0.000000e+00
br i1 %20, label %22, label %21
21: ; preds = %5
br label %25
22: ; preds = %5
%23 = load double*, double** %9
store double 0.000000e+00, double* %23
%24 = load double*, double** %10
store double 1.000000e+00, double* %24
br label %60
25: ; preds = %21
%26 = load double*, double** %7
%27 = load double, double* %26
%28 = load double*, double** %6
%29 = load double, double* %28
%30 = fmul double %27, %29
store double %30, double* %12
%31 = load double*, double** %8
%32 = load double, double* %31
%33 = load double, double* %12
%34 = fadd double %32, %33
store double %34, double* %11
%35 = load double*, double** %8
%36 = load double, double* %35
%37 = load double, double* %11
%38 = fdiv double %36, %37
store double %38, double* %13
%39 = load double, double* %13
%40 = fcmp ogt double %39, 5.000000e-01
br i1 %40, label %41, label %47
41: ; preds = %25
%42 = load double, double* %12
%43 = load double, double* %11
%44 = fdiv double %42, %43
store double %44, double* %14
%45 = load double, double* %14
%46 = fsub double 1.000000e+00, %45
store double %46, double* %13
br label %50
47: ; preds = %25
%48 = load double, double* %13
%49 = fsub double 1.000000e+00, %48
store double %49, double* %14
br label %50
50: ; preds = %47, %41
%51 = load double*, double** %8
%52 = load double, double* %51
%53 = fmul double %52, 5.000000e-01
store double %53, double* %16
%54 = load double*, double** %7
%55 = load double, double* %54
%56 = fmul double %55, 5.000000e-01
store double %56, double* %17
%57 = load double*, double** %10
%58 = load double*, double** %9
%59 = call i32 @cdflib_beta_inc(double* %16, double* %17, double* %13, double* %14, double* %57, double* %58, i32* %15)
br label %60
60: ; preds = %50, %22
ret void
}

LLVM IR (-O2):
define void @cdflib_cumf(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* %3, double* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = bitcast double* %6 to i8*
%12 = bitcast double* %7 to i8*
%13 = bitcast i32* %8 to i8*
%14 = bitcast double* %9 to i8*
%15 = bitcast double* %10 to i8*
%16 = load double, double* %0
%17 = fcmp ugt double %16, 0.000000e+00
br i1 %17, label %19, label %18
18: ; preds = %5
store double 0.000000e+00, double* %3
store double 1.000000e+00, double* %4
br label %35
19: ; preds = %5
%20 = load double, double* %1
%21 = fmul double %16, %20
%22 = load double, double* %2
%23 = fadd double %22, %21
%24 = fdiv double %22, %23
store double %24, double* %6
%25 = fcmp ogt double %24, 5.000000e-01
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = fdiv double %21, %23
store double %27, double* %7
%28 = fsub double 1.000000e+00, %27
store double %28, double* %6
br label %31
29: ; preds = %19
%30 = fsub double 1.000000e+00, %24
store double %30, double* %7
br label %31
31: ; preds = %29, %26
%32 = fmul double %22, 5.000000e-01
store double %32, double* %9
%33 = fmul double %20, 5.000000e-01
store double %33, double* %10
%34 = call i32 @cdflib_beta_inc(double* %9, double* %10, double* %6, double* %7, double* %4, double* %3, i32* %8)
br label %35
35: ; preds = %31, %18
ret void
}