// File: /workspace/github_c_makefile_star2_O2/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, %rbp
movq %r8, %r12
movq %rcx, %rax
movq %rdx, 0x48(%rsp)
movq %rsi, %rbx
movq %rcx, 0x28(%rsp)
xorl %edx, %edx
divq %r9
movq %rax, %r13
movq %r8, %rax
xorl %edx, %edx
divq %r9
movq %rax, %r15
movq %rax, %r14
imulq %r13, %r14
movq %rdi, 0x10(%rsp)
movq (%rdi), %rdx
movq %rdx, 0x30(%rsp)
imulq %r14, %rdx
shlq $0x2, %rdx
movq %rsi, %rdi
xorl %esi, %esi
callq 0x9420
decl %r12d
testq %rbp, %rbp
js 0x1f9dc
cvtsi2ss %rbp, %xmm0
jmp 0x1f9f1
movq %rbp, %rax
shrq %rax
andl $0x1, %ebp
orq %rax, %rbp
cvtsi2ss %rbp, %xmm0
addss %xmm0, %xmm0
movslq %r12d, %rcx
movq 0x28(%rsp), %rax
decl %eax
movslq %eax, %rbp
pushq $0x1
popq %rax
movss 0xd91f(%rip), %xmm1     # 0x2d328
movss 0xd90f(%rip), %xmm2     # 0x2d320
movss 0xd90b(%rip), %xmm3     # 0x2d324
movq %r15, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
cmpq %rcx, %rax
jge 0x1fced
cvtsi2ss %rax, %xmm4
addss %xmm1, %xmm4
divss %xmm0, %xmm4
addss %xmm2, %xmm4
cvttss2si %xmm4, %rdx
cvtsi2ss %rdx, %xmm5
cmpneqps %xmm4, %xmm5
xorps %xmm6, %xmm6
cmpnleps %xmm4, %xmm6
andps %xmm5, %xmm6
movd %xmm6, %esi
andl $0x1, %esi
subq %rsi, %rdx
cmpl %r15d, %edx
jge 0x1fcd1
cvtsi2ss %edx, %xmm5
subss %xmm5, %xmm4
movaps %xmm3, %xmm5
subss %xmm4, %xmm5
leal 0x1(%rdx), %esi
movq %rax, %rdi
movq 0x28(%rsp), %rcx
imulq %rcx, %rdi
movq 0x48(%rsp), %r9
leaq (%r9,%rdi,4), %rdi
movq %rdi, 0x20(%rsp)
leaq 0x1(%rax), %r8
movq %r8, 0x50(%rsp)
imulq %rcx, %r8
leaq (%r9,%r8,4), %rdi
movq %rdi, 0x18(%rsp)
decq %rax
imulq %rcx, %rax
leaq (%r9,%rax,4), %r9
movl %edx, %r10d
notl %r10d
shrl $0x1f, %r10d
movslq %edx, %rax
imulq %r13, %rax
leaq (%rbx,%rax,4), %rax
movq %rax, 0x8(%rsp)
xorl %edi, %edi
cmpl %r15d, %esi
setl %dil
movslq %esi, %rax
imulq %r13, %rax
leaq (%rbx,%rax,4), %rax
movq %rax, (%rsp)
pushq $0x1
popq %rcx
cmpq %rbp, %rcx
jge 0x1fcd9
cvtsi2ss %rcx, %xmm6
addss %xmm1, %xmm6
divss %xmm0, %xmm6
addss %xmm2, %xmm6
cvttss2si %xmm6, %r15
cvtsi2ss %r15, %xmm7
cmpneqps %xmm6, %xmm7
xorps %xmm8, %xmm8
cmpnleps %xmm6, %xmm8
andps %xmm7, %xmm8
movd %xmm8, %eax
andl $0x1, %eax
subq %rax, %r15
cmpl %r13d, %r15d
jge 0x1fcc9
cvtsi2ss %r15d, %xmm7
subss %xmm7, %xmm6
movq 0x20(%rsp), %rdx
movss (%rdx,%rcx,4), %xmm8
movss 0x4(%rdx,%rcx,4), %xmm7
xorl %eax, %eax
ucomiss %xmm8, %xmm7
seta %al
movaps %xmm3, %xmm7
movq 0x18(%rsp), %r8
movss 0x4(%r8,%rcx,4), %xmm9
ucomiss %xmm8, %xmm9
leal 0x2(%rax), %esi
cmovbel %eax, %esi
subss %xmm6, %xmm7
movss (%r8,%rcx,4), %xmm9
ucomiss %xmm8, %xmm9
leal 0x4(%rsi), %eax
cmovbel %esi, %eax
movss -0x4(%rdx,%rcx,4), %xmm9
movss -0x4(%r8,%rcx,4), %xmm10
ucomiss %xmm8, %xmm10
leal 0x8(%rax), %esi
cmovbel %eax, %esi
movl %esi, %eax
orl $0x10, %eax
ucomiss %xmm8, %xmm9
cmovbel %esi, %eax
movl %eax, %esi
orl $0x20, %esi
movss -0x4(%r9,%rcx,4), %xmm9
ucomiss %xmm8, %xmm9
movss (%r9,%rcx,4), %xmm9
cmovbel %eax, %esi
movl %esi, %eax
orl $0x40, %eax
ucomiss %xmm8, %xmm9
cmovbel %esi, %eax
movss 0x4(%r9,%rcx,4), %xmm9
movl %eax, %esi
orl $0x80, %esi
ucomiss %xmm8, %xmm9
cmovbel %eax, %esi
movq 0x10(%rsp), %rax
movzbl 0x8(%rax,%rsi), %esi
movl %r15d, %r11d
notl %r11d
shrl $0x1f, %r11d
testl %r10d, %r11d
je 0x1fc23
movq %r14, %rax
imulq %rsi, %rax
movq 0x8(%rsp), %rdx
leaq (%rdx,%rax,4), %rax
movslq %r15d, %r12
movaps %xmm7, %xmm8
mulss %xmm5, %xmm8
addss (%rax,%r12,4), %xmm8
movss %xmm8, (%rax,%r12,4)
leal 0x1(%r15), %r12d
xorl %eax, %eax
cmpl %r13d, %r12d
setl %al
movslq %r12d, %r12
testl %r10d, %eax
je 0x1fc76
movq %r13, %rdx
movq %rbp, %r13
movq %r14, %rbp
imulq %rsi, %rbp
movl %edi, %r8d
movl %r10d, %edi
movq 0x8(%rsp), %r10
leaq (%r10,%rbp,4), %rbp
movl %edi, %r10d
movl %r8d, %edi
movaps %xmm6, %xmm8
mulss %xmm5, %xmm8
addss (%rbp,%r12,4), %xmm8
movss %xmm8, (%rbp,%r12,4)
movq %r13, %rbp
movq %rdx, %r13
testl %edi, %r11d
je 0x1fc9d
movq %r14, %r11
imulq %rsi, %r11
movq (%rsp), %rdx
leaq (%rdx,%r11,4), %r11
movslq %r15d, %r15
mulss %xmm4, %xmm7
addss (%r11,%r15,4), %xmm7
movss %xmm7, (%r11,%r15,4)
incq %rcx
testl %edi, %eax
je 0x1faea
imulq %r14, %rsi
movq (%rsp), %rax
leaq (%rax,%rsi,4), %rax
mulss %xmm4, %xmm6
addss (%rax,%r12,4), %xmm6
movss %xmm6, (%rax,%r12,4)
jmp 0x1faea
incq %rcx
jmp 0x1faea
incq %rax
jmp 0x1fa23
movq 0x50(%rsp), %rax
movq 0x40(%rsp), %r15
movq 0x38(%rsp), %rcx
jmp 0x1fa23
movslq %r15d, %rax
movq %rax, 0x10(%rsp)
movslq %r13d, %rax
movq %rax, 0x20(%rsp)
movslq 0x30(%rsp), %r12
xorl %eax, %eax
testq %r12, %r12
cmovleq %rax, %r12
xorps %xmm1, %xmm1
cmpq 0x10(%rsp), %rax
jge 0x1fdd3
xorl %esi, %esi
movq %rax, 0x18(%rsp)
cmpq 0x20(%rsp), %rsi
jge 0x1fdcb
xorps %xmm0, %xmm0
movq %r12, %rax
xorl %ecx, %ecx
subq $0x1, %rax
jb 0x1fd4a
movq %rcx, %rdx
imulq %r14, %rdx
addss (%rbx,%rdx,4), %xmm0
incq %rcx
jmp 0x1fd33
ucomiss %xmm1, %xmm0
movq %rsi, (%rsp)
jb 0x1fd59
sqrtss %xmm0, %xmm2
jmp 0x1fd64
callq 0x9610
xorps %xmm1, %xmm1
movaps %xmm0, %xmm2
addss 0xe42c(%rip), %xmm2     # 0x2e198
movq %r12, %rbp
xorl %r13d, %r13d
movss %xmm2, 0x8(%rsp)
subq $0x1, %r12
jb 0x1fdb3
movq %r13, %r15
imulq %r14, %r15
movss (%rbx,%r15,4), %xmm0
ucomiss %xmm1, %xmm0
jb 0x1fd96
sqrtss %xmm0, %xmm0
jmp 0x1fda4
callq 0x9610
movss 0x8(%rsp), %xmm2
xorps %xmm1, %xmm1
divss %xmm2, %xmm0
movss %xmm0, (%rbx,%r15,4)
incq %r13
jmp 0x1fd78
addq $0x4, %rbx
movq (%rsp), %rsi
incq %rsi
movq %rbp, %r12
movq 0x18(%rsp), %rax
jmp 0x1fd20
incq %rax
jmp 0x1fd0e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop