#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 Beta_Distribution(double, double, double);
double Student_t_Distribution(double x, int n) {
  double a = (double)n / 2.0;
  double beta = Beta_Distribution(1.0 / (1.0 + x * x / n), a, 0.5);
  if (x > 0.0)
    return 1.0 - 0.5 * beta;
  else if (x < 0.0)
    return 0.5 * beta;
  return 0.5;
}


x86 assembly (clang, -O0):
<Student_t_Distribution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xee3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xeb7(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xeab(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe92(%rip),%xmm2
call   1030 <Beta_Distribution@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b1 <Student_t_Distribution+0xa1>
movsd  -0x28(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe65(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <Student_t_Distribution+0xd8>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d6 <Student_t_Distribution+0xc6>
movsd  0xe39(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <Student_t_Distribution+0xd8>
jmp    11db <Student_t_Distribution+0xcb>
movsd  0xe1d(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Student_t_Distribution>:
push   %rax
cvtsi2sd %edi,%xmm1
movsd  %xmm0,(%rsp)
movsd  0xede(%rip),%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
divsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm1
movsd  0xece(%rip),%xmm0
addsd  %xmm0,%xmm3
divsd  %xmm3,%xmm0
call   1030 <Beta_Distribution@plt>
movsd  (%rsp),%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jbe    1168 <Student_t_Distribution+0x58>
mulsd  0xeb2(%rip),%xmm0
addsd  0xea2(%rip),%xmm0
pop    %rax
ret
ucomisd %xmm2,%xmm1
movsd  0xe8c(%rip),%xmm1
jbe    1182 <Student_t_Distribution+0x72>
mulsd  0xe82(%rip),%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @Student_t_Distribution(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = sitofp i32 %8 to double
%10 = fdiv double %9, 2.000000e+00
store double %10, double* %6
%11 = load double, double* %4
%12 = load double, double* %4
%13 = fmul double %11, %12
%14 = load i32, i32* %5
%15 = sitofp i32 %14 to double
%16 = fdiv double %13, %15
%17 = fadd double 1.000000e+00, %16
%18 = fdiv double 1.000000e+00, %17
%19 = load double, double* %6
%20 = call double @Beta_Distribution(double %18, double %19, double 5.000000e-01)
store double %20, double* %7
%21 = load double, double* %4
%22 = fcmp ogt double %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %2
%24 = load double, double* %7
%25 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %24, double 1.000000e+00)
store double %25, double* %3
br label %34
26: ; preds = %2
%27 = load double, double* %4
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load double, double* %7
%31 = fmul double 5.000000e-01, %30
store double %31, double* %3
br label %34
32: ; preds = %26
br label %33
33: ; preds = %32
store double 5.000000e-01, double* %3
br label %34
34: ; preds = %33, %29, %23
%35 = load double, double* %3
ret double %35
}

LLVM IR (-O2):
define double @Student_t_Distribution(double %0, i32 %1) {
%3 = sitofp i32 %1 to double
%4 = fmul double %3, 5.000000e-01
%5 = fmul double %0, %0
%6 = fdiv double %5, %3
%7 = fadd double %6, 1.000000e+00
%8 = fdiv double 1.000000e+00, %7
%9 = tail call double @Beta_Distribution(double %8, double %4, double 5.000000e-01)
%10 = fcmp ogt double %0, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call double @llvm.fmuladd.f64(double %9, double -5.000000e-01, double 1.000000e+00)
br label %17
13: ; preds = %2
%14 = fcmp olt double %0, 0.000000e+00
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = fmul double %9, 5.000000e-01
br label %17
17: ; preds = %13, %15, %11
%18 = phi double [ %12, %11 ], [ %16, %15 ], [ 5.000000e-01, %13 ]
ret double %18
}