// File: /workspace/github_c_makefile_star2_O1/zpole[P]IICV/vl/lbp.c
// Function: vl_lbp_process
VL_EXPORT void
vl_lbp_process (VlLbp * self,
                float * features,
                float * image, vl_size width, vl_size height,
                vl_size cellSize)
{
  vl_size cwidth = width / cellSize;
  vl_size cheight = height / cellSize ;
  vl_size cstride = cwidth * cheight ;
  vl_size cdimension = vl_lbp_get_dimension(self) ;
  vl_index x,y,cx,cy,k,bin ;

#define at(u,v) (*(image + width * (v) + (u)))
#define to(u,v,w) (*(features + cstride * (w) + cwidth * (v) + (u)))

  /* clear the output buffer */
  memset(features, 0, sizeof(float)*cdimension*cstride) ;

  /* accumulate pixel-level measurements into cells */
  for (y = 1 ; y < (signed)height - 1 ; ++y) {
    float wy1 = (y + 0.5f) / (float)cellSize - 0.5f ;
    int cy1 = (int) vl_floor_f(wy1) ;
    int cy2 = cy1 + 1 ;
    float wy2 = wy1 - (float)cy1 ;
    wy1 = 1.0f - wy2 ;
    if (cy1 >= (signed)cheight) continue ;

    for (x = 1 ; x < (signed)width - 1; ++x) {
      float wx1 = (x + 0.5f) / (float)cellSize - 0.5f ;
      int cx1 = (int) vl_floor_f(wx1) ;
      int cx2 = cx1 + 1 ;
      float wx2 = wx1 - (float)cx1 ;
      wx1 = 1.0f - wx2 ;
      if (cx1 >= (signed)cwidth) continue ;

      {
        int unsigned bitString = 0 ;
        float center = at(x,y) ;
        if(at(x+1,y+0) > center) bitString |= 0x1 << 0; /*  E */
        if(at(x+1,y+1) > center) bitString |= 0x1 << 1; /* SE */
        if(at(x+0,y+1) > center) bitString |= 0x1 << 2; /* S  */
        if(at(x-1,y+1) > center) bitString |= 0x1 << 3; /* SW */
        if(at(x-1,y+0) > center) bitString |= 0x1 << 4; /*  W */
        if(at(x-1,y-1) > center) bitString |= 0x1 << 5; /* NW */
        if(at(x+0,y-1) > center) bitString |= 0x1 << 6; /* N  */
        if(at(x+1,y-1) > center) bitString |= 0x1 << 7; /* NE */
        bin = self->mapping[bitString] ;
      }

      if ((cx1 >= 0) & (cy1 >=0)) {
        to(cx1,cy1,bin) += wx1 * wy1;
      }
      if ((cx2 < (signed)cwidth)  & (cy1 >=0)) {
        to(cx2,cy1,bin) += wx2 * wy1 ;
      }
      if ((cx1 >= 0) & (cy2 < (signed)cheight)) {
        to(cx1,cy2,bin) += wx1 * wy2 ;
      }
      if ((cx2 < (signed)cwidth) & (cy2 < (signed)cheight)) {
        to(cx2,cy2,bin) += wx2 * wy2 ;
      }
    } /* x */
  } /* y */

  /* normalize cells */
  for (cy = 0 ; cy < (signed)cheight ; ++cy) {
    for (cx = 0 ; cx < (signed)cwidth ; ++ cx) {
      float norm = 0 ;
      for (k = 0 ; k < (signed)cdimension ; ++k) {
        norm += features[k * cstride] ;
      }
      norm = sqrtf(norm) + 1e-10f; ;
      for (k = 0 ; k < (signed)cdimension ; ++k) {
        features[k * cstride] = sqrtf(features[k * cstride]) / norm  ;
      }
      features += 1 ;
    }
  } /* next cell to normalize */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r15
movq %r8, %r12
movq %rcx, %rax
movq %rdx, 0x20(%rsp)
movq %rsi, %rbx
movq %rcx, 0x8(%rsp)
xorl %edx, %edx
divq %r9
movq %rax, %rbp
movq %r8, %rax
xorl %edx, %edx
divq %r9
movq %rax, %r14
movq %rax, 0x28(%rsp)
imulq %rbp, %r14
movq %rdi, 0x10(%rsp)
movq (%rdi), %rdx
movq %rdx, 0x40(%rsp)
imulq %r14, %rdx
shlq $0x2, %rdx
movq %rsi, %rdi
xorl %esi, %esi
callq 0x9400
decl %r12d
movslq %r12d, %rax
movq %rax, 0x50(%rsp)
cmpq $0x2, %rax
jl 0x23ce3
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
testq %r15, %r15
js 0x239ec
cvtsi2ss %r15, %xmm0
jmp 0x23a02
movq %r15, %rcx
shrq %rcx
andl $0x1, %r15d
orq %rcx, %r15
cvtsi2ss %r15, %xmm0
addss %xmm0, %xmm0
movq 0x8(%rsp), %rcx
movq %rcx, %r10
shlq $0x20, %r10
addq %rax, %r10
sarq $0x20, %r10
addq $0x8, 0x20(%rsp)
leaq (,%rcx,4), %rax
movq %rax, 0x48(%rsp)
movl $0x1, %edx
movss 0xf91b(%rip), %xmm1     # 0x33350
movss 0xf90b(%rip), %xmm2     # 0x33348
movss 0xf907(%rip), %xmm3     # 0x3334c
movq %rdx, 0x30(%rsp)
xorps %xmm4, %xmm4
cvtsi2ss %rdx, %xmm4
addss %xmm1, %xmm4
divss %xmm0, %xmm4
addss %xmm2, %xmm4
cvttss2si %xmm4, %rax
xorps %xmm5, %xmm5
cvtsi2ss %rax, %xmm5
cmpq $0x2, %r10
setl %dl
cmpneqps %xmm4, %xmm5
xorps %xmm6, %xmm6
cmpnleps %xmm4, %xmm6
andps %xmm5, %xmm6
movd %xmm6, %esi
andl $0x1, %esi
subq %rsi, %rax
cmpl 0x28(%rsp), %eax
setge %sil
orb %dl, %sil
jne 0x23cc6
xorps %xmm5, %xmm5
cvtsi2ss %eax, %xmm5
subss %xmm5, %xmm4
movaps %xmm3, %xmm5
subss %xmm4, %xmm5
leal 0x1(%rax), %edx
movl %eax, %edi
notl %edi
shrl $0x1f, %edi
cltq
imulq %rbp, %rax
leaq (%rbx,%rax,4), %rax
movq %rax, 0x18(%rsp)
xorl %r9d, %r9d
cmpl 0x28(%rsp), %edx
setl %r9b
movslq %edx, %rax
imulq %rbp, %rax
leaq (%rbx,%rax,4), %r15
movl $0x1, %r11d
movq 0x20(%rsp), %r12
movq %r15, 0x38(%rsp)
xorps %xmm6, %xmm6
cvtsi2ss %r11, %xmm6
addss %xmm1, %xmm6
divss %xmm0, %xmm6
addss %xmm2, %xmm6
cvttss2si %xmm6, %rax
xorps %xmm7, %xmm7
cvtsi2ss %rax, %xmm7
cmpneqps %xmm6, %xmm7
xorps %xmm8, %xmm8
cmpnleps %xmm6, %xmm8
andps %xmm7, %xmm8
movd %xmm8, %edx
andl $0x1, %edx
subq %rdx, %rax
cmpl %ebp, %eax
jge 0x23cb6
xorps %xmm7, %xmm7
cvtsi2ss %eax, %xmm7
subss %xmm7, %xmm6
movq 0x8(%rsp), %rcx
movss -0x4(%r12,%rcx,4), %xmm8
movss (%r12,%rcx,4), %xmm7
xorl %edx, %edx
ucomiss %xmm8, %xmm7
seta %dl
movaps %xmm3, %xmm7
movss (%r12,%rcx,8), %xmm9
ucomiss %xmm8, %xmm9
leal 0x2(%rdx), %esi
cmovbel %edx, %esi
subss %xmm6, %xmm7
movss -0x4(%r12,%rcx,8), %xmm9
ucomiss %xmm8, %xmm9
leal 0x4(%rsi), %edx
cmovbel %esi, %edx
movss -0x8(%r12,%rcx,4), %xmm9
movss -0x8(%r12,%rcx,8), %xmm10
ucomiss %xmm8, %xmm10
leal 0x8(%rdx), %esi
cmovbel %edx, %esi
movl %esi, %edx
orl $0x10, %edx
ucomiss %xmm8, %xmm9
cmovbel %esi, %edx
movl %edx, %esi
orl $0x20, %esi
movss -0x8(%r12), %xmm9
ucomiss %xmm8, %xmm9
movss -0x4(%r12), %xmm9
cmovbel %edx, %esi
movl %esi, %edx
orl $0x40, %edx
ucomiss %xmm8, %xmm9
cmovbel %esi, %edx
movss (%r12), %xmm9
movl %edx, %esi
orl $0x80, %esi
ucomiss %xmm8, %xmm9
cmovbel %edx, %esi
movq 0x10(%rsp), %rdx
movzbl 0x8(%rdx,%rsi), %edx
movl %eax, %r13d
notl %r13d
shrl $0x1f, %r13d
testl %edi, %r13d
je 0x23c1f
movq %r14, %rsi
imulq %rdx, %rsi
movq 0x18(%rsp), %rcx
leaq (%rcx,%rsi,4), %rsi
movslq %eax, %r8
movaps %xmm7, %xmm8
mulss %xmm5, %xmm8
addss (%rsi,%r8,4), %xmm8
movss %xmm8, (%rsi,%r8,4)
leal 0x1(%rax), %esi
xorl %r8d, %r8d
cmpl %ebp, %esi
setl %r8b
movslq %esi, %rsi
testl %edi, %r8d
je 0x23c77
movl %edi, %r15d
movl %r9d, %edi
movq %r10, %r9
movq %rbp, %r10
movq %r14, %rbp
imulq %rdx, %rbp
movq 0x18(%rsp), %rcx
leaq (%rcx,%rbp,4), %rbp
movaps %xmm6, %xmm8
mulss %xmm5, %xmm8
addss (%rbp,%rsi,4), %xmm8
movss %xmm8, (%rbp,%rsi,4)
movq %r10, %rbp
movq %r9, %r10
movl %edi, %r9d
movl %r15d, %edi
movq 0x38(%rsp), %r15
testl %r9d, %r13d
je 0x23c9b
movq %r14, %r13
imulq %rdx, %r13
leaq (%r15,%r13,4), %r13
cltq
mulss %xmm4, %xmm7
addss (%r13,%rax,4), %xmm7
movss %xmm7, (%r13,%rax,4)
testl %r9d, %r8d
je 0x23cb6
imulq %r14, %rdx
leaq (%r15,%rdx,4), %rax
mulss %xmm4, %xmm6
addss (%rax,%rsi,4), %xmm6
movss %xmm6, (%rax,%rsi,4)
incq %r11
addq $0x4, %r12
cmpq %r11, %r10
jne 0x23aec
movq 0x30(%rsp), %rdx
incq %rdx
movq 0x48(%rsp), %rax
addq %rax, 0x20(%rsp)
cmpq 0x50(%rsp), %rdx
jne 0x23a45
movslq 0x28(%rsp), %rax
movq %rax, 0x30(%rsp)
testq %rax, %rax
jle 0x23dd7
movslq %ebp, %rax
movq %rax, 0x10(%rsp)
movslq 0x40(%rsp), %r15
xorl %eax, %eax
xorps %xmm1, %xmm1
movq %r15, 0x8(%rsp)
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x10(%rsp)
jle 0x23dc4
xorl %ebp, %ebp
xorps %xmm0, %xmm0
testq %r15, %r15
jle 0x23d41
movq %r15, %rax
xorl %ecx, %ecx
movq %rcx, %rdx
imulq %r14, %rdx
addss (%rbx,%rdx,4), %xmm0
incq %rcx
decq %rax
jne 0x23d2d
ucomiss %xmm1, %xmm0
jb 0x23d4f
xorps %xmm2, %xmm2
sqrtss %xmm0, %xmm2
jmp 0x23d5a
callq 0x95e0
xorps %xmm1, %xmm1
movaps %xmm0, %xmm2
addss 0x1046e(%rip), %xmm2    # 0x341d0
testq %r15, %r15
jle 0x23dad
movq 0x8(%rsp), %r12
xorl %r15d, %r15d
movss %xmm2, 0x18(%rsp)
movq %r15, %r13
imulq %r14, %r13
movss (%rbx,%r13,4), %xmm0
ucomiss %xmm1, %xmm0
jb 0x23d8d
sqrtss %xmm0, %xmm0
jmp 0x23d9b
callq 0x95e0
movss 0x18(%rsp), %xmm2
xorps %xmm1, %xmm1
divss %xmm2, %xmm0
movss %xmm0, (%rbx,%r13,4)
incq %r15
decq %r12
jne 0x23d75
addq $0x4, %rbx
incq %rbp
cmpq 0x10(%rsp), %rbp
movq 0x8(%rsp), %r15
jl 0x23d20
movq 0x38(%rsp), %rax
incq %rax
cmpq 0x30(%rsp), %rax
jl 0x23d0d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop