// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/hog.c
// Function: vl_hog_put_image
void
vl_hog_put_image (VlHog * self,
                  float const * image,
                  vl_size width, vl_size height, vl_size numChannels,
                  vl_size cellSize)
{
  vl_size hogStride ;
  vl_size channelStride = width * height ;
  vl_index x, y ;
  vl_uindex k ;

  assert(self) ;
  assert(image) ;

  /* clear features */
  vl_hog_prepare_buffers(self, width, height, cellSize) ;
  hogStride = self->hogWidth * self->hogHeight ;

#define at(x,y,k) (self->hog[(x) + (y) * self->hogWidth + (k) * hogStride])

  /* compute gradients and map the to HOG cells by bilinear interpolation */
  for (y = 1 ; y < (signed)height - 1 ; ++y) {
    for (x = 1 ; x < (signed)width - 1 ; ++x) {
      float gradx = 0 ;
      float grady = 0 ;
      float gradNorm ;
      float orientationWeights [2] = {-1, -1} ;
      vl_index orientationBins [2] = {-1, -1} ;
      vl_index orientation = 0 ;
      float hx, hy, wx1, wx2, wy1, wy2 ;
      vl_index binx, biny, o ;

      /*
       Compute the gradient at (x,y). The image channel with
       the maximum gradient at each location is selected.
       */
      {
        float const * iter = image + y * width + x ;
        float gradNorm2 = 0 ;
        for (k = 0 ; k < numChannels ; ++k) {
          float gradx_ = *(iter + 1) - *(iter - 1) ;
          float grady_ = *(iter + width)  - *(iter - width) ;
          float gradNorm2_ = gradx_ * gradx_ + grady_ * grady_ ;
          if (gradNorm2_ > gradNorm2) {
            gradx = gradx_ ;
            grady = grady_ ;
            gradNorm2 = gradNorm2_ ;
          }
          iter += channelStride ;
        }
        gradNorm = sqrtf(gradNorm2) ;
      }

      /*
       Map the gradient to the closest and second closets orientation bins.
       There are numOrientations orientation in the interval [0,pi).
       The next numOriantations are the symmetric ones, for a total
       of 2*numOrientation directed orientations.
       */
      for (k = 0 ; k < self->numOrientations ; ++k) {
        float orientationScore_ = gradx * self->orientationX[k] +  grady * self->orientationY[k] ;
        vl_index orientationBin_ = k ;
        if (orientationScore_ < 0) {
          orientationScore_ = - orientationScore_ ;
          orientationBin_ += self->numOrientations ;
        }
        if (orientationScore_ > orientationWeights[0]) {
          orientationBins[1] = orientationBins[0] ;
          orientationWeights[1] = orientationWeights[0] ;
          orientationBins[0] = orientationBin_ ; ;
          orientationWeights[0] = orientationScore_ ;
        } else if (orientationScore_ > orientationWeights[1]) {
          orientationBins[1] = orientationBin_ ;
          orientationWeights[1] = orientationScore_ ;
        }
      }

      if (self->useBilinearOrientationAssigment) {
        /* min(1.0,...) guards against small overflows causing NaNs */
        float angle0 = acosf(VL_MIN(orientationWeights[0] / VL_MAX(gradNorm, 1e-10),1.0)) ;
        orientationWeights[1] = angle0 / (VL_PI / self->numOrientations) ;
        orientationWeights[0] = 1 - orientationWeights[1] ;
      } else {
        orientationWeights[0] = 1 ;
        orientationBins[1] = -1 ;
      }

      for (o = 0 ; o < 2 ; ++o) {
        float ow ;
        /*
         Accumulate the gradient. hx is the distance of the
         pixel x to the cell center at its left, in units of cellSize.
         With this parametrixation, a pixel on the cell center
         has hx = 0, which gradually increases to 1 moving to the next
         center.
         */

        orientation = orientationBins[o] ;
        if (orientation < 0) continue ;

        /*  (x - (w-1)/2) / w = (x + 0.5)/w - 0.5 */
        hx = (x + 0.5) / cellSize - 0.5 ;
        hy = (y + 0.5) / cellSize - 0.5 ;
        binx = vl_floor_f(hx) ;
        biny = vl_floor_f(hy) ;
        wx2 = hx - binx ;
        wy2 = hy - biny ;
        wx1 = 1.0 - wx2 ;
        wy1 = 1.0 - wy2 ;

        ow = orientationWeights[o] ;

        /*VL_PRINTF("%d %d - %d %d %f %f - %f %f %f %f - %d \n ",x,y,binx,biny,hx,hy,wx1,wx2,wy1,wy2,o);*/

        if (binx >= 0 && biny >=0) {
          at(binx,biny,orientation) += gradNorm * ow * wx1 * wy1 ;
        }
        if (binx < (signed)self->hogWidth - 1 && biny >=0) {
          at(binx+1,biny,orientation) += gradNorm * ow * wx2 * wy1 ;
        }
        if (binx < (signed)self->hogWidth - 1 && biny < (signed)self->hogHeight - 1) {
          at(binx+1,biny+1,orientation) += gradNorm * ow * wx2 * wy2 ;
        }
        if (binx >= 0 && biny < (signed)self->hogHeight - 1) {
          at(binx,biny+1,orientation) += gradNorm * ow * wx1 * wy2 ;
        }
      } /* next o */
    } /* next x */
  } /* next y */
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movq %rdx, 0x100(%rsp)
movq %rcx, 0xf8(%rsp)
movq %r8, 0xf0(%rsp)
movq %r9, 0xe8(%rsp)
movq 0x100(%rsp), %rax
imulq 0xf8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x110(%rsp), %rdi
movq 0x100(%rsp), %rsi
movq 0xf8(%rsp), %rdx
movq 0xe8(%rsp), %rcx
callq 0x20000
movq 0x110(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x110(%rsp), %rcx
imulq 0x60(%rcx), %rax
movq %rax, 0xe0(%rsp)
movq $0x1, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
movq 0xf8(%rsp), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x1ffec
movq $0x1, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq 0x100(%rsp), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x1ffd1
xorps %xmm0, %xmm0
movss %xmm0, 0xbc(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0xb8(%rsp)
movq 0x3a0a5(%rip), %rax     # 0x59810
movq %rax, 0xac(%rsp)
movq 0x3a0a6(%rip), %rax     # 0x59820
movq %rax, 0x90(%rsp)
movq 0x3a09f(%rip), %rax     # 0x59828
movq %rax, 0x98(%rsp)
movq $0x0, 0x88(%rsp)
movq 0x108(%rsp), %rax
movq 0xc8(%rsp), %rcx
imulq 0x100(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq 0xd0(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x4c(%rsp)
movq $0x0, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0xf0(%rsp), %rax
jae 0x1f8ce
movq 0x50(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x50(%rsp), %rax
subss -0x4(%rax), %xmm0
movss %xmm0, 0x48(%rsp)
movq 0x50(%rsp), %rax
movq 0x100(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0x50(%rsp), %rax
xorl %ecx, %ecx
subq 0x100(%rsp), %rcx
subss (%rax,%rcx,4), %xmm0
movss %xmm0, 0x44(%rsp)
movss 0x48(%rsp), %xmm0
movss 0x48(%rsp), %xmm2
movss 0x44(%rsp), %xmm1
mulss 0x44(%rsp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x40(%rsp)
movss 0x40(%rsp), %xmm0
ucomiss 0x4c(%rsp), %xmm0
jbe 0x1f89f
movss 0x48(%rsp), %xmm0
movss %xmm0, 0xbc(%rsp)
movss 0x44(%rsp), %xmm0
movss %xmm0, 0xb8(%rsp)
movss 0x40(%rsp), %xmm0
movss %xmm0, 0x4c(%rsp)
movq 0xd8(%rsp), %rax
shlq $0x2, %rax
addq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xc0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc0(%rsp)
jmp 0x1f7e6
movss 0x4c(%rsp), %xmm0
callq 0x96a0
movss %xmm0, 0xb4(%rsp)
movq $0x0, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movq 0x110(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x1fa39
movss 0xbc(%rsp), %xmm0
movq 0x110(%rsp), %rax
movq 0x38(%rax), %rax
movq 0xc0(%rsp), %rcx
movss (%rax,%rcx,4), %xmm2
movss 0xb8(%rsp), %xmm1
movq 0x110(%rsp), %rax
movq 0x40(%rax), %rax
movq 0xc0(%rsp), %rcx
mulss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x3c(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
ucomiss 0x3c(%rsp), %xmm0
jbe 0x1f9a0
movss 0x3c(%rsp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, 0x3c(%rsp)
movq 0x110(%rsp), %rax
movq 0x10(%rax), %rax
addq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
movss 0x3c(%rsp), %xmm0
ucomiss 0xac(%rsp), %xmm0
jbe 0x1f9f0
movq 0x90(%rsp), %rax
movq %rax, 0x98(%rsp)
movss 0xac(%rsp), %xmm0
movss %xmm0, 0xb0(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x90(%rsp)
movss 0x3c(%rsp), %xmm0
movss %xmm0, 0xac(%rsp)
jmp 0x1fa1e
movss 0x3c(%rsp), %xmm0
ucomiss 0xb0(%rsp), %xmm0
jbe 0x1fa1c
movq 0x30(%rsp), %rax
movq %rax, 0x98(%rsp)
movss 0x3c(%rsp), %xmm0
movss %xmm0, 0xb0(%rsp)
jmp 0x1fa1e
jmp 0x1fa20
movq 0xc0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc0(%rsp)
jmp 0x1f8ee
movq 0x110(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x1fbbb
movss 0xac(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movss 0xb4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x39d8d(%rip), %xmm1    # 0x59800
ucomisd %xmm1, %xmm0
jbe 0x1fa8e
movss 0xb4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0x1fa9e
movsd 0x39d6a(%rip), %xmm0    # 0x59800
movsd %xmm0, 0x18(%rsp)
jmp 0x1fa9e
movsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
divsd %xmm0, %xmm1
movsd 0x39622(%rip), %xmm0    # 0x590d8
ucomisd %xmm1, %xmm0
jbe 0x1fb26
movss 0xac(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movss 0xb4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x39d1c(%rip), %xmm1    # 0x59800
ucomisd %xmm1, %xmm0
jbe 0x1faff
movss 0xb4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x1fb0f
movsd 0x39cf9(%rip), %xmm0    # 0x59800
movsd %xmm0, 0x8(%rsp)
jmp 0x1fb0f
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
jmp 0x1fb35
movsd 0x395aa(%rip), %xmm0    # 0x590d8
movsd %xmm0, (%rsp)
jmp 0x1fb35
movsd (%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x95c0
movss %xmm0, 0x2c(%rsp)
movss 0x2c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x110(%rsp), %rax
movq 0x10(%rax), %xmm2
movaps 0x395f9(%rip), %xmm1    # 0x59160
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
movapd 0x395fd(%rip), %xmm1    # 0x59170
subpd %xmm1, %xmm2
movaps %xmm2, %xmm1
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm1, %xmm2
movsd 0x39c66(%rip), %xmm1    # 0x597f0
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xb0(%rsp)
movss 0x395e9(%rip), %xmm0    # 0x59190
subss 0xb0(%rsp), %xmm0
movss %xmm0, 0xac(%rsp)
jmp 0x1fbd8
movss 0x395cd(%rip), %xmm0    # 0x59190
movss %xmm0, 0xac(%rsp)
movq $-0x1, 0x98(%rsp)
movq $0x0, 0x58(%rsp)
cmpq $0x2, 0x58(%rsp)
jge 0x1ffb6
movq 0x58(%rsp), %rax
movq 0x90(%rsp,%rax,8), %rax
movq %rax, 0x88(%rsp)
cmpq $0x0, 0x88(%rsp)
jge 0x1fc12
jmp 0x1ffa3
cvtsi2sdq 0xd0(%rsp), %xmm0
movsd 0x3945c(%rip), %xmm1    # 0x59080
addsd %xmm1, %xmm0
movq 0xe8(%rsp), %xmm4
movaps 0x39528(%rip), %xmm3    # 0x59160
punpckldq %xmm3, %xmm4    # xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1]
movapd 0x3952c(%rip), %xmm2    # 0x59170
subpd %xmm2, %xmm4
movaps %xmm4, %xmm5
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
addsd %xmm5, %xmm4
divsd %xmm4, %xmm0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x84(%rsp)
cvtsi2sdq 0xc8(%rsp), %xmm0
addsd %xmm1, %xmm0
movq 0xe8(%rsp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0x393e2(%rip), %xmm1    # 0x59080
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x80(%rsp)
movss 0x84(%rsp), %xmm0
callq 0x20190
movq %rax, 0x68(%rsp)
movss 0x80(%rsp), %xmm0
callq 0x20190
movq %rax, 0x60(%rsp)
movss 0x84(%rsp), %xmm0
cvtsi2ssq 0x68(%rsp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x78(%rsp)
movss 0x80(%rsp), %xmm0
cvtsi2ssq 0x60(%rsp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x70(%rsp)
movss 0x78(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x393bd(%rip), %xmm0    # 0x590d8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x7c(%rsp)
movss 0x70(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3939d(%rip), %xmm0    # 0x590d8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x74(%rsp)
movq 0x58(%rsp), %rax
movss 0xac(%rsp,%rax,4), %xmm0
movss %xmm0, 0x28(%rsp)
cmpq $0x0, 0x68(%rsp)
jl 0x1fdd4
cmpq $0x0, 0x60(%rsp)
jl 0x1fdd4
movss 0xb4(%rsp), %xmm0
mulss 0x28(%rsp), %xmm0
mulss 0x7c(%rsp), %xmm0
movss 0x74(%rsp), %xmm2
movq 0x110(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x68(%rsp), %rcx
movq 0x60(%rsp), %rdx
movq 0x110(%rsp), %rsi
imulq 0x58(%rsi), %rdx
addq %rdx, %rcx
movq 0x88(%rsp), %rdx
imulq 0xe0(%rsp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq 0x68(%rsp), %rax
movq 0x110(%rsp), %rcx
movq 0x58(%rcx), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x1fe63
cmpq $0x0, 0x60(%rsp)
jl 0x1fe63
movss 0xb4(%rsp), %xmm0
mulss 0x28(%rsp), %xmm0
mulss 0x78(%rsp), %xmm0
movss 0x74(%rsp), %xmm2
movq 0x110(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x68(%rsp), %rcx
addq $0x1, %rcx
movq 0x60(%rsp), %rdx
movq 0x110(%rsp), %rsi
imulq 0x58(%rsi), %rdx
addq %rdx, %rcx
movq 0x88(%rsp), %rdx
imulq 0xe0(%rsp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq 0x68(%rsp), %rax
movq 0x110(%rsp), %rcx
movq 0x58(%rcx), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x1ff0e
movq 0x60(%rsp), %rax
movq 0x110(%rsp), %rcx
movq 0x60(%rcx), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x1ff0e
movss 0xb4(%rsp), %xmm0
mulss 0x28(%rsp), %xmm0
mulss 0x78(%rsp), %xmm0
movss 0x70(%rsp), %xmm2
movq 0x110(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x68(%rsp), %rcx
addq $0x1, %rcx
movq 0x60(%rsp), %rdx
addq $0x1, %rdx
movq 0x110(%rsp), %rsi
imulq 0x58(%rsi), %rdx
addq %rdx, %rcx
movq 0x88(%rsp), %rdx
imulq 0xe0(%rsp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
cmpq $0x0, 0x68(%rsp)
jl 0x1ffa1
movq 0x60(%rsp), %rax
movq 0x110(%rsp), %rcx
movq 0x60(%rcx), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x1ffa1
movss 0xb4(%rsp), %xmm0
mulss 0x28(%rsp), %xmm0
mulss 0x7c(%rsp), %xmm0
movss 0x70(%rsp), %xmm2
movq 0x110(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x68(%rsp), %rcx
movq 0x60(%rsp), %rdx
addq $0x1, %rdx
movq 0x110(%rsp), %rsi
imulq 0x58(%rsi), %rdx
addq %rdx, %rcx
movq 0x88(%rsp), %rdx
imulq 0xe0(%rsp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
jmp 0x1ffa3
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
jmp 0x1fbe1
jmp 0x1ffb8
movq 0xd0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd0(%rsp)
jmp 0x1f72d
jmp 0x1ffd3
movq 0xc8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc8(%rsp)
jmp 0x1f702
addq $0x118, %rsp            # imm = 0x118
retq
nopw %cs:(%rax,%rax)