#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*/ exit(int);
double exp(scalar_t__);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ lngamma(double);
double pow(int, double);
double sqrt(double);
int /*<<< orphan*/ stderr;
double student_t_density(double n, double x, const char *prompt) {
  if (n <= 0) {
    fprintf(stderr,
            "%s: IMPLEMENTATION ERROR! (Invalid argument in function "
            "\"student_t_density\")\n",
            prompt);
    exit(4);
  }
  return exp(lngamma((n + 1) / 2) - lngamma(n / 2)) / sqrt(n / 2) *
         pow((1 + x * x / n), -(n + 1) / 2);
}


x86 assembly (clang, -O0):
<student_t_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     11a7 <student_t_density+0x47>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe78(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x4,%edi
call   1080 <exit@plt>
movsd  0xe59(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <lngamma@plt>
mov    %rax,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe2a(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <lngamma@plt>
mov    -0x30(%rbp),%rdi
sub    %rax,%rdi
call   1040 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe03(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  -0x8(%rbp),%xmm1
movsd  0xdda(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  0xdca(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd9e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<student_t_density>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm1,0x28(%rsp)
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    1235 <student_t_density+0xd5>
movsd  0xe7b(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
mulsd  0xe71(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
call   1050 <lngamma@plt>
mov    %rax,%rbx
movsd  0xe5b(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1050 <lngamma@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
call   1040 <exp@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
ucomisd 0xe3b(%rip),%xmm0
jb     11e5 <student_t_density+0x85>
sqrtsd %xmm0,%xmm0
jmp    11ea <student_t_density+0x8a>
call   1070 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  %xmm0,%xmm0
divsd  0x10(%rsp),%xmm0
addsd  0xdee(%rip),%xmm0
cvttsd2si %xmm0,%edi
movsd  0x20(%rsp),%xmm0
mulsd  0xdec(%rip),%xmm0
call   1060 <pow@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
ret
mov    %rdi,%rdx
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x4,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [78 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22student_t_density\22)\0A\00"
define double @student_t_density(double %0, double %1, i8* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i8*
store double %0, double* %4
store double %1, double* %5
store i8* %2, i8** %6
%7 = load double, double* %4
%8 = fcmp ole double %7, 0.000000e+00
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %6
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 @exit(i32 4)
unreachable
14: ; preds = %3
%15 = load double, double* %4
%16 = fadd double %15, 1.000000e+00
%17 = fdiv double %16, 2.000000e+00
%18 = call i64 @lngamma(double %17)
%19 = load double, double* %4
%20 = fdiv double %19, 2.000000e+00
%21 = call i64 @lngamma(double %20)
%22 = sub nsw i64 %18, %21
%23 = call double @exp(i64 %22)
%24 = load double, double* %4
%25 = fdiv double %24, 2.000000e+00
%26 = call double @sqrt(double %25)
%27 = fdiv double %23, %26
%28 = load double, double* %5
%29 = load double, double* %5
%30 = fmul double %28, %29
%31 = load double, double* %4
%32 = fdiv double %30, %31
%33 = fadd double 1.000000e+00, %32
%34 = fptosi double %33 to i32
%35 = load double, double* %4
%36 = fadd double %35, 1.000000e+00
%37 = fneg double %36
%38 = fdiv double %37, 2.000000e+00
%39 = call double @pow(i32 %34, double %38)
%40 = fmul double %27, %39
ret double %40
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [78 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22student_t_density\22)\0A\00"
define double @student_t_density(double %0, double %1, i8* %2) {
%4 = fcmp ugt double %0, 0.000000e+00
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i8* %2)
%8 = tail call i32 @exit(i32 4)
unreachable
9: ; preds = %3
%10 = fadd double %0, 1.000000e+00
%11 = fmul double %10, 5.000000e-01
%12 = tail call i64 @lngamma(double %11)
%13 = fmul double %0, 5.000000e-01
%14 = tail call i64 @lngamma(double %13)
%15 = sub nsw i64 %12, %14
%16 = tail call double @exp(i64 %15)
%17 = tail call double @sqrt(double %13)
%18 = fdiv double %16, %17
%19 = fmul double %1, %1
%20 = fdiv double %19, %0
%21 = fadd double %20, 1.000000e+00
%22 = fptosi double %21 to i32
%23 = fmul double %10, -5.000000e-01
%24 = tail call double @pow(i32 %22, double %23)
%25 = fmul double %18, %24
ret double %25
}