#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 */
float exp(float);
float log(double);
int /*<<< orphan*/ printf(char *);
float betai(float a, float b, float x) {
  float betacf(float a, float b, float x);
  float gammln(float xx);
  float bt;
  if (x < 0.0 || x > 1.0) {
    printf("Error(betai):bad input x\n");
    return (0);
  }
  if (x == 0.0 || x == 1.0)
    bt = 0.0;
  else
    bt = exp(gammln(a + b) - gammln(a) - gammln(b) + a * log(x) +
             b * log(1.0 - x));
  if (x < (a + 1.0) / (a + b + 2.0))
    return (bt * betacf(a, b, x) / a);
  else
    return (1.0 - bt * betacf(b, a, 1.0 - x) / b);
}


x86 assembly (clang, -O0):
<betai>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     1198 <betai+0x48>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe72(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b1 <betai+0x61>
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    139a <betai+0x24a>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d2 <betai+0x82>
jp     11d2 <betai+0x82>
jmp    11f3 <betai+0xa3>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe1d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1200 <betai+0xb0>
jp     1200 <betai+0xb0>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    12bf <betai+0x16f>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
call   1060 <gammln@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x8(%rbp),%xmm0
call   1060 <gammln@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
call   1060 <gammln@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <log@plt>
movss  -0x24(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x20(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd69(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1050 <log@plt>
movss  -0x1c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x18(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <exp@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd27(%rip),%xmm2
addsd  %xmm2,%xmm0
movss  -0x8(%rbp),%xmm2
addss  -0xc(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movsd  0xd15(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    133e <betai+0x1ee>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
call   1070 <betacf@plt>
movaps %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
mulss  %xmm1,%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    139a <betai+0x24a>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm3
movsd  0xc9d(%rip),%xmm2
subsd  %xmm3,%xmm2
cvtsd2ss %xmm2,%xmm2
call   1070 <betacf@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
mulss  %xmm1,%xmm0
divss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xc73(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<betai>:
sub    $0x48,%rsp
movaps %xmm0,%xmm3
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
ja     12a0 <betai+0x150>
movaps %xmm2,%xmm4
ucomiss 0xe93(%rip),%xmm2
ja     12a0 <betai+0x150>
cvtss2sd %xmm4,%xmm5
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm4
movaps %xmm3,%xmm6
addss  %xmm1,%xmm6
movss  %xmm1,0xc(%rsp)
movaps %xmm3,0x20(%rsp)
jne    1197 <betai+0x47>
jnp    1254 <betai+0x104>
ucomiss 0xe62(%rip),%xmm4
jne    11a6 <betai+0x56>
jnp    1254 <betai+0x104>
movaps %xmm6,%xmm0
movss  %xmm4,0x1c(%rsp)
movsd  %xmm5,0x10(%rsp)
movaps %xmm6,0x30(%rsp)
call   1060 <gammln@plt>
movss  %xmm0,0x8(%rsp)
movaps 0x20(%rsp),%xmm0
call   1060 <gammln@plt>
movss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1060 <gammln@plt>
movss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <log@plt>
mulss  0x20(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
movsd  0xde9(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
call   1050 <log@plt>
mulss  0xc(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
call   1040 <exp@plt>
movaps 0x30(%rsp),%xmm6
movsd  0x10(%rsp),%xmm5
movss  0x1c(%rsp),%xmm4
movaps 0x20(%rsp),%xmm3
movaps %xmm0,%xmm2
movaps %xmm3,%xmm0
unpcklps %xmm6,%xmm0
cvtps2pd %xmm0,%xmm0
addpd  0xdab(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
ucomisd %xmm5,%xmm0
movss  %xmm2,0x8(%rsp)
jbe    12b1 <betai+0x161>
movaps %xmm3,%xmm0
movss  0xc(%rsp),%xmm1
movaps %xmm4,%xmm2
call   1070 <betacf@plt>
movss  0x8(%rsp),%xmm1
mulss  %xmm0,%xmm1
divss  0x20(%rsp),%xmm1
jmp    12ea <betai+0x19a>
lea    0xd79(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm1,%xmm1
jmp    12ea <betai+0x19a>
movss  0xd47(%rip),%xmm2
subss  %xmm4,%xmm2
movss  0xc(%rsp),%xmm0
movaps %xmm3,%xmm1
call   1070 <betacf@plt>
movss  0x8(%rsp),%xmm1
mulss  %xmm0,%xmm1
divss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
movss  0xd1a(%rip),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Error(betai):bad input x\0A\00"
define float @betai(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
%9 = load float, float* %7
%10 = fpext float %9 to double
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = load float, float* %7
%14 = fpext float %13 to double
%15 = fcmp ogt double %14, 1.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %12, %3
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store float 0.000000e+00, float* %4
br label %87
18: ; preds = %12
%19 = load float, float* %7
%20 = fpext float %19 to double
%21 = fcmp oeq double %20, 0.000000e+00
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load float, float* %7
%24 = fpext float %23 to double
%25 = fcmp oeq double %24, 1.000000e+00
br i1 %25, label %26, label %27
26: ; preds = %22, %18
store float 0.000000e+00, float* %8
br label %50
27: ; preds = %22
%28 = load float, float* %5
%29 = load float, float* %6
%30 = fadd float %28, %29
%31 = call float @gammln(float %30)
%32 = load float, float* %5
%33 = call float @gammln(float %32)
%34 = fsub float %31, %33
%35 = load float, float* %6
%36 = call float @gammln(float %35)
%37 = fsub float %34, %36
%38 = load float, float* %5
%39 = load float, float* %7
%40 = fpext float %39 to double
%41 = call float @log(double %40)
%42 = call float @llvm.fmuladd.f32(float %38, float %41, float %37)
%43 = load float, float* %6
%44 = load float, float* %7
%45 = fpext float %44 to double
%46 = fsub double 1.000000e+00, %45
%47 = call float @log(double %46)
%48 = call float @llvm.fmuladd.f32(float %43, float %47, float %42)
%49 = call float @exp(float %48)
store float %49, float* %8
br label %50
50: ; preds = %27, %26
%51 = load float, float* %7
%52 = fpext float %51 to double
%53 = load float, float* %5
%54 = fpext float %53 to double
%55 = fadd double %54, 1.000000e+00
%56 = load float, float* %5
%57 = load float, float* %6
%58 = fadd float %56, %57
%59 = fpext float %58 to double
%60 = fadd double %59, 2.000000e+00
%61 = fdiv double %55, %60
%62 = fcmp olt double %52, %61
br i1 %62, label %63, label %72
63: ; preds = %50
%64 = load float, float* %8
%65 = load float, float* %5
%66 = load float, float* %6
%67 = load float, float* %7
%68 = call float @betacf(float %65, float %66, float %67)
%69 = fmul float %64, %68
%70 = load float, float* %5
%71 = fdiv float %69, %70
store float %71, float* %4
br label %87
72: ; preds = %50
%73 = load float, float* %8
%74 = load float, float* %6
%75 = load float, float* %5
%76 = load float, float* %7
%77 = fpext float %76 to double
%78 = fsub double 1.000000e+00, %77
%79 = fptrunc double %78 to float
%80 = call float @betacf(float %74, float %75, float %79)
%81 = fmul float %73, %80
%82 = load float, float* %6
%83 = fdiv float %81, %82
%84 = fpext float %83 to double
%85 = fsub double 1.000000e+00, %84
%86 = fptrunc double %85 to float
store float %86, float* %4
br label %87
87: ; preds = %72, %63, %16
%88 = load float, float* %4
ret float %88
}

LLVM IR (-O2):
@str = [25 x i8] c"Error(betai):bad input x\00"
define float @betai(float %0, float %1, float %2) {
%4 = fpext float %2 to double
%5 = fcmp olt float %2, 0.000000e+00
%6 = fcmp ogt float %2, 1.000000e+00
%7 = or i1 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %47
10: ; preds = %3
%11 = fcmp oeq float %2, 0.000000e+00
%12 = fcmp oeq float %2, 1.000000e+00
%13 = or i1 %11, %12
%14 = fadd float %0, %1
br i1 %13, label %27, label %15
15: ; preds = %10
%16 = tail call float @gammln(float %14)
%17 = tail call float @gammln(float %0)
%18 = fsub float %16, %17
%19 = tail call float @gammln(float %1)
%20 = fsub float %18, %19
%21 = tail call float @log(double %4)
%22 = tail call float @llvm.fmuladd.f32(float %0, float %21, float %20)
%23 = fsub double 1.000000e+00, %4
%24 = tail call float @log(double %23)
%25 = tail call float @llvm.fmuladd.f32(float %1, float %24, float %22)
%26 = tail call float @exp(float %25)
br label %27
27: ; preds = %10, %15
%28 = phi float [ %26, %15 ], [ 0.000000e+00, %10 ]
%29 = insertelement <2 x float> poison, float %0, i64 0
%30 = insertelement <2 x float> %29, float %14, i64 1
%31 = fpext <2 x float> %30 to <2 x double>
%32 = fadd <2 x double> %31, <double 1.000000e+00, double 2.000000e+00>
%33 = extractelement <2 x double> %32, i64 0
%34 = extractelement <2 x double> %32, i64 1
%35 = fdiv double %33, %34
%36 = fcmp ogt double %35, %4
br i1 %36, label %37, label %41
37: ; preds = %27
%38 = tail call float @betacf(float %0, float %1, float %2)
%39 = fmul float %28, %38
%40 = fdiv float %39, %0
br label %47
41: ; preds = %27
%42 = fsub float 1.000000e+00, %2
%43 = tail call float @betacf(float %1, float %0, float %42)
%44 = fmul float %28, %43
%45 = fdiv float %44, %1
%46 = fsub float 1.000000e+00, %45
br label %47
47: ; preds = %41, %37, %8
%48 = phi float [ 0.000000e+00, %8 ], [ %40, %37 ], [ %46, %41 ]
ret float %48
}