// File: /workspace/github_c_makefile_star2_O3/zpole[P]IICV/vl/quickshift.c
// Function: vl_quickshift_process
VL_EXPORT
void vl_quickshift_process(VlQS * q)
{
  vl_qs_type const *I = q->image;
  int        *parents = q->parents;
  vl_qs_type *E = q->density;
  vl_qs_type *dists = q->dists;
  vl_qs_type *M = 0, *n = 0 ;
  vl_qs_type sigma = q->sigma ;
  vl_qs_type tau = q->tau;
  vl_qs_type tau2 = tau*tau;

  int K = q->channels, d;
  int N1 = q->height, N2 = q->width;
  int i1,i2, j1,j2, R, tR;

  d = 2 + K ; /* Total dimensions include spatial component (x,y) */

  if (q->medoid) { /* n and M are only used in mediod shift */
    M = (vl_qs_type *) vl_calloc(N1*N2*d, sizeof(vl_qs_type)) ;
    n = (vl_qs_type *) vl_calloc(N1*N2,   sizeof(vl_qs_type)) ;
  }

  R = (int) ceil (3 * sigma) ;
  tR = (int) ceil (tau) ;

  /* -----------------------------------------------------------------
   *                                                                 n
   * -------------------------------------------------------------- */

  /* If we are doing medoid shift, initialize n to the inner product of the
   * image with itself
   */
  if (n) {
    for (i2 = 0 ; i2 < N2 ; ++ i2) {
      for (i1 = 0 ; i1 < N1 ; ++ i1) {
        n [i1 + N1 * i2] = vl_quickshift_inner(I,N1,N2,K,
                                               i1,i2,
                                               i1,i2) ;
      }
    }
  }

  /* -----------------------------------------------------------------
   *                                                 E = - [oN'*F]', M
   * -------------------------------------------------------------- */

  /*
     D_ij = d(x_i,x_j)
     E_ij = exp(- .5 * D_ij / sigma^2) ;
     F_ij = - E_ij
     E_i  = sum_j E_ij
     M_di = sum_j X_j F_ij

     E is the parzen window estimate of the density
     0 = dissimilar to everything, windowsize = identical
  */

  for (i2 = 0 ; i2 < N2 ; ++ i2) {
    for (i1 = 0 ; i1 < N1 ; ++ i1) {

      int j1min = VL_MAX(i1 - R, 0   ) ;
      int j1max = VL_MIN(i1 + R, N1-1) ;
      int j2min = VL_MAX(i2 - R, 0   ) ;
      int j2max = VL_MIN(i2 + R, N2-1) ;

      /* For each pixel in the window compute the distance between it and the
       * source pixel */
      for (j2 = j2min ; j2 <= j2max ; ++ j2) {
        for (j1 = j1min ; j1 <= j1max ; ++ j1) {
          vl_qs_type Dij = vl_quickshift_distance(I,N1,N2,K, i1,i2, j1,j2) ;
          /* Make distance a similarity */
          vl_qs_type Fij = - exp(- Dij / (2*sigma*sigma)) ;

          /* E is E_i above */
          E [i1 + N1 * i2] -= Fij ;

          if (M) {
            /* Accumulate votes for the median */
            int k ;
            M [i1 + N1*i2 + (N1*N2) * 0] += j1 * Fij ;
            M [i1 + N1*i2 + (N1*N2) * 1] += j2 * Fij ;
            for (k = 0 ; k < K ; ++k) {
              M [i1 + N1*i2 + (N1*N2) * (k+2)] +=
                I [j1 + N1*j2 + (N1*N2) * k] * Fij ;
            }
          }

        } /* j1 */
      } /* j2 */

    }  /* i1 */
  } /* i2 */

  /* -----------------------------------------------------------------
   *                                               Find best neighbors
   * -------------------------------------------------------------- */

  if (q->medoid) {

    /*
       Qij = - nj Ei - 2 sum_k Gjk Mik
       n is I.^2
    */

    /* medoid shift */
    for (i2 = 0 ; i2 < N2 ; ++i2) {
      for (i1 = 0 ; i1 < N1 ; ++i1) {

        vl_qs_type sc_best = 0  ;
        /* j1/j2 best are the best indicies for each i */
        vl_qs_type j1_best = i1 ;
        vl_qs_type j2_best = i2 ;

        int j1min = VL_MAX(i1 - R, 0   ) ;
        int j1max = VL_MIN(i1 + R, N1-1) ;
        int j2min = VL_MAX(i2 - R, 0   ) ;
        int j2max = VL_MIN(i2 + R, N2-1) ;

        for (j2 = j2min ; j2 <= j2max ; ++ j2) {
          for (j1 = j1min ; j1 <= j1max ; ++ j1) {

            vl_qs_type Qij = - n [j1 + j2 * N1] * E [i1 + i2 * N1] ;
            int k ;

            Qij -= 2 * j1 * M [i1 + i2 * N1 + (N1*N2) * 0] ;
            Qij -= 2 * j2 * M [i1 + i2 * N1 + (N1*N2) * 1] ;
            for (k = 0 ; k < K ; ++k) {
              Qij -= 2 *
                I [j1 + j2 * N1 + (N1*N2) * k] *
                M [i1 + i2 * N1 + (N1*N2) * (k + 2)] ;
            }

            if (Qij > sc_best) {
              sc_best = Qij ;
              j1_best = j1 ;
              j2_best = j2 ;
            }
          }
        }

        /* parents_i is the linear index of j which is the best pair
         * dists_i is the score of the best match
         */
        parents [i1 + N1 * i2] = j1_best + N1 * j2_best ;
        dists[i1 + N1 * i2] = sc_best ;
      }
    }

  } else {

    /* Quickshift assigns each i to the closest j which has an increase in the
     * density (E). If there is no j s.t. Ej > Ei, then dists_i == inf (a root
     * node in one of the trees of merges).
     */
    for (i2 = 0 ; i2 < N2 ; ++i2) {
      for (i1 = 0 ; i1 < N1 ; ++i1) {

        vl_qs_type E0 = E [i1 + N1 * i2] ;
        vl_qs_type d_best = VL_QS_INF ;
        vl_qs_type j1_best = i1   ;
        vl_qs_type j2_best = i2   ;

        int j1min = VL_MAX(i1 - tR, 0   ) ;
        int j1max = VL_MIN(i1 + tR, N1-1) ;
        int j2min = VL_MAX(i2 - tR, 0   ) ;
        int j2max = VL_MIN(i2 + tR, N2-1) ;

        for (j2 = j2min ; j2 <= j2max ; ++ j2) {
          for (j1 = j1min ; j1 <= j1max ; ++ j1) {
            if (E [j1 + N1 * j2] > E0) {
              vl_qs_type Dij = vl_quickshift_distance(I,N1,N2,K, i1,i2, j1,j2) ;
              if (Dij <= tau2 && Dij < d_best) {
                d_best = Dij ;
                j1_best = j1 ;
                j2_best = j2 ;
              }
            }
          }
        }

        /* parents is the index of the best pair */
        /* dists_i is the minimal distance, inf implies no Ej > Ei within
         * distance tau from the point */
        parents [i1 + N1 * i2] = j1_best + N1 * j2_best ;
        dists[i1 + N1 * i2] = sqrt(d_best) ;
      }
    }
  }

  if (M) vl_free(M) ;
  if (n) vl_free(n) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdi, %r12
movq (%rdi), %rax
movq %rax, 0xb0(%rsp)
movq 0x28(%rdi), %rax
movq %rax, 0x120(%rsp)
movq 0x38(%rdi), %rax
movq %rax, 0xc8(%rsp)
movq 0x30(%rdi), %rax
movq %rax, 0x118(%rsp)
movsd 0x18(%rdi), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rdi), %xmm0
movaps %xmm0, 0xf0(%rsp)
movl 0x10(%rdi), %eax
movl 0x8(%rdi), %ebx
movl 0xc(%rdi), %r14d
cmpl $0x0, 0x14(%rdi)
movq %rax, 0xc0(%rsp)
movq %rbx, 0x18(%rsp)
je 0x2898a
addl $0x2, %eax
movl %r14d, %ebx
imull 0x18(%rsp), %ebx
imull %ebx, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x98f0
movq %rax, 0x88(%rsp)
movslq %ebx, %rdi
movq 0x18(%rsp), %rbx
movl $0x8, %esi
callq 0x98f0
movq %rax, %r15
jmp 0x28999
xorl %r15d, %r15d
movq $0x0, 0x88(%rsp)
movsd 0x987f(%rip), %xmm0     # 0x32220
mulsd 0x10(%rsp), %xmm0
callq 0x99c0
movsd %xmm0, 0x50(%rsp)
movapd 0xf0(%rsp), %xmm0
callq 0x99c0
testq %r15, %r15
setne %al
movq %r14, 0x38(%rsp)
testl %r14d, %r14d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x28a72
movq 0x38(%rsp), %rax
imull %ebx, %eax
cltq
leaq (,%rbx,8), %rcx
shlq $0x3, %rax
xorl %edx, %edx
movq 0xb0(%rsp), %rsi
testl %ebx, %ebx
jle 0x28a65
movq %rdx, %rdi
imulq %rdx, %rdi
movq %rdx, %r8
imulq %rbx, %r8
movq %rsi, %r9
xorl %r10d, %r10d
movl %r10d, %r11d
imull %r10d, %r11d
addl %edi, %r11d
xorps %xmm1, %xmm1
cvtsi2sd %r11d, %xmm1
movq 0xc0(%rsp), %rbx
testl %ebx, %ebx
jle 0x28a4a
movq %r9, %r11
movsd (%r11), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm1
addq %rax, %r11
decq %rbx
jne 0x28a35
leaq (%r10,%r8), %r11
movsd %xmm1, (%r15,%r11,8)
incq %r10
addq $0x8, %r9
movq 0x18(%rsp), %rbx
cmpq %rbx, %r10
jne 0x28a14
incq %rdx
addq %rcx, %rsi
cmpq 0x38(%rsp), %rdx
jne 0x289fc
movq %r15, 0x128(%rsp)
movq 0x38(%rsp), %rax
testl %eax, %eax
movq 0xc0(%rsp), %rdx
jle 0x2953e
movq %r12, 0x130(%rsp)
cvttsd2si 0x50(%rsp), %esi
movapd 0xf0(%rsp), %xmm1
mulsd %xmm1, %xmm1
movapd %xmm1, 0xf0(%rsp)
cvttsd2si %xmm0, %ecx
movq %rcx, 0xd0(%rsp)
leal -0x1(%rbx), %ecx
movl %ecx, 0xe4(%rsp)
leal -0x1(%rax), %ecx
movl %ecx, 0xdc(%rsp)
movl %eax, %ecx
imull %ebx, %ecx
movslq %ecx, %r15
movsd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
movq %rsi, 0x90(%rsp)
negl %esi
leaq (,%rbx,8), %rax
movq %rax, 0x20(%rsp)
shlq $0x3, %r15
movq %rcx, %rax
shlq $0x4, %rax
addq 0x88(%rsp), %rax
movq %rax, 0x108(%rsp)
movq %rcx, 0x138(%rsp)
leaq (,%rcx,8), %rax
movq %rax, 0xb8(%rsp)
movq $0x0, 0x100(%rsp)
movq $0x0, 0x60(%rsp)
movl %esi, 0xd8(%rsp)
movl %esi, %edi
testl %edi, %edi
movl $0x0, %eax
movl %edi, 0xe0(%rsp)
cmovgl %edi, %eax
movq %rax, 0x110(%rsp)
testl %ebx, %ebx
jle 0x28e75
movq 0x20(%rsp), %rdi
imulq 0x110(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl %esi, %r8d
movq 0x90(%rsp), %rax
subl %eax, %r8d
testl %r8d, %r8d
movl $0x0, %ecx
cmovlel %ecx, %r8d
movl %r8d, 0xec(%rsp)
leal (%rsi,%rax), %ecx
movl 0xdc(%rsp), %eax
cmpl %eax, %ecx
cmovgel %eax, %ecx
imulq %rbx, %rsi
movq %rsi, 0x148(%rsp)
movl %ecx, 0xe8(%rsp)
movslq %ecx, %rax
movq %rax, 0x40(%rsp)
movq 0xb0(%rsp), %rax
movq %rdi, 0x150(%rsp)
addq %rdi, %rax
movq %rax, 0x140(%rsp)
movq 0x108(%rsp), %r12
movq 0x100(%rsp), %rbp
movq $0x0, 0x8(%rsp)
movl 0xd8(%rsp), %esi
testl %esi, %esi
movl $0x0, %eax
movl %esi, 0x5c(%rsp)
cmovgl %esi, %eax
movq %rax, 0x68(%rsp)
movl 0xe8(%rsp), %eax
cmpl %eax, 0xec(%rsp)
jg 0x28e4c
movq 0x140(%rsp), %rax
movq 0x68(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, 0x70(%rsp)
movq 0x150(%rsp), %rax
leaq (%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
movq 0x90(%rsp), %rax
movq 0x8(%rsp), %rsi
leal (%rsi,%rax), %edi
movl 0xe4(%rsp), %ecx
cmpl %ecx, %edi
cmovgel %ecx, %edi
movl %esi, %ecx
subl %eax, %ecx
testl %ecx, %ecx
movl $0x0, %eax
cmovlel %eax, %ecx
movl %ecx, 0x98(%rsp)
movq 0x148(%rsp), %rax
leaq (%rsi,%rax), %rcx
movq 0x138(%rsp), %rax
movq %rcx, 0x10(%rsp)
addq %rcx, %rax
movq %rax, 0xa0(%rsp)
movl %edi, 0x48(%rsp)
movslq %edi, %rax
movq %rax, 0x80(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x98(%rsp), %eax
cmpl 0x48(%rsp), %eax
jg 0x28e24
movq 0x30(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0xa8(%rsp)
subl 0x60(%rsp), %eax
imull %eax, %eax
movl %eax, 0x50(%rsp)
movq 0x70(%rsp), %r13
movq 0x28(%rsp), %r14
movq 0x68(%rsp), %rbx
movl %ebx, %eax
subl 0x8(%rsp), %eax
imull %eax, %eax
addl 0x50(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
testl %edx, %edx
jle 0x28d53
movq 0xb0(%rsp), %rax
movq %rdx, %rcx
movsd (%rax,%rbp), %xmm1
subsd (%rax,%r14), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
addq %r15, %rax
decq %rcx
jne 0x28d38
xorpd 0x9375(%rip), %xmm0     # 0x320d0
divsd 0x78(%rsp), %xmm0
callq 0x9a60
movq 0xc8(%rsp), %rax
movq 0x10(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rcx,8)
movq 0x88(%rsp), %rax
testq %rax, %rax
movq 0xc0(%rsp), %rdx
movq 0xb8(%rsp), %rsi
je 0x28e07
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
xorpd 0x9323(%rip), %xmm0     # 0x320d0
mulsd %xmm0, %xmm1
movq 0x10(%rsp), %rcx
addsd (%rax,%rcx,8), %xmm1
movsd %xmm1, (%rax,%rcx,8)
movsd 0xa8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movq 0xa0(%rsp), %rcx
addsd (%rax,%rcx,8), %xmm1
movsd %xmm1, (%rax,%rcx,8)
testl %edx, %edx
jle 0x28e07
movq %rdx, %rax
xorl %ecx, %ecx
movsd (%r13,%rcx), %xmm1
mulsd %xmm0, %xmm1
addsd (%r12,%rcx), %xmm1
movsd %xmm1, (%r12,%rcx)
addq %rsi, %rcx
decq %rax
jne 0x28de8
leaq 0x1(%rbx), %rax
addq $0x8, %r14
addq $0x8, %r13
cmpq 0x80(%rsp), %rbx
movq %rax, %rbx
jl 0x28d15
movq 0x30(%rsp), %rsi
leaq 0x1(%rsi), %rax
movq 0x20(%rsp), %rcx
addq %rcx, 0x28(%rsp)
addq %rcx, 0x70(%rsp)
cmpq 0x40(%rsp), %rsi
movq %rax, 0x30(%rsp)
jl 0x28cd5
movq 0x8(%rsp), %rcx
incq %rcx
movl 0x5c(%rsp), %esi
incl %esi
addq $0x8, %rbp
addq $0x8, %r12
movq 0x18(%rsp), %rbx
movq %rcx, 0x8(%rsp)
cmpq %rbx, %rcx
jne 0x28c16
movq 0x60(%rsp), %rsi
incq %rsi
movl 0xe0(%rsp), %edi
incl %edi
movq 0x20(%rsp), %rax
addq %rax, 0x100(%rsp)
addq %rax, 0x108(%rsp)
movq 0x38(%rsp), %rax
movq %rsi, 0x60(%rsp)
cmpq %rax, %rsi
jne 0x28b5b
movq 0x130(%rsp), %rcx
cmpl $0x0, 0x14(%rcx)
je 0x29214
testl %eax, %eax
jle 0x2953e
leal -0x1(%rbx), %ecx
movl %ecx, 0xf0(%rsp)
leal -0x1(%rax), %ecx
movl %ecx, 0x40(%rsp)
movl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
imull %ebx, %ecx
movq 0x90(%rsp), %rax
negl %eax
movq %rcx, %rdx
shlq $0x4, %rdx
addq 0x88(%rsp), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, 0x70(%rsp)
leaq (,%rcx,8), %r8
movapd 0x91b8(%rip), %xmm1     # 0x320d0
movsd 0x92c8(%rip), %xmm2     # 0x321e8
movq $0x0, 0x48(%rsp)
movl %eax, 0x68(%rsp)
movl %eax, %edx
testl %edx, %edx
movl $0x0, %eax
movl %edx, 0x98(%rsp)
cmovgl %edx, %eax
movq %rax, 0x78(%rsp)
testl %ebx, %ebx
jle 0x291df
movq 0x20(%rsp), %rsi
imulq 0x78(%rsp), %rsi
movq 0x48(%rsp), %rdx
cvtsi2sd %edx, %xmm3
movl %edx, %r9d
movq 0x90(%rsp), %rax
subl %eax, %r9d
testl %r9d, %r9d
movl $0x0, %ecx
cmovlel %ecx, %r9d
leal (%rdx,%rax), %r10d
movl 0x40(%rsp), %eax
cmpl %eax, %r10d
cmovgel %eax, %r10d
imulq %rbx, %rdx
movslq %r10d, %rdi
addq 0xb0(%rsp), %rsi
movq %rsi, 0xb8(%rsp)
movq 0x28(%rsp), %r11
xorl %esi, %esi
movl 0x68(%rsp), %ebp
movl %r9d, 0xa8(%rsp)
movl %r10d, 0xa0(%rsp)
movq %rdx, 0x30(%rsp)
testl %ebp, %ebp
movl $0x0, %r14d
cmovgl %ebp, %r14d
xorps %xmm4, %xmm4
cvtsi2sd %esi, %xmm4
cmpl %r10d, %r9d
jle 0x28feb
leaq (%rsi,%rdx), %r13
xorpd %xmm5, %xmm5
movapd %xmm3, %xmm10
jmp 0x291a4
movl %ebp, 0x80(%rsp)
movq 0x90(%rsp), %rax
leal (%rsi,%rax), %ebp
movl 0xf0(%rsp), %ecx
cmpl %ecx, %ebp
cmovgel %ecx, %ebp
movq 0xb8(%rsp), %rcx
movq %r14, 0x10(%rsp)
leaq (%rcx,%r14,8), %rcx
movl %esi, %ebx
subl %eax, %ebx
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
movq %rsi, 0x8(%rsp)
leaq (%rsi,%rdx), %r13
movq 0x70(%rsp), %rax
addq %r13, %rax
movq %rax, 0x50(%rsp)
movslq %ebp, %rax
xorpd %xmm5, %xmm5
movq 0x78(%rsp), %rsi
movapd %xmm3, %xmm10
cmpl %ebp, %ebx
jg 0x29169
movq %rsi, %r10
imulq 0x18(%rsp), %r10
movq 0xc8(%rsp), %r9
movsd (%r9,%r13,8), %xmm6
movq 0x88(%rsp), %rdx
movsd (%rdx,%r13,8), %xmm7
leal (%rsi,%rsi), %r9d
xorps %xmm8, %xmm8
cvtsi2sd %r9d, %xmm8
xorpd %xmm1, %xmm8
xorps %xmm9, %xmm9
cvtsi2sd %esi, %xmm9
movq 0x50(%rsp), %r9
mulsd (%rdx,%r9,8), %xmm8
movq %rcx, %r15
movq 0x10(%rsp), %r12
movapd %xmm5, %xmm11
movapd %xmm10, %xmm12
leaq (%r12,%r10), %r9
leal (%r12,%r12), %r14d
movq 0x128(%rsp), %rdx
movsd (%rdx,%r9,8), %xmm10
mulsd %xmm6, %xmm10
xorps %xmm5, %xmm5
cvtsi2sd %r14d, %xmm5
xorpd %xmm1, %xmm5
mulsd %xmm7, %xmm5
subsd %xmm10, %xmm5
addsd %xmm8, %xmm5
movq 0xc0(%rsp), %r9
testl %r9d, %r9d
jle 0x29117
xorl %r14d, %r14d
movsd (%r15,%r14), %xmm10
mulsd %xmm2, %xmm10
mulsd (%r11,%r14), %xmm10
addsd %xmm10, %xmm5
addq %r8, %r14
decq %r9
jne 0x290f9
ucomisd %xmm11, %xmm5
jbe 0x29126
xorps %xmm4, %xmm4
cvtsi2sd %r12d, %xmm4
movapd %xmm11, %xmm10
cmpltsd %xmm5, %xmm10
movapd %xmm10, %xmm13
andpd %xmm9, %xmm13
andnpd %xmm12, %xmm10
orpd %xmm13, %xmm10
maxsd %xmm11, %xmm5
leaq 0x1(%r12), %r9
addq $0x8, %r15
movapd %xmm5, %xmm11
movapd %xmm10, %xmm12
cmpq %rax, %r12
movq %r9, %r12
jl 0x290b4
leaq 0x1(%rsi), %r9
addq 0x20(%rsp), %rcx
cmpq %rdi, %rsi
movq %r9, %rsi
jl 0x2904f
movq 0x18(%rsp), %rbx
movl 0xa8(%rsp), %r9d
movl 0xa0(%rsp), %r10d
movq 0x30(%rsp), %rdx
movq 0x8(%rsp), %rsi
movl 0x80(%rsp), %ebp
mulsd %xmm0, %xmm10
addsd %xmm4, %xmm10
cvttsd2si %xmm10, %eax
movq 0x120(%rsp), %rcx
movl %eax, (%rcx,%r13,4)
movq 0x118(%rsp), %rax
movsd %xmm5, (%rax,%r13,8)
incq %rsi
incl %ebp
addq $0x8, %r11
cmpq %rbx, %rsi
jne 0x28fc1
movq 0x48(%rsp), %rcx
incq %rcx
movl 0x98(%rsp), %edx
incl %edx
movq 0x28(%rsp), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %rcx, 0x48(%rsp)
cmpq 0x38(%rsp), %rcx
jne 0x28f2f
jmp 0x2953e
testl %eax, %eax
jle 0x2953e
decl %eax
movl %eax, 0x60(%rsp)
movq 0x38(%rsp), %rax
imull %ebx, %eax
leal -0x1(%rbx), %ecx
movl %ecx, 0x48(%rsp)
movslq %eax, %r15
cvtsi2sd %ebx, %xmm8
movq 0xd0(%rsp), %rax
negl %eax
shlq $0x3, %r15
movsd 0x99b8(%rip), %xmm9     # 0x32c08
xorpd %xmm10, %xmm10
movq $0x0, 0x40(%rsp)
movq $0x0, 0x8(%rsp)
movl %eax, 0x5c(%rsp)
movsd %xmm8, 0x98(%rsp)
testl %eax, %eax
movl $0x0, %ecx
movl %eax, 0x68(%rsp)
cmovgl %eax, %ecx
movq %rcx, 0x30(%rsp)
testl %ebx, %ebx
jle 0x2950a
movq 0x20(%rsp), %rax
imulq 0x30(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x8(%rsp), %rdx
movq %rdx, %rax
imulq 0x18(%rsp), %rax
movq %rax, 0xb8(%rsp)
xorps %xmm11, %xmm11
cvtsi2sd %edx, %xmm11
movl %edx, %esi
movq 0xd0(%rsp), %rax
subl %eax, %esi
testl %esi, %esi
movl $0x0, %ecx
cmovlel %ecx, %esi
movl %esi, 0xa8(%rsp)
leal (%rdx,%rax), %ecx
movl 0x60(%rsp), %eax
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, 0xa0(%rsp)
movslq %ecx, %rax
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rbx
xorl %r8d, %r8d
movl 0x5c(%rsp), %ecx
movsd %xmm11, 0x28(%rsp)
testl %ecx, %ecx
movl $0x0, %eax
movl %ecx, 0x80(%rsp)
cmovgl %ecx, %eax
movq 0xb8(%rsp), %rcx
leaq (%r8,%rcx), %rsi
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
movl 0xa0(%rsp), %ecx
cmpl %ecx, 0xa8(%rsp)
movq %r8, 0x10(%rsp)
movq %rsi, 0x78(%rsp)
jle 0x29358
movapd %xmm9, %xmm0
movapd %xmm11, %xmm3
jmp 0x2948d
movq 0x70(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movq 0xc8(%rsp), %rdx
movsd (%rdx,%rsi,8), %xmm2
movq 0xd0(%rsp), %rdi
leal (%r8,%rdi), %edx
movl 0x48(%rsp), %esi
cmpl %esi, %edx
cmovgel %esi, %edx
movl %r8d, %esi
subl %edi, %esi
testl %esi, %esi
movl $0x0, %edi
cmovlel %edi, %esi
movslq %edx, %rdi
movq 0x30(%rsp), %r8
movapd %xmm11, %xmm3
movapd %xmm9, %xmm0
cmpl %edx, %esi
jg 0x29476
movq %r8, %r9
imulq 0x18(%rsp), %r9
xorps %xmm4, %xmm4
cvtsi2sd %r8d, %xmm4
movl %r8d, %r10d
subl 0x8(%rsp), %r10d
imull %r10d, %r10d
movq %rcx, %r11
movq %rax, %r14
leaq (%r14,%r9), %r12
movq 0xc8(%rsp), %r13
movsd (%r13,%r12,8), %xmm5
ucomisd %xmm2, %xmm5
jbe 0x29462
movl %r14d, %ebp
subl 0x10(%rsp), %ebp
imull %ebp, %ebp
addl %r10d, %ebp
xorps %xmm5, %xmm5
cvtsi2sd %ebp, %xmm5
movq 0xc0(%rsp), %r13
testl %r13d, %r13d
jle 0x2942d
movq 0xb0(%rsp), %r12
movsd (%r12,%rbx), %xmm6
subsd (%r12,%r11), %xmm6
mulsd %xmm6, %xmm6
addsd %xmm6, %xmm5
addq %r15, %r12
decq %r13
jne 0x29411
movapd %xmm5, %xmm6
cmpltpd %xmm0, %xmm6
movapd %xmm5, %xmm7
cmplepd 0xf0(%rsp), %xmm7
andpd %xmm6, %xmm7
movd %xmm7, %ebp
testb $0x1, %bpl
je 0x29462
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
movapd %xmm4, %xmm3
movapd %xmm5, %xmm0
leaq 0x1(%r14), %r12
addq $0x8, %r11
cmpq %rdi, %r14
movq %r12, %r14
jl 0x293cf
leaq 0x1(%r8), %r9
addq 0x20(%rsp), %rcx
cmpq 0x50(%rsp), %r8
movq %r9, %r8
jl 0x293a4
mulsd %xmm8, %xmm3
addsd %xmm1, %xmm3
cvttsd2si %xmm3, %eax
movq 0x120(%rsp), %rcx
movq 0x78(%rsp), %r14
movl %eax, (%rcx,%r14,4)
ucomisd %xmm10, %xmm0
jb 0x294b8
sqrtsd %xmm0, %xmm0
jmp 0x294dc
callq 0x9990
movsd 0x28(%rsp), %xmm11
xorpd %xmm10, %xmm10
movsd 0x9736(%rip), %xmm9     # 0x32c08
movsd 0x98(%rsp), %xmm8
movq 0x10(%rsp), %r8
movl 0x80(%rsp), %ecx
movq 0x118(%rsp), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r8
incl %ecx
addq $0x8, %rbx
cmpq 0x18(%rsp), %r8
jne 0x2930a
movq 0x8(%rsp), %rcx
incq %rcx
movl 0x68(%rsp), %edx
incl %edx
movq 0x40(%rsp), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
movq %rcx, 0x8(%rsp)
movl %edx, %eax
cmpq 0x38(%rsp), %rcx
movq 0x18(%rsp), %rbx
jne 0x29275
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x29550
callq 0x9580
movq 0x128(%rsp), %rdi
addq $0x158, %rsp            # imm = 0x158
testq %rdi, %rdi
je 0x29573
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9580
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq