// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movl %edi, 0x24(%rsp)
cvtsi2sd %edi, %xmm1
movapd %xmm1, %xmm2
movsd %xmm0, 0x18(%rsp)
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %r12d
leal 0x1(%r12), %eax
movl %eax, 0x10(%rsp)
leal 0x2(%r12,%r12), %r13d
leal 0x1(%r12,%r12), %r15d
movapd 0x1639(%rip), %xmm0     # 0x364b0
movapd %xmm1, 0x60(%rsp)
xorpd %xmm1, %xmm0
movapd %xmm0, (%rsp)
movl %r15d, %r14d
imull %r14d, %r14d
shlq $0x3, %r14
movq %r14, %rdi
callq 0x7560
movq %rax, %rbx
movq %r14, %rdi
callq 0x7560
movslq %r15d, %r9
xorl %r8d, %r8d
testl %r9d, %r9d
movl $0x0, %ebp
cmovgl %r15d, %ebp
movq %r12, 0x40(%rsp)
leal (%r12,%r12), %ecx
movslq %ecx, %rcx
leaq 0x8(,%rcx,8), %rcx
movsd 0x159e(%rip), %xmm0     # 0x36470
movq %rbx, %rdx
cmpq %rbp, %r8
je 0x34f07
movq %r8, %rsi
xorl %edi, %edi
cmpq %rdi, %r15
je 0x34eff
xorpd %xmm1, %xmm1
cmpq $-0x1, %rsi
jl 0x34ef2
movapd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rdi,8)
incq %rdi
decq %rsi
jmp 0x34edf
incq %r8
addq %rcx, %rdx
jmp 0x34ed5
movq %r9, 0x30(%rsp)
movq %rax, 0x48(%rsp)
cvtsi2sdl 0x10(%rsp), %xmm0
movapd (%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movq %r13, 0x38(%rsp)
leal -0x2(%r13), %eax
movslq %eax, %rcx
imull %r15d, %eax
cltq
movq %rax, 0x28(%rsp)
leaq (%rbx,%rax,8), %rax
movq %rax, 0x18(%rsp)
leaq 0x8(,%rcx,8), %rax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
movq %rbx, 0x50(%rsp)
movl %r15d, %r12d
cmpq %r14, %rbp
je 0x34fbd
movq %rbp, %r13
leaq 0x1(%r14), %rbp
cvtsi2sd %ebp, %xmm1
movapd (%rsp), %xmm0
callq 0x7720
movsd (%rbx), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rbx)
cvtsi2sd %r12d, %xmm1
movapd (%rsp), %xmm0
callq 0x7720
movq 0x18(%rsp), %rax
movsd (%rax,%r14,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rax,%r14,8)
decl %r12d
addq 0x10(%rsp), %rbx
movq %rbp, %r14
movq %r13, %rbp
jmp 0x34f63
movapd (%rsp), %xmm1
addsd %xmm1, %xmm1
addsd 0x14c2(%rip), %xmm1     # 0x36490
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x34fe6
movapd %xmm1, %xmm0
cvtsi2sd %r15d, %xmm1
callq 0x7720
movq 0x50(%rsp), %rbx
movq 0x28(%rsp), %rax
addsd (%rbx,%rax,8), %xmm0
movsd %xmm0, (%rbx,%rax,8)
movl %r15d, %eax
pushq $0x1
popq %rcx
xorl %edx, %edx
movsd 0x1466(%rip), %xmm0     # 0x36470
movq 0x48(%rsp), %r14
movq 0x38(%rsp), %r13
movq 0x30(%rsp), %r10
cmpq %rbp, %rdx
je 0x35072
movq %rdx, %rsi
imulq %r10, %rsi
leaq (%rbx,%rsi,8), %rsi
xorl %edi, %edi
movl %ecx, %r8d
testl %r8d, %r8d
movl $0x0, %r9d
cmovgl %r8d, %r9d
cmpq %rax, %rdi
je 0x3506b
cmpq %rdi, %rdx
jae 0x3504d
incq %rdi
decl %r8d
jmp 0x3502e
movapd %xmm0, %xmm1
subl $0x1, %r9d
jb 0x35045
movsd (%rsi,%rdi,8), %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, (%rsi,%rdi,8)
addsd %xmm0, %xmm1
jmp 0x35051
incq %rdx
incl %ecx
jmp 0x35019
leaq 0x5c(%rsp), %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl %r15d, %ecx
movl 0x24(%rsp), %ebp
movl %ebp, %r8d
callq 0x3578c
imull 0x40(%rsp), %r13d
movslq %r13d, %rax
movsd (%r14,%rax,8), %xmm6
movl (%r12), %eax
xorl %ecx, %ecx
testl %ebp, %ebp
cmovgl %ebp, %ecx
movsd 0x13bf(%rip), %xmm0     # 0x36470
movsd 0x62ef(%rip), %xmm1     # 0x3b3a8
movsd 0x62df(%rip), %xmm2     # 0x3b3a0
movapd %xmm0, %xmm3
movapd 0x60(%rsp), %xmm5
subl $0x1, %ecx
jb 0x350fd
mulsd %xmm3, %xmm6
divsd %xmm5, %xmm6
leal -0x8c(%rax), %edx
ucomisd %xmm6, %xmm1
movapd %xmm6, %xmm4
mulsd %xmm2, %xmm4
cmoval %edx, %eax
ja 0x350f3
movapd %xmm6, %xmm4
addsd %xmm0, %xmm3
movapd %xmm4, %xmm6
jmp 0x350cb
cvtsi2sd %eax, %xmm1
movsd 0x137f(%rip), %xmm0     # 0x36488
movsd %xmm6, (%rsp)
callq 0x7720
mulsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x74e0
movq %r14, %rdi
callq 0x74e0
movsd (%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq