#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 kf_betai_aux(double, double, int);
double kf_betai(double a, double b, double x) {
  return x < (a + 1.) / (a + b + 2.) ? kf_betai_aux(a, b, x)
                                     : 1. - kf_betai_aux(b, a, 1. - x);
}


x86 assembly (clang, -O0):
<kf_betai>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xed4(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
addsd  -0x10(%rbp),%xmm2
movsd  0xeb5(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    117b <kf_betai+0x6b>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
cvttsd2si -0x18(%rbp),%edi
call   1030 <kf_betai_aux@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    11af <kf_betai+0x9f>
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xe7b(%rip),%xmm2
subsd  -0x18(%rbp),%xmm2
cvttsd2si %xmm2,%edi
call   1030 <kf_betai_aux@plt>
movaps %xmm0,%xmm1
movsd  0xe62(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kf_betai>:
push   %rax
movapd %xmm0,%xmm3
movsd  0xee3(%rip),%xmm0
movapd %xmm3,%xmm4
addsd  %xmm1,%xmm4
addsd  0xedb(%rip),%xmm4
addsd  %xmm3,%xmm0
divsd  %xmm4,%xmm0
ucomisd %xmm2,%xmm0
jbe    1149 <kf_betai+0x39>
cvttsd2si %xmm2,%edi
movapd %xmm3,%xmm0
pop    %rax
jmp    1030 <kf_betai_aux@plt>
movsd  0xeaf(%rip),%xmm0
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
movapd %xmm1,%xmm0
movapd %xmm3,%xmm1
call   1030 <kf_betai_aux@plt>
movsd  0xe92(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @kf_betai(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%7 = load double, double* %6
%8 = load double, double* %4
%9 = fadd double %8, 1.000000e+00
%10 = load double, double* %4
%11 = load double, double* %5
%12 = fadd double %10, %11
%13 = fadd double %12, 2.000000e+00
%14 = fdiv double %9, %13
%15 = fcmp olt double %7, %14
br i1 %15, label %16, label %22
16: ; preds = %3
%17 = load double, double* %4
%18 = load double, double* %5
%19 = load double, double* %6
%20 = fptosi double %19 to i32
%21 = call double @kf_betai_aux(double %17, double %18, i32 %20)
br label %30
22: ; preds = %3
%23 = load double, double* %5
%24 = load double, double* %4
%25 = load double, double* %6
%26 = fsub double 1.000000e+00, %25
%27 = fptosi double %26 to i32
%28 = call double @kf_betai_aux(double %23, double %24, i32 %27)
%29 = fsub double 1.000000e+00, %28
br label %30
30: ; preds = %22, %16
%31 = phi double [ %21, %16 ], [ %29, %22 ]
ret double %31
}

LLVM IR (-O2):
define double @kf_betai(double %0, double %1, double %2) {
%4 = fadd double %0, 1.000000e+00
%5 = fadd double %0, %1
%6 = fadd double %5, 2.000000e+00
%7 = fdiv double %4, %6
%8 = fcmp ogt double %7, %2
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = fptosi double %2 to i32
%11 = tail call double @kf_betai_aux(double %0, double %1, i32 %10)
br label %17
12: ; preds = %3
%13 = fsub double 1.000000e+00, %2
%14 = fptosi double %13 to i32
%15 = tail call double @kf_betai_aux(double %1, double %0, i32 %14)
%16 = fsub double 1.000000e+00, %15
br label %17
17: ; preds = %12, %9
%18 = phi double [ %11, %9 ], [ %16, %12 ]
ret double %18
}