#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 LogGamma(double);
double exp(double);
double log(double);
double pdfChisquare(long n, double x) {
  double t, s = n / 2.0;
  t = (s - 1.0) * log(x / 2.0) - (x / 2.0) - log(2.0) - LogGamma(s);
  return (exp(t));
}


x86 assembly (clang, -O0):
<pdfChisquare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xeb1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe67(%rip),%xmm3
divsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe37(%rip),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <LogGamma@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <exp@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdfChisquare>:
sub    $0x18,%rsp
cvtsi2sd %rdi,%xmm1
movsd  0xebf(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xeb5(%rip),%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
addsd  0xe92(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <LogGamma@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
jmp    1040 <exp@plt>

LLVM IR (-O0):
define double @pdfChisquare(i64 %0, double %1) {
%3 = alloca i64
%4 = alloca double
%5 = alloca double
%6 = alloca double
store i64 %0, i64* %3
store double %1, double* %4
%7 = load i64, i64* %3
%8 = sitofp i64 %7 to double
%9 = fdiv double %8, 2.000000e+00
store double %9, double* %6
%10 = load double, double* %6
%11 = fsub double %10, 1.000000e+00
%12 = load double, double* %4
%13 = fdiv double %12, 2.000000e+00
%14 = call double @log(double %13)
%15 = load double, double* %4
%16 = fdiv double %15, 2.000000e+00
%17 = fneg double %16
%18 = call double @llvm.fmuladd.f64(double %11, double %14, double %17)
%19 = call double @log(double 2.000000e+00)
%20 = fsub double %18, %19
%21 = load double, double* %6
%22 = call double @LogGamma(double %21)
%23 = fsub double %20, %22
store double %23, double* %5
%24 = load double, double* %5
%25 = call double @exp(double %24)
ret double %25
}

LLVM IR (-O2):
define double @pdfChisquare(i64 %0, double %1) {
%3 = sitofp i64 %0 to double
%4 = fmul double %3, 5.000000e-01
%5 = fadd double %4, -1.000000e+00
%6 = fmul double %1, 5.000000e-01
%7 = tail call double @log(double %6)
%8 = fneg double %6
%9 = tail call double @llvm.fmuladd.f64(double %5, double %7, double %8)
%10 = fadd double %9, 0xBFE62E42FEFA39EF
%11 = tail call double @LogGamma(double %4)
%12 = fsub double %10, %11
%13 = tail call double @exp(double %12)
ret double %13
}