// File: millanek[P]Dsuite/KolmogorovSmirnovDist.cpp
// Function: CalcFloorCeil(int, double, double*, double*, double*)
static void CalcFloorCeil (
   int n,                         /* sample size */
   double t,                      /* = nx */
   double *A,                     /* A_i */
   double *Atflo,                 /* floor (A_i - t) */
   double *Atcei                  /* ceiling (A_i + t) */
   )
{
   /* Precompute A_i, floors, and ceilings for limits of sums in the
      Pomeranz algorithm */
   int i;
   int ell = (int) t;             /* floor (t) */
   double z = t - ell;            /* t - floor (t) */
   double w = ceil (t) - t;

   if (z > 0.5) {
      for (i = 2; i <= 2 * n + 2; i += 2)
         Atflo[i] = i / 2 - 2 - ell;
      for (i = 1; i <= 2 * n + 2; i += 2)
         Atflo[i] = i / 2 - 1 - ell;

      for (i = 2; i <= 2 * n + 2; i += 2)
         Atcei[i] = i / 2 + ell;
      for (i = 1; i <= 2 * n + 2; i += 2)
         Atcei[i] = i / 2 + 1 + ell;

   } else if (z > 0.0) {
      for (i = 1; i <= 2 * n + 2; i++)
         Atflo[i] = i / 2 - 1 - ell;

      for (i = 2; i <= 2 * n + 2; i++)
         Atcei[i] = i / 2 + ell;
      Atcei[1] = 1 + ell;

   } else {                       /* z == 0 */
      for (i = 2; i <= 2 * n + 2; i += 2)
         Atflo[i] = i / 2 - 1 - ell;
      for (i = 1; i <= 2 * n + 2; i += 2)
         Atflo[i] = i / 2 - ell;

      for (i = 2; i <= 2 * n + 2; i += 2)
         Atcei[i] = i / 2 - 1 + ell;
      for (i = 1; i <= 2 * n + 2; i += 2)
         Atcei[i] = i / 2 + ell;
   }

   if (w < z)
      z = w;
   A[0] = A[1] = 0;
   A[2] = z;
   A[3] = 1 - A[2];
   for (i = 4; i <= 2 * n + 1; i++)
      A[i] = A[i - 2] + 1;
   A[2 * n + 2] = n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cvttsd2si -0x10(%rbp), %eax
movl %eax, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
cvtsi2sdl -0x30(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x80b0
subsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x38(%rbp), %xmm0
movsd 0xf28(%rip), %xmm1      # 0x884b0
ucomisd %xmm1, %xmm0
jbe 0x876a0
movl $0x2, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x875d5
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
subl $0x2, %eax
subl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x87599
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x87618
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
subl $0x1, %eax
subl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x875dc
movl $0x2, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x87658
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8761f
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x8769b
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x1, %eax
addl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8765f
jmp 0x87857
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8774d
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x876f5
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
subl $0x1, %eax
subl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x876b9
movl $0x2, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x87735
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x876fc
movl -0x30(%rbp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x87855
movl $0x2, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x87790
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
subl $0x1, %eax
subl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x87754
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x877d0
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
subl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x87797
movl $0x2, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x87813
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
subl $0x1, %eax
addl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x877d7
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x87853
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8781a
jmp 0x87855
jmp 0x87857
movsd -0x40(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x87871
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movsd -0x38(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x18(%rbp), %rax
movsd 0xc06(%rip), %xmm0      # 0x884a8
subsd 0x10(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movl $0x4, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jg 0x878f8
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movsd 0xbcd(%rip), %xmm0      # 0x884a8
addsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x878b7
cvtsi2sdl -0x4(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0x4(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)