#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 confrac(double, double, double);
double ibeta(double a, double b, double x) {
  if (a <= 0.0 || b <= 0.0)
    return -1.0;
  if (x < 0.0 || x > 1.0)
    return -1.0;
  ;
  if (x == 0.0 || x == 1.0)
    return x;
  if (a < x * (a + b)) {
    double temp = confrac(b, a, 1.0 - x);
    return (temp < 0.0) ? temp : 1.0 - temp;
  } else {
    return confrac(a, b, x);
  }
}


x86 assembly (clang, -O0):
<ibeta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    1143 <ibeta+0x33>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1155 <ibeta+0x45>
movsd  0xebd(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    126f <ibeta+0x15f>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     117a <ibeta+0x6a>
movsd  -0x20(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118c <ibeta+0x7c>
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    126f <ibeta+0x15f>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a9 <ibeta+0x99>
jp     11a9 <ibeta+0x99>
jmp    11c6 <ibeta+0xb6>
movsd  -0x20(%rbp),%xmm0
movsd  0xe4a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11d5 <ibeta+0xc5>
jp     11d5 <ibeta+0xc5>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    126f <ibeta+0x15f>
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
addsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    1256 <ibeta+0x146>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xdf7(%rip),%xmm2
subsd  -0x20(%rbp),%xmm2
call   1030 <confrac@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1235 <ibeta+0x125>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1247 <ibeta+0x137>
movsd  0xdc3(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    126f <ibeta+0x15f>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1030 <confrac@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ibeta>:
push   %rax
movapd %xmm0,%xmm3
xorpd  %xmm4,%xmm4
ucomisd %xmm0,%xmm4
movsd  0xedb(%rip),%xmm0
jae    11b9 <ibeta+0xa9>
ucomisd %xmm1,%xmm4
jae    11b9 <ibeta+0xa9>
xorpd  %xmm4,%xmm4
ucomisd %xmm2,%xmm4
ja     11b9 <ibeta+0xa9>
ucomisd 0xec1(%rip),%xmm2
ja     11b9 <ibeta+0xa9>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    1155 <ibeta+0x45>
jnp    11bb <ibeta+0xab>
ucomisd 0xeab(%rip),%xmm2
jne    1161 <ibeta+0x51>
jnp    11bb <ibeta+0xab>
movapd %xmm3,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm3,%xmm0
jbe    11c1 <ibeta+0xb1>
movsd  0xe8d(%rip),%xmm4
subsd  %xmm2,%xmm4
movapd %xmm1,%xmm0
movapd %xmm3,%xmm1
movapd %xmm4,%xmm2
call   1030 <confrac@plt>
movapd %xmm0,%xmm1
movsd  0xe6c(%rip),%xmm3
subsd  %xmm1,%xmm3
xorpd  %xmm2,%xmm2
movapd %xmm1,%xmm0
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
pop    %rax
ret
movapd %xmm2,%xmm0
pop    %rax
ret
movapd %xmm3,%xmm0
pop    %rax
jmp    1030 <confrac@plt>

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

LLVM IR (-O2):
define double @ibeta(double %0, double %1, double %2) {
%4 = fcmp ole double %0, 0.000000e+00
%5 = fcmp ole double %1, 0.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %27, label %7
7: ; preds = %3
%8 = fcmp olt double %2, 0.000000e+00
%9 = fcmp ogt double %2, 1.000000e+00
%10 = or i1 %8, %9
br i1 %10, label %27, label %11
11: ; preds = %7
%12 = fcmp oeq double %2, 0.000000e+00
%13 = fcmp oeq double %2, 1.000000e+00
%14 = or i1 %12, %13
br i1 %14, label %27, label %15
15: ; preds = %11
%16 = fadd double %0, %1
%17 = fmul double %16, %2
%18 = fcmp ogt double %17, %0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = fsub double 1.000000e+00, %2
%21 = tail call double @confrac(double %1, double %0, double %20)
%22 = fcmp olt double %21, 0.000000e+00
%23 = fsub double 1.000000e+00, %21
%24 = select i1 %22, double %21, double %23
br label %27
25: ; preds = %15
%26 = tail call double @confrac(double %0, double %1, double %2)
br label %27
27: ; preds = %11, %7, %3, %25, %19
%28 = phi double [ %24, %19 ], [ %26, %25 ], [ -1.000000e+00, %3 ], [ -1.000000e+00, %7 ], [ %2, %11 ]
ret double %28
}