// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/liop.c
// Function: vl_liopdesc_process
void
vl_liopdesc_process (VlLiopDesc * self, float * desc, float const * patch)
{
  vl_index i,t ;
  vl_index offset,numPermutations ;
  vl_index spatialBinArea, spatialBinEnd, spatialBinIndex ;
  float threshold ;

  memset(desc, 0, sizeof(float) * self->dimension) ;

  /*
   * Sort pixels in the patch by increasing intensity.
   */

  for (i = 0 ; i < (signed)self->patchSize ; ++i) {
    vl_index pixel = self->patchPixels[i] ;
    self->patchIntensities[i] = patch[pixel] ;
    self->patchPermutation[i] = i ;
  }
  patch_sort(self, self->patchSize) ;

  /*
   * Tune the threshold if needed.
   */

  if (self->intensityThreshold < 0) {
    i = self->patchPermutation[0] ;
    t = self->patchPermutation[self->patchSize-1] ;
    threshold = - self->intensityThreshold
    * (self->patchIntensities[t] - self->patchIntensities[i]);
  } else {
    threshold = self->intensityThreshold ;
  }

  /*
   * Process pixels in order of increasing intenisity, dividing them into
   * spatial bins on the fly.
   */

  numPermutations = factorial(self->numNeighbours) ;
  spatialBinArea = self->patchSize / self->numSpatialBins ;
  spatialBinEnd = spatialBinArea ;
  spatialBinIndex = 0 ;
  offset = 0 ;

  for (i = 0 ; i < (signed)self->patchSize ; ++i) {
    vl_index permIndex ;
    double *sx, *sy ;

    /* advance to the next spatial bin if needed */
    if (i >= (signed)spatialBinEnd && spatialBinIndex < (signed)self->numSpatialBins - 1) {
      spatialBinEnd += spatialBinArea ;
      spatialBinIndex ++ ;
      offset += numPermutations ;
    }

    /* get intensities of neighbours of the current patch element and sort them */
    sx = self->neighSamplesX + self->numNeighbours * self->patchPermutation[i] ;
    sy = self->neighSamplesY + self->numNeighbours * self->patchPermutation[i] ;
    for (t = 0 ; t < self->numNeighbours ; ++t) {
      double x = *sx++ ;
      double y = *sy++ ;

      /* bilinear interpolation */
      vl_index ix = vl_floor_d(x) ;
      vl_index iy = vl_floor_d(y) ;

      double wx = x - ix ;
      double wy = y - iy ;

      double a = 0, b = 0, c = 0, d = 0 ;

      int L = (int) self->patchSideLength ;

      if (ix >= 0   && iy >= 0  ) { a = patch[ix   + iy * L] ; }
      if (ix <  L-1 && iy >= 0  ) { b = patch[ix+1 + iy * L] ; }
      if (ix >= 0   && iy <  L-1) { c = patch[ix   + (iy+1) * L] ; }
      if (ix <  L-1 && iy <  L-1) { d = patch[ix+1 + (iy+1) * L] ; }

      self->neighPermutation[t] = t;
      self->neighIntensities[t] = (1 - wy) * (a + (b - a) * wx) + wy * (c + (d - c) * wx) ;
    }
    neigh_sort (self, self->numNeighbours) ;

    /* get permutation index */
    permIndex = get_permutation_index(self->neighPermutation, self->numNeighbours);

    /*
     * Compute weight according to difference in intensity values and
     * accumulate.
     */
    {
      int k, t ;
      float weight = 0 ;
      for(k = 0; k < self->numNeighbours ; ++k) {
        for(t = k + 1; t < self->numNeighbours; ++t){
          double a = self->neighIntensities[k] ;
          double b = self->neighIntensities[t] ;
          weight += (a > b + threshold || b > a + threshold) ;
        }
      }
      desc[permIndex + offset] += weight ;
    }
  }

  /* normalization */
  {
    float norm = 0;
    for(i = 0; i < (signed)self->dimension; i++) {
      norm += desc[i]*desc[i];
    }
    norm = VL_MAX(sqrt(norm), 1e-12) ;
    for(i = 0; i < (signed)self->dimension; i++){
      desc[i] /= norm ;
    }
  }
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
movq %rdx, 0xe0(%rsp)
movq 0xe8(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x10(%rax), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x9480
movq $0x0, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq 0x20(%rcx), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x38af1
movq 0xf0(%rsp), %rax
movq 0x28(%rax), %rax
movq 0xd8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x98(%rsp)
movq 0xe0(%rsp), %rax
movq 0x98(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0xf0(%rsp), %rax
movq 0x30(%rax), %rax
movq 0xd8(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq 0xd8(%rsp), %rdx
movq 0xf0(%rsp), %rax
movq 0x38(%rax), %rax
movq 0xd8(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0x38a4a
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x39300
movq 0xf0(%rsp), %rax
xorps %xmm0, %xmm0
ucomiss 0x8(%rax), %xmm0
jbe 0x38bb9
movq 0xf0(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movq %rax, 0xd8(%rsp)
movq 0xf0(%rsp), %rax
movq 0x38(%rax), %rax
movq 0xf0(%rsp), %rcx
movq 0x20(%rcx), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0xd0(%rsp)
movq 0xf0(%rsp), %rax
movss 0x8(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq 0xf0(%rsp), %rax
movq 0x30(%rax), %rax
movq 0xd0(%rsp), %rcx
movss (%rax,%rcx,4), %xmm1
movq 0xf0(%rsp), %rax
movq 0x30(%rax), %rax
movq 0xd8(%rsp), %rcx
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movss %xmm0, 0xa4(%rsp)
jmp 0x38bcf
movq 0xf0(%rsp), %rax
movss 0x8(%rax), %xmm0
movss %xmm0, 0xa4(%rsp)
movq 0xf0(%rsp), %rax
movl (%rax), %edi
callq 0x38920
cltq
movq %rax, 0xc0(%rsp)
movq 0xf0(%rsp), %rax
movq 0x20(%rax), %rax
movq 0xf0(%rsp), %rcx
movslq 0x4(%rcx), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq $0x0, 0xa8(%rsp)
movq $0x0, 0xc8(%rsp)
movq $0x0, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq 0x20(%rcx), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x391bc
movq 0xd8(%rsp), %rax
movq 0xb0(%rsp), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jl 0x38cdb
movq 0xa8(%rsp), %rax
movq 0xf0(%rsp), %rcx
movl 0x4(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x38cdb
movq 0xb8(%rsp), %rax
addq 0xb0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
movq 0xc0(%rsp), %rax
addq 0xc8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xf0(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xf0(%rsp), %rcx
movslq (%rcx), %rcx
movq 0xf0(%rsp), %rdx
movq 0x38(%rdx), %rdx
movq 0xd8(%rsp), %rsi
imulq (%rdx,%rsi,8), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x88(%rsp)
movq 0xf0(%rsp), %rax
movq 0x60(%rax), %rax
movq 0xf0(%rsp), %rcx
movslq (%rcx), %rcx
movq 0xf0(%rsp), %rdx
movq 0x38(%rdx), %rdx
movq 0xd8(%rsp), %rsi
imulq (%rdx,%rsi,8), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x80(%rsp)
movq $0x0, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq 0xf0(%rsp), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jge 0x3902f
movq 0x88(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x88(%rsp)
movsd (%rax), %xmm0
movsd %xmm0, 0x78(%rsp)
movq 0x80(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x80(%rsp)
movsd (%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x78(%rsp), %xmm0
callq 0x39330
movq %rax, 0x68(%rsp)
movsd 0x70(%rsp), %xmm0
callq 0x39330
movq %rax, 0x60(%rsp)
movsd 0x78(%rsp), %xmm0
cvtsi2sdq 0x68(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x70(%rsp), %xmm0
cvtsi2sdq 0x60(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0xf0(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x2c(%rsp)
cmpq $0x0, 0x68(%rsp)
jl 0x38e82
cmpq $0x0, 0x60(%rsp)
jl 0x38e82
movq 0xe0(%rsp), %rax
movq 0x68(%rsp), %rcx
movq 0x60(%rsp), %rdx
movslq 0x2c(%rsp), %rsi
imulq %rsi, %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x68(%rsp), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x38ecf
cmpq $0x0, 0x60(%rsp)
jl 0x38ecf
movq 0xe0(%rsp), %rax
movq 0x68(%rsp), %rcx
addq $0x1, %rcx
movq 0x60(%rsp), %rdx
movslq 0x2c(%rsp), %rsi
imulq %rsi, %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
cmpq $0x0, 0x68(%rsp)
jl 0x38f1c
movq 0x60(%rsp), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x38f1c
movq 0xe0(%rsp), %rax
movq 0x68(%rsp), %rcx
movq 0x60(%rsp), %rdx
addq $0x1, %rdx
movslq 0x2c(%rsp), %rsi
imulq %rsi, %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x68(%rsp), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x38f79
movq 0x60(%rsp), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x38f79
movq 0xe0(%rsp), %rax
movq 0x68(%rsp), %rcx
addq $0x1, %rcx
movq 0x60(%rsp), %rdx
addq $0x1, %rdx
movslq 0x2c(%rsp), %rsi
imulq %rsi, %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0xd0(%rsp), %rdx
movq 0xf0(%rsp), %rax
movq 0x50(%rax), %rax
movq 0xd0(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movsd 0x20137(%rip), %xmm0    # 0x590d8
subsd 0x50(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
subsd 0x48(%rsp), %xmm2
movsd 0x58(%rsp), %xmm3
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd 0x50(%rsp), %xmm1
movsd 0x38(%rsp), %xmm4
movsd 0x30(%rsp), %xmm3
subsd 0x38(%rsp), %xmm3
movsd 0x58(%rsp), %xmm5
mulsd %xmm5, %xmm3
addsd %xmm4, %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0xf0(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xd0(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq 0xd0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd0(%rsp)
jmp 0x38d65
movq 0xf0(%rsp), %rdi
movq 0xf0(%rsp), %rax
movslq (%rax), %rsi
callq 0x39390
movq 0xf0(%rsp), %rax
movq 0x50(%rax), %rdi
movq 0xf0(%rsp), %rax
movslq (%rax), %rsi
callq 0x393c0
movq %rax, 0x90(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
movq 0xf0(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x3917b
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0xf0(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x39169
movq 0xf0(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x28(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0xf0(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x24(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movss 0xa4(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
addsd %xmm2, %xmm1
movb $0x1, %al
ucomisd %xmm1, %xmm0
movb %al, 0xb(%rsp)
ja 0x39140
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movss 0xa4(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
seta %al
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cvtsi2ss %eax, %xmm0
addss 0x20(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x3909b
jmp 0x3916b
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x3907c
movss 0x20(%rsp), %xmm0
movq 0xe8(%rsp), %rax
movq 0x90(%rsp), %rcx
addq 0xc8(%rsp), %rcx
addss (%rax,%rcx,4), %xmm0
movss %xmm0, (%rax,%rcx,4)
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0x38c41
xorps %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movq $0x0, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x39241
movq 0xe8(%rsp), %rax
movq 0xd8(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0xe8(%rsp), %rax
movq 0xd8(%rsp), %rcx
movss (%rax,%rcx,4), %xmm2
movss 0xc(%rsp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0x391d1
movss 0xc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x9b20
movsd 0x1ffe8(%rip), %xmm1    # 0x59240
ucomisd %xmm1, %xmm0
jbe 0x39274
movss 0xc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x9b20
movsd %xmm0, (%rsp)
jmp 0x39283
movsd 0x1ffc4(%rip), %xmm0    # 0x59240
movsd %xmm0, (%rsp)
jmp 0x39283
movsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movq $0x0, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x392f4
movss 0xc(%rsp), %xmm1
movq 0xe8(%rsp), %rax
movq 0xd8(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0x3929e
addq $0xf8, %rsp
retq
nopl (%rax)