// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/hog.c
// Function: vl_hog_put_polar_field
void vl_hog_put_polar_field (VlHog * self,
                             float const * modulus,
                             float const * angle,
                             vl_bool directed,
                             vl_size width, vl_size height,
                             vl_size cellSize)
{
  vl_size hogStride ;
  vl_index x, y, o ;
  vl_index period = self->numOrientations * (directed ? 2 : 1) ;
  double angleStep = VL_PI / self->numOrientations ;

  assert(self) ;
  assert(modulus) ;
  assert(angle) ;

  /* 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])
#define atNorm(x,y) (self->hogNorm[(x) + (y) * self->hogWidth])

  /* fill HOG cells from gradient field */
  for (y = 0 ; y < (signed)height ; ++y) {
    for (x = 0 ; x < (signed)width ; ++x) {
      float ho, hx, hy, wo1, wo2, wx1, wx2, wy1, wy2 ;
      vl_index bino, binx, biny ;
      float orientationWeights [2] = {0,0} ;
      vl_index orientationBins [2] = {-1,-1} ;
      vl_index orientation = 0 ;
      float thisAngle = *angle++ ;
      float thisModulus = *modulus++ ;

      if (thisModulus <= 0.0f) continue ;

      /*  (x - (w-1)/2) / w = (x + 0.5)/w - 0.5 */

      ho = (float)thisAngle / angleStep ;
      bino = vl_floor_f(ho) ;
      wo2 = ho - bino ;
      wo1 = 1.0f - wo2 ;

      while (bino < 0) { bino += self->numOrientations * 2 ; }

      if (self->useBilinearOrientationAssigment) {
        orientationBins[0] = bino % period ;
        orientationBins[1] = (bino + 1) % period ;
        orientationWeights[0] = wo1 ;
        orientationWeights[1] = wo2 ;
      } else {
        orientationBins[0] = (bino + ((wo1 > wo2) ? 0 : 1)) % period ;
        orientationWeights[0] = 1 ;
        orientationBins[1] = -1 ;
      }

      for (o = 0 ; o < 2 ; ++o) {
        /*
         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 ;

        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 ;

        wx1 *= orientationWeights[o] ;
        wx2 *= orientationWeights[o] ;
        wy1 *= orientationWeights[o] ;
        wy2 *= 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) += thisModulus * wx1 * wy1 ;
        }
        if (binx < (signed)self->hogWidth - 1 && biny >=0) {
          at(binx+1,biny,orientation) += thisModulus * wx2 * wy1 ;
        }
        if (binx < (signed)self->hogWidth - 1 && biny < (signed)self->hogHeight - 1) {
          at(binx+1,biny+1,orientation) += thisModulus * wx2 * wy2 ;
        }
        if (binx >= 0 && biny < (signed)self->hogHeight - 1) {
          at(binx,biny+1,orientation) += thisModulus * wx1 * wy2 ;
        }
      } /* next o */
    } /* next x */
  } /* next y */
}

// Assembly:
subq $0xc8, %rsp
movq 0xd0(%rsp), %rax
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdx, 0xb0(%rsp)
movl %ecx, 0xac(%rsp)
movq %r8, 0xa0(%rsp)
movq %r9, 0x98(%rsp)
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %rax
movl 0xac(%rsp), %ecx
subl $0x1, %ecx
movl $0x1, %ecx
sbbl $-0x1, %ecx
imulq %rcx, %rax
movq %rax, 0x70(%rsp)
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %xmm1
movaps 0x38f07(%rip), %xmm0    # 0x59160
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x38f0b(%rip), %xmm0    # 0x59170
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x39574(%rip), %xmm0    # 0x597f0
divsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0xc0(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0xd0(%rsp), %rcx
callq 0x20000
movq 0xc0(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xc0(%rsp), %rcx
imulq 0x60(%rcx), %rax
movq %rax, 0x90(%rsp)
movq $0x0, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq 0x98(%rsp), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x208af
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq 0xa0(%rsp), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x20894
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x9480
movq 0x394ec(%rip), %rax     # 0x59820
movq %rax, 0x10(%rsp)
movq 0x394e8(%rip), %rax     # 0x59828
movq %rax, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0xb0(%rsp)
movss (%rax), %xmm0
movss %xmm0, 0x4(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0xb8(%rsp)
movss (%rax), %xmm0
movss %xmm0, (%rsp)
xorps %xmm0, %xmm0
ucomiss (%rsp), %xmm0
jb 0x2039d
jmp 0x2087b
movss 0x4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
divsd 0x68(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x64(%rsp)
movss 0x64(%rsp), %xmm0
callq 0x20190
movq %rax, 0x38(%rsp)
movss 0x64(%rsp), %xmm0
cvtsi2ssq 0x38(%rsp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x54(%rsp)
movss 0x38daa(%rip), %xmm0    # 0x59190
subss 0x54(%rsp), %xmm0
movss %xmm0, 0x58(%rsp)
cmpq $0x0, 0x38(%rsp)
jge 0x20415
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %rax
shlq %rax
addq 0x38(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x203f2
movq 0xc0(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x20463
movq 0x38(%rsp), %rax
cqto
idivq 0x70(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x38(%rsp), %rax
addq $0x1, %rax
cqto
idivq 0x70(%rsp)
movq %rdx, 0x18(%rsp)
movss 0x58(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x54(%rsp), %xmm0
movss %xmm0, 0x24(%rsp)
jmp 0x204aa
movq 0x38(%rsp), %rax
movss 0x58(%rsp), %xmm0
movss 0x54(%rsp), %xmm1
movl $0x1, %ecx
xorl %edx, %edx
ucomiss %xmm1, %xmm0
cmoval %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
cqto
idivq 0x70(%rsp)
movq %rdx, 0x10(%rsp)
movss 0x38cf5(%rip), %xmm0    # 0x59190
movss %xmm0, 0x20(%rsp)
movq $-0x1, 0x18(%rsp)
movq $0x0, 0x78(%rsp)
cmpq $0x2, 0x78(%rsp)
jge 0x20879
movq 0x78(%rsp), %rax
movq 0x10(%rsp,%rax,8), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jge 0x204db
jmp 0x20866
cvtsi2sdq 0x88(%rsp), %xmm0
movsd 0x38b93(%rip), %xmm1    # 0x59080
addsd %xmm1, %xmm0
movq 0xd0(%rsp), %xmm4
movaps 0x38c5f(%rip), %xmm3    # 0x59160
punpckldq %xmm3, %xmm4    # xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1]
movapd 0x38c63(%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, 0x60(%rsp)
cvtsi2sdq 0x80(%rsp), %xmm0
addsd %xmm1, %xmm0
movq 0xd0(%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 0x38b1c(%rip), %xmm1    # 0x59080
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x5c(%rsp)
movss 0x60(%rsp), %xmm0
callq 0x20190
movq %rax, 0x30(%rsp)
movss 0x5c(%rsp), %xmm0
callq 0x20190
movq %rax, 0x28(%rsp)
movss 0x60(%rsp), %xmm0
cvtsi2ssq 0x30(%rsp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x4c(%rsp)
movss 0x5c(%rsp), %xmm0
cvtsi2ssq 0x28(%rsp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x44(%rsp)
movss 0x4c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x38b06(%rip), %xmm0    # 0x590d8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x50(%rsp)
movss 0x44(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x38ae6(%rip), %xmm0    # 0x590d8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x48(%rsp)
movq 0x78(%rsp), %rax
movss 0x20(%rsp,%rax,4), %xmm0
mulss 0x50(%rsp), %xmm0
movss %xmm0, 0x50(%rsp)
movq 0x78(%rsp), %rax
movss 0x20(%rsp,%rax,4), %xmm0
mulss 0x4c(%rsp), %xmm0
movss %xmm0, 0x4c(%rsp)
movq 0x78(%rsp), %rax
movss 0x20(%rsp,%rax,4), %xmm0
mulss 0x48(%rsp), %xmm0
movss %xmm0, 0x48(%rsp)
movq 0x78(%rsp), %rax
movss 0x20(%rsp,%rax,4), %xmm0
mulss 0x44(%rsp), %xmm0
movss %xmm0, 0x44(%rsp)
cmpq $0x0, 0x30(%rsp)
jl 0x206c6
cmpq $0x0, 0x28(%rsp)
jl 0x206c6
movss (%rsp), %xmm0
mulss 0x50(%rsp), %xmm0
movss 0x48(%rsp), %xmm2
movq 0xc0(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq 0xc0(%rsp), %rsi
imulq 0x58(%rsi), %rdx
addq %rdx, %rcx
movq 0x8(%rsp), %rdx
imulq 0x90(%rsp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq 0x30(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq 0x58(%rcx), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x20748
cmpq $0x0, 0x28(%rsp)
jl 0x20748
movss (%rsp), %xmm0
mulss 0x4c(%rsp), %xmm0
movss 0x48(%rsp), %xmm2
movq 0xc0(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x30(%rsp), %rcx
addq $0x1, %rcx
movq 0x28(%rsp), %rdx
movq 0xc0(%rsp), %rsi
imulq 0x58(%rsi), %rdx
addq %rdx, %rcx
movq 0x8(%rsp), %rdx
imulq 0x90(%rsp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq 0x30(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq 0x58(%rcx), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x207e2
movq 0x28(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq 0x60(%rcx), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x207e2
movss (%rsp), %xmm0
mulss 0x4c(%rsp), %xmm0
movss 0x44(%rsp), %xmm2
movq 0xc0(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x30(%rsp), %rcx
addq $0x1, %rcx
movq 0x28(%rsp), %rdx
addq $0x1, %rdx
movq 0xc0(%rsp), %rsi
imulq 0x58(%rsi), %rdx
addq %rdx, %rcx
movq 0x8(%rsp), %rdx
imulq 0x90(%rsp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
cmpq $0x0, 0x30(%rsp)
jl 0x20864
movq 0x28(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq 0x60(%rcx), %rcx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x20864
movss (%rsp), %xmm0
mulss 0x50(%rsp), %xmm0
movss 0x44(%rsp), %xmm2
movq 0xc0(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rdx
addq $0x1, %rdx
movq 0xc0(%rsp), %rsi
imulq 0x58(%rsi), %rdx
addq %rdx, %rcx
movq 0x8(%rsp), %rdx
imulq 0x90(%rsp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
jmp 0x20866
movq 0x78(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x78(%rsp)
jmp 0x204b3
jmp 0x2087b
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x20300
jmp 0x20896
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0x202d8
addq $0xc8, %rsp
retq
nopw (%rax,%rax)