// File: /workspace/github_cpp_makefile_star2_O3/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, 0x2c(%rsp)
cvtsi2sd %edi, %xmm1
movsd %xmm1, 0x38(%rsp)
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ebx
leal 0x1(%rbx), %eax
leal 0x2(%rbx,%rbx), %ecx
movq %rcx, 0x18(%rsp)
leal 0x1(%rbx,%rbx), %ebp
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movl %ebp, %r15d
imull %r15d, %r15d
shlq $0x3, %r15
movq %r15, %rdi
callq 0x7570
movq %rax, 0x20(%rsp)
movq %r15, %rdi
callq 0x7570
movsd 0x8(%rsp), %xmm10
movq %rax, 0x40(%rsp)
movl %ebp, 0x14(%rsp)
movl %ebp, %r12d
movq %rbx, 0x30(%rsp)
testl %ebx, %ebx
js 0x4008f
movl 0x18(%rsp), %eax
leaq -0x1(%r12), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movq 0x20(%rsp), %rcx
addq $0x8, %rcx
movq 0x30(%rsp), %r11
leal (%r11,%r11), %edx
movslq %edx, %rdx
leaq 0x8(,%rdx,8), %rdx
movq $-0x1, %rsi
xorl %edi, %edi
movdqa 0x15bb(%rip), %xmm1     # 0x414f0
movdqa 0x15c3(%rip), %xmm2     # 0x41500
pxor %xmm2, %xmm0
movq 0x1527(%rip), %xmm3     # 0x41470
pcmpeqd %xmm4, %xmm4
movdqa 0x64eb(%rip), %xmm5     # 0x46440
movq %rsi, %r8
xorl %r9d, %r9d
movdqa %xmm1, %xmm6
movdqa %xmm6, %xmm7
pxor %xmm2, %xmm7
movdqa %xmm7, %xmm8
pcmpgtd %xmm0, %xmm8
pcmpeqd %xmm0, %xmm7
pshufd $0xf5, %xmm7, %xmm9     # xmm9 = xmm7[1,1,3,3]
pand %xmm8, %xmm9
pshufd $0xf5, %xmm8, %xmm7     # xmm7 = xmm8[1,1,3,3]
por %xmm9, %xmm7
movd %xmm7, %r10d
notl %r10d
testb $0x1, %r10b
je 0x3ffb4
leaq 0x1(%r8), %r10
pxor %xmm8, %xmm8
cmpq $-0x1, %r10
jl 0x3ffad
movdqa %xmm3, %xmm8
movq %xmm8, -0x8(%rcx,%r9,8)
pxor %xmm4, %xmm7
pextrw $0x4, %xmm7, %r10d
testb $0x1, %r10b
je 0x3ffd8
pxor %xmm7, %xmm7
cmpq $-0x1, %r8
jl 0x3ffd2
movdqa %xmm3, %xmm7
movq %xmm7, (%rcx,%r9,8)
addq $0x2, %r9
paddq %xmm5, %xmm6
addq $-0x2, %r8
cmpq %r9, %rax
jne 0x3ff5f
incq %rdi
incq %rsi
addq %rdx, %rcx
cmpq %r12, %rdi
jne 0x3ff55
testl %r11d, %r11d
js 0x4008f
movq 0x18(%rsp), %rcx
leal -0x2(%rcx), %eax
imull 0x14(%rsp), %eax
cltq
movq 0x20(%rsp), %r14
leaq (%r14,%rax,8), %r15
movslq %ecx, %rax
leaq -0x8(,%rax,8), %rax
movq %rax, 0x48(%rsp)
xorl %ebp, %ebp
movq %r12, %r13
leaq 0x1(%rbp), %rbx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movapd %xmm10, %xmm0
callq 0x7730
movsd (%r14), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r14)
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x7730
movsd 0x8(%rsp), %xmm10
movsd (%r15,%rbp,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r15,%rbp,8)
addq 0x48(%rsp), %r14
movq %rbx, %rbp
decq %r13
jne 0x40035
addsd %xmm10, %xmm10
addsd 0x13f3(%rip), %xmm10    # 0x41490
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm10
movl 0x14(%rsp), %ebp
jbe 0x400bd
movapd %xmm10, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
callq 0x7730
movq 0x18(%rsp), %rax
addl $-0x2, %eax
imull %ebp, %eax
cltq
movq 0x20(%rsp), %r14
addsd (%r14,%rax,8), %xmm0
movsd %xmm0, (%r14,%rax,8)
movq 0x30(%rsp), %r13
testl %r13d, %r13d
movl 0x2c(%rsp), %ebx
movq 0x40(%rsp), %r15
js 0x40141
movslq %ebp, %rax
xorl %ecx, %ecx
movsd 0x1375(%rip), %xmm0     # 0x41470
movq %rcx, %rdx
imulq %rax, %rdx
leaq (%r14,%rdx,8), %rdx
xorl %esi, %esi
movq %rcx, %rdi
subq %rsi, %rdi
js 0x40131
movsd (%rdx,%rsi,8), %xmm1
xorl %r8d, %r8d
movapd %xmm0, %xmm2
divsd %xmm2, %xmm1
addsd %xmm0, %xmm2
incq %r8
cmpq %r8, %rdi
jae 0x4011c
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %r12, %rsi
jne 0x40108
incq %rcx
cmpq %r12, %rcx
jne 0x400fb
leaq 0x54(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl %ebp, %ecx
movl %ebx, %r8d
callq 0x408d6
movq 0x18(%rsp), %rax
imull %r13d, %eax
cltq
movsd (%r15,%rax,8), %xmm2
movl (%r12), %eax
testl %ebx, %ebx
jle 0x401c7
movsd 0x12f6(%rip), %xmm0     # 0x41470
movsd 0x6296(%rip), %xmm1     # 0x46418
movsd 0x6286(%rip), %xmm3     # 0x46410
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 0x401b9
movapd %xmm2, %xmm6
addsd %xmm0, %xmm4
movapd %xmm6, %xmm2
decl %ebx
jne 0x40194
jmp 0x401cb
movapd %xmm2, %xmm6
movq %xmm6, 0x8(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd 0x12a8(%rip), %xmm0     # 0x41488
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