#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*/ assert(int);
int /*<<< orphan*/ df_to_index(float, int *, float *);
float get_t(int, int, float);
int /*<<< orphan*/ index_to_p(int);
float linear(float, float, int /*<<< orphan*/, float, int /*<<< orphan*/);
float student_t_p_2tail(float t, float df) {
  int df_index1, p_index_min, p_index_mid, p_index_max;
  float df_weight1, t_max, t_mid, t_min;
  p_index_min = 0;
  p_index_max = 189;
  df_to_index(df, &df_index1, &df_weight1);
  if (t < 0)
    t = -t;
  if (t > get_t(p_index_min, df_index1, df_weight1))
    return 0.000;
  if (t < get_t(p_index_max, df_index1, df_weight1))
    return 1.000;
  while (p_index_max - p_index_min > 1) {
    p_index_mid = (p_index_min + p_index_max) / 2;
    t_mid = get_t(p_index_mid, df_index1, df_weight1);
    if (t_mid >= t)
      p_index_min = p_index_mid;
    if (t_mid <= t)
      p_index_max = p_index_mid;
  }
  t_max = get_t(p_index_min, df_index1, df_weight1);
  t_min = get_t(p_index_max, df_index1, df_weight1);
  assert(t >= t_min);
  assert(t <= t_max);
  return linear(t, t_max, index_to_p(p_index_min), t_min,
                index_to_p(p_index_max));
}


x86 assembly (clang, -O0):
<student_t_p_2tail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xbd,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <df_to_index@plt>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11a6 <student_t_p_2tail+0x56>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
movss  -0x20(%rbp),%xmm0
call   1070 <get_t@plt>
movaps %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11de <student_t_p_2tail+0x8e>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    132e <student_t_p_2tail+0x1de>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%esi
movss  -0x20(%rbp),%xmm0
call   1070 <get_t@plt>
movss  -0x34(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jbe    1218 <student_t_p_2tail+0xc8>
movss  0xdf2(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    132e <student_t_p_2tail+0x1de>
jmp    121d <student_t_p_2tail+0xcd>
mov    -0x1c(%rbp),%eax
sub    -0x14(%rbp),%eax
cmp    $0x1,%eax
jle    1285 <student_t_p_2tail+0x135>
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%esi
movss  -0x20(%rbp),%xmm0
call   1070 <get_t@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1267 <student_t_p_2tail+0x117>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
movss  -0x28(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     1280 <student_t_p_2tail+0x130>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    121d <student_t_p_2tail+0xcd>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
movss  -0x20(%rbp),%xmm0
call   1070 <get_t@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%esi
movss  -0x20(%rbp),%xmm0
call   1070 <get_t@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0x2c(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movss  -0x8(%rbp),%xmm1
movss  -0x24(%rbp),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <index_to_p@plt>
mov    %eax,-0x3c(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <index_to_p@plt>
movss  -0x44(%rbp),%xmm0
movss  -0x40(%rbp),%xmm1
mov    -0x3c(%rbp),%edi
movss  -0x38(%rbp),%xmm2
mov    %eax,%esi
call   1060 <linear@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<student_t_p_2tail>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps %xmm0,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
movaps %xmm1,%xmm0
call   1030 <df_to_index@plt>
movaps 0xe8a(%rip),%xmm0
movaps 0x10(%rsp),%xmm2
xorps  %xmm2,%xmm0
xorps  %xmm1,%xmm1
movaps %xmm2,%xmm3
cmpltss %xmm1,%xmm3
andps  %xmm3,%xmm0
andnps %xmm2,%xmm3
orps   %xmm0,%xmm3
movaps %xmm3,0x10(%rsp)
mov    0x8(%rsp),%esi
movss  0x4(%rsp),%xmm0
xor    %edi,%edi
call   1070 <get_t@plt>
movaps 0x10(%rsp),%xmm1
ucomiss %xmm0,%xmm1
xorps  %xmm0,%xmm0
ja     12b1 <student_t_p_2tail+0x161>
mov    0x8(%rsp),%esi
movss  0x4(%rsp),%xmm0
mov    $0xbd,%r14d
mov    $0xbd,%edi
call   1070 <get_t@plt>
ucomiss 0x10(%rsp),%xmm0
jbe    11e7 <student_t_p_2tail+0x97>
movss  0xe2e(%rip),%xmm0
jmp    12b1 <student_t_p_2tail+0x161>
xor    %ebx,%ebx
jmp    11fa <student_t_p_2tail+0xaa>
nopl   0x0(%rax,%rax,1)
mov    %r14d,%eax
sub    %ebx,%eax
cmp    $0x1,%eax
jle    122e <student_t_p_2tail+0xde>
lea    (%rbx,%r14,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    0x8(%rsp),%esi
movss  0x4(%rsp),%xmm0
mov    %ebp,%edi
call   1070 <get_t@plt>
movaps 0x10(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jb     1224 <student_t_p_2tail+0xd4>
mov    %ebp,%ebx
ucomiss %xmm0,%xmm1
jb     11f0 <student_t_p_2tail+0xa0>
mov    %ebp,%r14d
jmp    11f0 <student_t_p_2tail+0xa0>
mov    0x8(%rsp),%esi
movss  0x4(%rsp),%xmm0
mov    %ebx,%edi
call   1070 <get_t@plt>
movss  %xmm0,0xc(%rsp)
mov    0x8(%rsp),%esi
movss  0x4(%rsp),%xmm0
mov    %r14d,%edi
call   1070 <get_t@plt>
movss  %xmm0,0x2c(%rsp)
xor    %edi,%edi
movaps 0x10(%rsp),%xmm1
ucomiss %xmm0,%xmm1
setae  %dil
call   1050 <assert@plt>
xor    %edi,%edi
movss  0xc(%rsp),%xmm0
ucomiss 0x10(%rsp),%xmm0
setae  %dil
call   1050 <assert@plt>
mov    %ebx,%edi
call   1040 <index_to_p@plt>
mov    %eax,%ebx
mov    %r14d,%edi
call   1040 <index_to_p@plt>
movaps 0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
mov    %ebx,%edi
movss  0x2c(%rsp),%xmm2
mov    %eax,%esi
call   1060 <linear@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define float @student_t_p_2tail(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store float %0, float* %4
store float %1, float* %5
store i32 0, i32* %7
store i32 189, i32* %9
%14 = load float, float* %5
%15 = call i32 @df_to_index(float %14, i32* %6, float* %10)
%16 = load float, float* %4
%17 = fcmp olt float %16, 0.000000e+00
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load float, float* %4
%20 = fneg float %19
store float %20, float* %4
br label %21
21: ; preds = %18, %2
%22 = load float, float* %4
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = load float, float* %10
%26 = call float @get_t(i32 %23, i32 %24, float %25)
%27 = fcmp ogt float %22, %26
br i1 %27, label %28, label %29
28: ; preds = %21
store float 0.000000e+00, float* %3
br label %91
29: ; preds = %21
%30 = load float, float* %4
%31 = load i32, i32* %9
%32 = load i32, i32* %6
%33 = load float, float* %10
%34 = call float @get_t(i32 %31, i32 %32, float %33)
%35 = fcmp olt float %30, %34
br i1 %35, label %36, label %37
36: ; preds = %29
store float 1.000000e+00, float* %3
br label %91
37: ; preds = %29
br label %38
38: ; preds = %63, %37
%39 = load i32, i32* %9
%40 = load i32, i32* %7
%41 = sub nsw i32 %39, %40
%42 = icmp sgt i32 %41, 1
br i1 %42, label %43, label %64
43: ; preds = %38
%44 = load i32, i32* %7
%45 = load i32, i32* %9
%46 = add nsw i32 %44, %45
%47 = sdiv i32 %46, 2
store i32 %47, i32* %8
%48 = load i32, i32* %8
%49 = load i32, i32* %6
%50 = load float, float* %10
%51 = call float @get_t(i32 %48, i32 %49, float %50)
store float %51, float* %12
%52 = load float, float* %12
%53 = load float, float* %4
%54 = fcmp oge float %52, %53
br i1 %54, label %55, label %57
55: ; preds = %43
%56 = load i32, i32* %8
store i32 %56, i32* %7
br label %57
57: ; preds = %55, %43
%58 = load float, float* %12
%59 = load float, float* %4
%60 = fcmp ole float %58, %59
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = load i32, i32* %8
store i32 %62, i32* %9
br label %63
63: ; preds = %61, %57
br label %38
64: ; preds = %38
%65 = load i32, i32* %7
%66 = load i32, i32* %6
%67 = load float, float* %10
%68 = call float @get_t(i32 %65, i32 %66, float %67)
store float %68, float* %11
%69 = load i32, i32* %9
%70 = load i32, i32* %6
%71 = load float, float* %10
%72 = call float @get_t(i32 %69, i32 %70, float %71)
store float %72, float* %13
%73 = load float, float* %4
%74 = load float, float* %13
%75 = fcmp oge float %73, %74
%76 = zext i1 %75 to i32
%77 = call i32 @assert(i32 %76)
%78 = load float, float* %4
%79 = load float, float* %11
%80 = fcmp ole float %78, %79
%81 = zext i1 %80 to i32
%82 = call i32 @assert(i32 %81)
%83 = load float, float* %4
%84 = load float, float* %11
%85 = load i32, i32* %7
%86 = call i32 @index_to_p(i32 %85)
%87 = load float, float* %13
%88 = load i32, i32* %9
%89 = call i32 @index_to_p(i32 %88)
%90 = call float @linear(float %83, float %84, i32 %86, float %87, i32 %89)
store float %90, float* %3
br label %91
91: ; preds = %64, %36, %28
%92 = load float, float* %3
ret float %92
}

LLVM IR (-O2):
define float @student_t_p_2tail(float %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = bitcast i32* %3 to i8*
%6 = bitcast float* %4 to i8*
%7 = call i32 @df_to_index(float %1, i32* %3, float* %4)
%8 = fcmp olt float %0, 0.000000e+00
%9 = fneg float %0
%10 = select i1 %8, float %9, float %0
%11 = load i32, i32* %3
%12 = load float, float* %4
%13 = call float @get_t(i32 0, i32 %11, float %12)
%14 = fcmp ogt float %10, %13
br i1 %14, label %50, label %15
15: ; preds = %2
%16 = load i32, i32* %3
%17 = load float, float* %4
%18 = call float @get_t(i32 189, i32 %16, float %17)
%19 = fcmp olt float %10, %18
br i1 %19, label %50, label %20
20: ; preds = %15, %20
%21 = phi i32 [ %29, %20 ], [ 0, %15 ]
%22 = phi i32 [ %31, %20 ], [ 189, %15 ]
%23 = add nsw i32 %21, %22
%24 = sdiv i32 %23, 2
%25 = load i32, i32* %3
%26 = load float, float* %4
%27 = call float @get_t(i32 %24, i32 %25, float %26)
%28 = fcmp ult float %27, %10
%29 = select i1 %28, i32 %21, i32 %24
%30 = fcmp ugt float %27, %10
%31 = select i1 %30, i32 %22, i32 %24
%32 = sub nsw i32 %31, %29
%33 = icmp sgt i32 %32, 1
br i1 %33, label %20, label %34
34: ; preds = %20
%35 = load i32, i32* %3
%36 = load float, float* %4
%37 = call float @get_t(i32 %29, i32 %35, float %36)
%38 = load i32, i32* %3
%39 = load float, float* %4
%40 = call float @get_t(i32 %31, i32 %38, float %39)
%41 = fcmp oge float %10, %40
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = fcmp ole float %10, %37
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = call i32 @index_to_p(i32 %29)
%48 = call i32 @index_to_p(i32 %31)
%49 = call float @linear(float %10, float %37, i32 %47, float %40, i32 %48)
br label %50
50: ; preds = %15, %2, %34
%51 = phi float [ %49, %34 ], [ 0.000000e+00, %2 ], [ 1.000000e+00, %15 ]
ret float %51
}