#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 beta(double, double);
int /*<<< orphan*/ dbetaidx(double, double, double);
int /*<<< orphan*/ log(double);
int /*<<< orphan*/ printf(char *, double, double, int, ...);
void betai_test() {
  double betai(double, double, double);
  double x, a, b, q, p;
  int i;
  a = 10;
  b = 0.5;
  printf("#1/beta(%f,%f)=%12.6e\n", a, b, 1. / beta(a, b));
  for (i = 1; i < 100; i++) {
    x = (double)i / 100.;
    q = betai(a, b, x);
    printf("%15.10f%15.6e%15.6e%10.4f\n", x, betai(a, b, x), dbetaidx(a, b, x),
           log(q));
  }
}


x86 assembly (clang, -O0):
<betai_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <beta@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
cvtsi2sd %eax,%xmm3
movsd  0xe55(%rip),%xmm2
divsd  %xmm3,%xmm2
cvttsd2si %xmm2,%esi
lea    0xe66(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
cmpl   $0x64,-0x2c(%rbp)
jge    1270 <betai_test+0x120>
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xe39(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
call   1060 <betai@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
call   1060 <betai@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
call   1040 <dbetaidx@plt>
mov    %eax,-0x44(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1070 <log@plt>
movsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
mov    -0x44(%rbp),%esi
mov    %eax,%edx
lea    0xddc(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c8 <betai_test+0x78>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<betai_test>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  0xea0(%rip),%xmm0
movsd  0xea0(%rip),%xmm1
call   1050 <beta@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe94(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%esi
lea    0xe95(%rip),%rdi
movsd  0xe6d(%rip),%xmm0
movsd  0xe6d(%rip),%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
mov    $0x63,%ebx
lea    0xe89(%rip),%r14
movsd  0xe5a(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x18(%rsp)
movapd %xmm0,%xmm2
divsd  0xe46(%rip),%xmm2
movsd  %xmm2,(%rsp)
movsd  0xe21(%rip),%xmm0
movsd  0xe21(%rip),%xmm1
call   1060 <betai@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe06(%rip),%xmm0
movsd  0xe06(%rip),%xmm1
movsd  (%rsp),%xmm2
call   1060 <betai@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xde6(%rip),%xmm0
movsd  0xde6(%rip),%xmm1
movsd  (%rsp),%xmm2
call   1040 <dbetaidx@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
call   1070 <log@plt>
mov    %r14,%rdi
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %ebp,%esi
mov    %eax,%edx
mov    $0x2,%al
call   1030 <printf@plt>
movsd  0x18(%rsp),%xmm0
addsd  0xdb0(%rip),%xmm0
add    $0xffffffff,%ebx
jne    11c0 <betai_test+0x70>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"/beta(%f,%f)=%12.6e\0A\00"
@.str.1 = [27 x i8] c"%15.10f%15.6e%15.6e%10.4f\0A\00"
define void @betai_test() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double 1.000000e+01, double* %2
store double 5.000000e-01, double* %3
%7 = load double, double* %2
%8 = load double, double* %3
%9 = load double, double* %2
%10 = load double, double* %3
%11 = call i32 @beta(double %9, double %10)
%12 = sitofp i32 %11 to double
%13 = fdiv double 1.000000e+00, %12
%14 = fptosi double %13 to i32
%15 = call i32 (i8*, double, double, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %7, double %8, i32 %14)
store i32 1, i32* %6
br label %16
16: ; preds = %39, %0
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 100
br i1 %18, label %19, label %42
19: ; preds = %16
%20 = load i32, i32* %6
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 1.000000e+02
store double %22, double* %1
%23 = load double, double* %2
%24 = load double, double* %3
%25 = load double, double* %1
%26 = call double @betai(double %23, double %24, double %25)
store double %26, double* %4
%27 = load double, double* %1
%28 = load double, double* %2
%29 = load double, double* %3
%30 = load double, double* %1
%31 = call double @betai(double %28, double %29, double %30)
%32 = load double, double* %2
%33 = load double, double* %3
%34 = load double, double* %1
%35 = call i32 @dbetaidx(double %32, double %33, double %34)
%36 = load double, double* %4
%37 = call i32 @log(double %36)
%38 = call i32 (i8*, double, double, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %27, double %31, i32 %35, i32 %37)
br label %39
39: ; preds = %19
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %16
42: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"/beta(%f,%f)=%12.6e\0A\00"
@.str.1 = [27 x i8] c"%15.10f%15.6e%15.6e%10.4f\0A\00"
define void @betai_test() {
%1 = tail call i32 @beta(double 1.000000e+01, double 5.000000e-01)
%2 = sitofp i32 %1 to double
%3 = fdiv double 1.000000e+00, %2
%4 = fptosi double %3 to i32
%5 = tail call i32 (i8*, double, double, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double 1.000000e+01, double 5.000000e-01, i32 %4)
br label %6
6: ; preds = %0, %6
%7 = phi i32 [ 1, %0 ], [ %15, %6 ]
%8 = sitofp i32 %7 to double
%9 = fdiv double %8, 1.000000e+02
%10 = tail call double @betai(double 1.000000e+01, double 5.000000e-01, double %9)
%11 = tail call double @betai(double 1.000000e+01, double 5.000000e-01, double %9)
%12 = tail call i32 @dbetaidx(double 1.000000e+01, double 5.000000e-01, double %9)
%13 = tail call i32 @log(double %10)
%14 = tail call i32 (i8*, double, double, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %9, double %11, i32 %12, i32 %13)
%15 = add nuw nsw i32 %7, 1
%16 = icmp eq i32 %15, 100
br i1 %16, label %17, label %6
17: ; preds = %6
ret void
}