// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/distributions.c
// Function: chi_square
double chi_square(int freedom, double x)
{
 double  a, y, s;
 double  e, c, z;
 int even;     /* true if df is an even number */
 if (x <= 0.0 || freedom < 1)
   return (1.0);
 a = 0.5 * x;
 even = (2*(freedom/2)) == freedom;
 if (freedom > 1)
   y = ex (-a);
 if (even)
   s = y;
 else
   s = (2.0 * z_normal (-sqrt (x)));
 if (freedom > 2)
  {
   x = 0.5 * (freedom - 1.0);
   if (even)
     z=1.0;
   else
     z=0.5;
   if (a > BIGX)
    {
     if (even)
       e=0.0;
     else
       e=LOG_SQRT_PI;
     c = log (a);
     while (z <= x)
      {
       e = log (z) + e;
       s += ex (c*z-a-e);
       z += 1.0;
      }
     return (s);
    }
   else
    {
     if (even)
       e = 1.0;
     else
       e=(I_SQRT_PI / sqrt (a));
     c = 0.0;
     while (z <= x)
      {
       e = e * (a / z);
       c = c + e;
       z += 1.0;
      }
     return (c * y + s);
    }
  }
 else
   return (s);
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
movsd 0x77f74(%rip), %xmm4    # 0x95520
testl %edi, %edi
jle 0x1d77a
movapd %xmm0, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jae 0x1d77a
movl %edi, %ebx
movsd 0x78750(%rip), %xmm3    # 0x95d20
mulsd %xmm1, %xmm3
cmpl $0x2, %edi
movapd %xmm3, 0x20(%rsp)
jb 0x1d612
xorpd %xmm6, %xmm6
ucomisd 0x7a45d(%rip), %xmm3    # 0x97a48
ja 0x1d612
movapd 0x78bdb(%rip), %xmm0    # 0x961d0
xorpd %xmm3, %xmm0
movsd %xmm1, (%rsp)
callq 0x4060
movsd (%rsp), %xmm1
movapd 0x20(%rsp), %xmm3
movapd %xmm0, %xmm6
movapd %xmm6, %xmm4
testb $0x1, %bl
je 0x1d65b
movsd %xmm6, 0x8(%rsp)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x1d631
sqrtsd %xmm1, %xmm0
jmp 0x1d63a
movapd %xmm1, %xmm0
callq 0x4300
xorpd 0x78b8e(%rip), %xmm0    # 0x961d0
callq 0x1d821
movapd %xmm0, %xmm4
addsd %xmm0, %xmm4
movapd 0x20(%rsp), %xmm3
movsd 0x8(%rsp), %xmm6
cmpl $0x3, %ebx
jb 0x1d77a
xorl %eax, %eax
testb $0x1, %bl
cvtsi2sd %ebx, %xmm5
addsd 0x7873b(%rip), %xmm5    # 0x95db0
sete %al
mulsd 0x786a0(%rip), %xmm5    # 0x95d20
leaq 0x7a369(%rip), %rcx     # 0x979f0
movsd (%rcx,%rax,8), %xmm7
ucomisd 0x7a3b4(%rip), %xmm3    # 0x97a48
movsd %xmm5, 0x18(%rsp)
jbe 0x1d784
movsd %xmm7, (%rsp)
movsd %xmm4, 0x10(%rsp)
xorpd %xmm0, %xmm0
testb $0x1, %bl
je 0x1d6bc
movsd 0x7a39c(%rip), %xmm0    # 0x97a58
movsd %xmm0, 0x8(%rsp)
movapd %xmm3, %xmm0
callq 0x4160
movapd 0x20(%rsp), %xmm2
movsd %xmm0, 0x38(%rsp)
xorpd 0x78af1(%rip), %xmm2    # 0x961d0
movsd 0x10(%rsp), %xmm4
movsd 0x18(%rsp), %xmm0
movsd (%rsp), %xmm3
movapd %xmm2, 0x20(%rsp)
ucomisd %xmm3, %xmm0
jb 0x1d77a
movsd %xmm4, 0x10(%rsp)
movapd %xmm3, %xmm0
movsd %xmm3, (%rsp)
callq 0x4160
movsd (%rsp), %xmm3
movapd 0x20(%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x38(%rsp), %xmm0
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
movsd %xmm1, 0x8(%rsp)
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
movsd 0x7a317(%rip), %xmm4    # 0x97a60
ucomisd %xmm0, %xmm4
ja 0x1d75d
callq 0x4060
movsd (%rsp), %xmm3
movapd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm4
addsd %xmm1, %xmm4
addsd 0x77db1(%rip), %xmm3    # 0x95520
movsd 0x18(%rsp), %xmm0
jmp 0x1d6f6
movapd %xmm4, %xmm0
addq $0x40, %rsp
popq %rbx
retq
movsd 0x77d93(%rip), %xmm8    # 0x95520
movapd %xmm8, %xmm1
testb $0x1, %bl
je 0x1d7f3
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm3
jb 0x1d7a7
sqrtsd %xmm3, %xmm0
jmp 0x1d7e7
movapd %xmm3, %xmm0
movsd %xmm4, 0x10(%rsp)
movsd %xmm6, 0x8(%rsp)
movsd %xmm7, (%rsp)
callq 0x4300
movsd 0x77d56(%rip), %xmm8    # 0x95520
movsd (%rsp), %xmm7
movsd 0x8(%rsp), %xmm6
movsd 0x18(%rsp), %xmm5
movsd 0x10(%rsp), %xmm4
movapd 0x20(%rsp), %xmm3
movsd 0x7a261(%rip), %xmm1    # 0x97a50
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm7, %xmm5
jb 0x1d814
movapd %xmm3, %xmm2
divsd %xmm7, %xmm2
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addsd %xmm8, %xmm7
jmp 0x1d7f7
mulsd %xmm6, %xmm0
addsd %xmm4, %xmm0
jmp 0x1d77e