// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movsd %xmm0, -0x10(%rbp)
cvtsi2sdl -0x4(%rbp), %xmm0
mulsd -0x10(%rbp), %xmm0
cvttsd2si %xmm0, %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
shll %eax
subl $0x1, %eax
movl %eax, -0x18(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm1
cvtsi2sdl -0x4(%rbp), %xmm0
movsd -0x10(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x18(%rbp), %eax
imull -0x18(%rbp), %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x8780
movq %rax, -0x48(%rbp)
movl -0x18(%rbp), %eax
imull -0x18(%rbp), %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x8780
movq %rax, -0x50(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x857ef
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x857e2
movl -0x1c(%rbp), %eax
subl -0x20(%rbp), %eax
addl $0x1, %eax
cmpl $0x0, %eax
jge 0x857b7
movq -0x48(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull -0x18(%rbp), %ecx
addl -0x20(%rbp), %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x857d5
movq -0x48(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull -0x18(%rbp), %ecx
addl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movsd 0x2cd8(%rip), %xmm0     # 0x884a8
movsd %xmm0, (%rax,%rcx,8)
jmp 0x857d7
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x85786
jmp 0x857e4
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x85777
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x85875
movsd -0x38(%rbp), %xmm0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm1
callq 0x8a20
movaps %xmm0, %xmm1
movq -0x48(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull -0x18(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movsd -0x38(%rbp), %xmm0
movl -0x18(%rbp), %eax
subl -0x1c(%rbp), %eax
cvtsi2sd %eax, %xmm1
callq 0x8a20
movaps %xmm0, %xmm1
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
imull -0x18(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x857f6
movsd -0x38(%rbp), %xmm0
addsd %xmm0, %xmm0
movsd 0x2c42(%rip), %xmm1     # 0x884c8
addsd %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x858b9
movsd -0x38(%rbp), %xmm0
addsd %xmm0, %xmm0
movsd 0x2c24(%rip), %xmm1     # 0x884c8
addsd %xmm1, %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
callq 0x8a20
movsd %xmm0, -0x58(%rbp)
jmp 0x858c3
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x858c3
movsd -0x58(%rbp), %xmm0
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
imull -0x18(%rbp), %ecx
movslq %ecx, %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x85978
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x85968
movl -0x1c(%rbp), %eax
subl -0x20(%rbp), %eax
addl $0x1, %eax
cmpl $0x0, %eax
jle 0x8595b
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl -0x20(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jg 0x85959
cvtsi2sdl -0x24(%rbp), %xmm1
movq -0x48(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull -0x18(%rbp), %ecx
addl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8591a
jmp 0x8595b
jmp 0x8595d
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x858fd
jmp 0x8596a
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x858ea
movl $0x0, -0x28(%rbp)
movq -0x48(%rbp), %rdi
movl -0x28(%rbp), %esi
movq -0x50(%rbp), %rdx
movl -0x18(%rbp), %r8d
movl -0x4(%rbp), %r9d
leaq -0x2c(%rbp), %rcx
callq 0x87ab0
movq -0x50(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
imull -0x18(%rbp), %ecx
addl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jg 0x85a20
movsd -0x40(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x4(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x7cb1(%rip), %xmm0     # 0x8d6a0
ucomisd -0x40(%rbp), %xmm0
jbe 0x85a13
movsd 0x7c9a(%rip), %xmm0     # 0x8d698
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x2c(%rbp), %eax
subl $0x8c, %eax
movl %eax, -0x2c(%rbp)
jmp 0x85a15
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x859c3
cvtsi2sdl -0x2c(%rbp), %xmm1
movsd 0x2a8b(%rip), %xmm0     # 0x884b8
callq 0x8a20
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x48(%rbp), %rdi
callq 0x86d0
movq -0x50(%rbp), %rdi
callq 0x86d0
movsd -0x40(%rbp), %xmm0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)