// File: /workspace/github_cpp_makefile_star2_O1/millanek[P]Dsuite/KolmogorovSmirnovDist.cpp
// Function: DurbinMatrix(int, double)
static double DurbinMatrix (int n, double d)
{
   int k, m, i, j, g, eH, eQ;
   double h, s, *H, *Q;
   /* OMIT NEXT TWO LINES IF YOU REQUIRE >7 DIGIT ACCURACY IN THE RIGHT TAIL */
#if 0
   s = d * d * n;
   if (s > 7.24 || (s > 3.76 && n > 99))
      return 1 - 2 * exp (-(2.000071 + .331 / sqrt (n) + 1.409 / n) * s);
#endif
   k = (int) (n * d) + 1;
   m = 2 * k - 1;
   h = k - n * d;
   H = (double *) malloc ((m * m) * sizeof (double));
   Q = (double *) malloc ((m * m) * sizeof (double));
   for (i = 0; i < m; i++)
      for (j = 0; j < m; j++)
         if (i - j + 1 < 0)
            H[i * m + j] = 0;
         else
            H[i * m + j] = 1;
   for (i = 0; i < m; i++) {
      H[i * m] -= pow (h, (double)(i + 1));
      H[(m - 1) * m + i] -= pow (h, (double)(m - i));
   }
   H[(m - 1) * m] += (2 * h - 1 > 0 ? pow (2 * h - 1, (double) m) : 0);
   for (i = 0; i < m; i++)
      for (j = 0; j < m; j++)
         if (i - j + 1 > 0)
            for (g = 1; g <= i - j + 1; g++)
               H[i * m + j] /= g;
   eH = 0;
   mPower (H, eH, Q, &eQ, m, n);
   s = Q[(k - 1) * m + k - 1];

   for (i = 1; i <= n; i++) {
      s = s * (double) i / n;
      if (s < INORM) {
         s *= NORM;
         eQ -= LOGNORM;
      }
   }
   s *= pow (10., (double) eQ);
   free (H);
   free (Q);
   return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edi, %ebx
cvtsi2sd %edi, %xmm1
movsd %xmm1, 0x38(%rsp)
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
cvttsd2si %xmm0, %r12d
leal 0x1(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x8(%rsp)
leal 0x1(,%r12,2), %ebp
movl %ebp, %r15d
imull %r15d, %r15d
shlq $0x3, %r15
movq %r15, %rdi
callq 0x7570
movq %rax, %r14
movq %r15, %rdi
callq 0x7570
testl %r12d, %r12d
js 0x3f00a
cmpl $0x2, %ebp
movl $0x1, %r9d
cmovgel %ebp, %r9d
leal (%r12,%r12), %ecx
movslq %ecx, %rcx
leaq 0x8(,%rcx,8), %rcx
xorl %edx, %edx
movsd 0x1499(%rip), %xmm0     # 0x40470
movq %r14, %rsi
movq %rdx, %rdi
xorl %r8d, %r8d
xorpd %xmm1, %xmm1
cmpq $-0x1, %rdi
jl 0x3efee
movapd %xmm0, %xmm1
movsd %xmm1, (%rsi,%r8,8)
incq %r8
decq %rdi
cmpq %r8, %r9
jne 0x3efe0
incq %rdx
addq %rcx, %rsi
cmpq %r9, %rdx
jne 0x3efda
movl %ebp, 0x14(%rsp)
movq %rax, 0x48(%rsp)
movq %r14, 0x30(%rsp)
leal 0x2(,%r12,2), %eax
movq %rax, 0x18(%rsp)
movsd 0x8(%rsp), %xmm2
subsd 0x20(%rsp), %xmm2
movq %r12, 0x40(%rsp)
testl %r12d, %r12d
js 0x3f0e1
movq 0x18(%rsp), %rcx
leal -0x2(%rcx), %eax
movl 0x14(%rsp), %ebp
imull %ebp, %eax
cltq
cmpl $0x2, %ebp
movl $0x1, %edx
cmovgel %ebp, %edx
movq %rdx, 0x20(%rsp)
movq 0x30(%rsp), %r14
leaq (%r14,%rax,8), %r13
movslq %ecx, %rax
leaq -0x8(,%rax,8), %rax
movq %rax, 0x50(%rsp)
xorl %r12d, %r12d
movsd %xmm2, 0x8(%rsp)
leaq 0x1(%r12), %r15
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
movapd %xmm2, %xmm0
callq 0x7730
movsd (%r14), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r14)
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x7730
movsd 0x8(%rsp), %xmm2
movsd (%r13,%r12,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r13,%r12,8)
decl %ebp
addq 0x50(%rsp), %r14
movq %r15, %r12
cmpq %r15, 0x20(%rsp)
jne 0x3f082
addsd %xmm2, %xmm2
addsd 0x13a3(%rip), %xmm2     # 0x40490
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
movl 0x14(%rsp), %ebp
jbe 0x3f10b
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movapd %xmm2, %xmm0
callq 0x7730
movq 0x18(%rsp), %rax
addl $-0x2, %eax
imull %ebp, %eax
cltq
movq 0x30(%rsp), %r14
addsd (%r14,%rax,8), %xmm0
movsd %xmm0, (%r14,%rax,8)
movq 0x40(%rsp), %r13
testl %r13d, %r13d
movq 0x48(%rsp), %r15
js 0x3f196
cmpl $0x2, %ebp
movl $0x1, %eax
cmovgel %ebp, %eax
movslq %ebp, %rcx
xorl %edx, %edx
movsd 0x1320(%rip), %xmm0     # 0x40470
movq %rdx, %rsi
imulq %rcx, %rsi
leaq (%r14,%rsi,8), %rsi
xorl %edi, %edi
movq %rdx, %r8
subq %rdi, %r8
js 0x3f186
movsd (%rsi,%rdi,8), %xmm1
xorl %r9d, %r9d
movapd %xmm0, %xmm2
divsd %xmm2, %xmm1
addsd %xmm0, %xmm2
incq %r9
cmpq %r9, %r8
jge 0x3f171
movsd %xmm1, (%rsi,%rdi,8)
incq %rdi
cmpq %rax, %rdi
jne 0x3f15d
incq %rdx
cmpq %rax, %rdx
jne 0x3f150
leaq 0x2c(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl %ebp, %ecx
movl %ebx, %r8d
callq 0x3f93d
movq 0x18(%rsp), %rax
imull %r13d, %eax
cltq
movsd (%r15,%rax,8), %xmm2
movl (%r12), %eax
testl %ebx, %ebx
jle 0x3f21c
movsd 0x12a1(%rip), %xmm0     # 0x40470
movsd 0x61b1(%rip), %xmm1     # 0x45388
movsd 0x61a1(%rip), %xmm3     # 0x45380
movapd %xmm0, %xmm4
movsd 0x38(%rsp), %xmm5
movl %eax, %ecx
mulsd %xmm4, %xmm2
divsd %xmm5, %xmm2
leal -0x8c(%rcx), %eax
ucomisd %xmm2, %xmm1
movapd %xmm2, %xmm6
mulsd %xmm3, %xmm6
cmovbel %ecx, %eax
ja 0x3f20e
movapd %xmm2, %xmm6
addsd %xmm0, %xmm4
movapd %xmm6, %xmm2
decl %ebx
jne 0x3f1e9
jmp 0x3f220
movapd %xmm2, %xmm6
movsd %xmm6, 0x8(%rsp)
movl %eax, 0x2c(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd 0x124f(%rip), %xmm0     # 0x40488
callq 0x7730
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0x7500
movq %r15, %rdi
callq 0x7500
movsd 0x8(%rsp), %xmm0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq