// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %r8, %rax
xorl %edx, %edx
divq %r9
movq %rax, %r13
movq %rax, %r14
imulq %r15, %r14
movq %rdi, 0x18(%rsp)
movq (%rdi), %rdx
movq %rdx, 0x30(%rsp)
imulq %r14, %rdx
shlq $0x2, %rdx
movq %rsi, %rdi
xorl %esi, %esi
callq 0x9400
decl %r12d
movslq %r12d, %r8
cmpq $0x2, %r8
jl 0x23db9
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
testq %rbp, %rbp
js 0x23a7b
cvtsi2ss %rbp, %xmm0
jmp 0x23a90
movq %rbp, %rcx
shrq %rcx
andl $0x1, %ebp
orq %rcx, %rbp
cvtsi2ss %rbp, %xmm0
addss %xmm0, %xmm0
movq 0x28(%rsp), %rbp
shlq $0x20, %rbp
addq %rax, %rbp
sarq $0x20, %rbp
movl $0x1, %eax
movss 0xe8b3(%rip), %xmm1     # 0x32360
movss 0xe8a3(%rip), %xmm2     # 0x32358
movss 0xe89f(%rip), %xmm3     # 0x3235c
movq %r13, 0x40(%rsp)
movq %r8, 0x38(%rsp)
xorps %xmm4, %xmm4
cvtsi2ss %rax, %xmm4
addss %xmm1, %xmm4
divss %xmm0, %xmm4
addss %xmm2, %xmm4
cvttss2si %xmm4, %rdx
cmpq $0x2, %rbp
xorps %xmm5, %xmm5
cvtsi2ss %rdx, %xmm5
setl %sil
cmpneqps %xmm4, %xmm5
xorps %xmm6, %xmm6
cmpnleps %xmm4, %xmm6
andps %xmm5, %xmm6
movd %xmm6, %edi
andl $0x1, %edi
subq %rdi, %rdx
cmpl %r13d, %edx
setge %dil
orb %sil, %dil
cmpb $0x1, %dil
jne 0x23b23
incq %rax
movq %rax, %rcx
jmp 0x23db0
xorps %xmm5, %xmm5
cvtsi2ss %edx, %xmm5
subss %xmm5, %xmm4
movaps %xmm3, %xmm5
subss %xmm4, %xmm5
leal 0x1(%rdx), %r10d
movq %rax, %rsi
movq 0x28(%rsp), %rcx
imulq %rcx, %rsi
movq 0x48(%rsp), %r8
leaq (%r8,%rsi,4), %rsi
movq %rsi, 0x8(%rsp)
leaq 0x1(%rax), %rdi
movq %rdi, 0x50(%rsp)
imulq %rcx, %rdi
leaq (%r8,%rdi,4), %rsi
movq %rsi, 0x20(%rsp)
decq %rax
imulq %rcx, %rax
leaq (%r8,%rax,4), %r8
movl %edx, %r9d
notl %r9d
shrl $0x1f, %r9d
movslq %edx, %rax
imulq %r15, %rax
leaq (%rbx,%rax,4), %rax
movq %rax, 0x10(%rsp)
xorl %edi, %edi
cmpl %r13d, %r10d
setl %dil
movslq %r10d, %rax
imulq %r15, %rax
leaq (%rbx,%rax,4), %rax
movq %rax, (%rsp)
movl $0x1, %eax
xorps %xmm6, %xmm6
cvtsi2ss %rax, %xmm6
addss %xmm1, %xmm6
divss %xmm0, %xmm6
addss %xmm2, %xmm6
cvttss2si %xmm6, %rcx
xorps %xmm7, %xmm7
cvtsi2ss %rcx, %xmm7
cmpneqps %xmm6, %xmm7
xorps %xmm8, %xmm8
cmpnleps %xmm6, %xmm8
andps %xmm7, %xmm8
movd %xmm8, %edx
andl $0x1, %edx
subq %rdx, %rcx
cmpl %r15d, %ecx
jge 0x23d92
xorps %xmm7, %xmm7
cvtsi2ss %ecx, %xmm7
subss %xmm7, %xmm6
movq 0x8(%rsp), %rsi
movss (%rsi,%rax,4), %xmm8
movss 0x4(%rsi,%rax,4), %xmm7
xorl %edx, %edx
ucomiss %xmm8, %xmm7
seta %dl
movaps %xmm3, %xmm7
movq 0x20(%rsp), %r11
movss 0x4(%r11,%rax,4), %xmm9
ucomiss %xmm8, %xmm9
leal 0x2(%rdx), %r10d
cmovbel %edx, %r10d
subss %xmm6, %xmm7
movss (%r11,%rax,4), %xmm9
ucomiss %xmm8, %xmm9
leal 0x4(%r10), %edx
cmovbel %r10d, %edx
movss -0x4(%rsi,%rax,4), %xmm9
movss -0x4(%r11,%rax,4), %xmm10
ucomiss %xmm8, %xmm10
leal 0x8(%rdx), %r10d
cmovbel %edx, %r10d
movl %r10d, %edx
orl $0x10, %edx
ucomiss %xmm8, %xmm9
cmovbel %r10d, %edx
movl %edx, %r10d
orl $0x20, %r10d
movss -0x4(%r8,%rax,4), %xmm9
ucomiss %xmm8, %xmm9
movss (%r8,%rax,4), %xmm9
cmovbel %edx, %r10d
movl %r10d, %edx
orl $0x40, %edx
ucomiss %xmm8, %xmm9
cmovbel %r10d, %edx
movss 0x4(%r8,%rax,4), %xmm9
movl %edx, %r10d
orl $0x80, %r10d
ucomiss %xmm8, %xmm9
cmovbel %edx, %r10d
movq 0x18(%rsp), %rdx
movzbl 0x8(%rdx,%r10), %edx
movl %ecx, %r13d
notl %r13d
shrl $0x1f, %r13d
testl %r9d, %r13d
je 0x23cf4
movq %r14, %r10
imulq %rdx, %r10
movq 0x10(%rsp), %r11
leaq (%r11,%r10,4), %r10
movslq %ecx, %r12
movaps %xmm7, %xmm8
mulss %xmm5, %xmm8
addss (%r10,%r12,4), %xmm8
movss %xmm8, (%r10,%r12,4)
leal 0x1(%rcx), %r10d
xorl %r12d, %r12d
cmpl %r15d, %r10d
setl %r12b
movslq %r10d, %r10
testl %r9d, %r12d
je 0x23d43
movq %r15, %r11
movq %rbp, %r15
movq %r14, %rbp
imulq %rdx, %rbp
movl %r9d, %esi
movq 0x10(%rsp), %r9
leaq (%r9,%rbp,4), %rbp
movl %esi, %r9d
movaps %xmm6, %xmm8
mulss %xmm5, %xmm8
addss (%rbp,%r10,4), %xmm8
movss %xmm8, (%rbp,%r10,4)
movq %r15, %rbp
movq %r11, %r15
testl %edi, %r13d
je 0x23d6c
movq %r14, %r13
imulq %rdx, %r13
movq (%rsp), %rsi
leaq (%rsi,%r13,4), %r13
movslq %ecx, %rcx
mulss %xmm4, %xmm7
addss (%r13,%rcx,4), %xmm7
movss %xmm7, (%r13,%rcx,4)
incq %rax
testl %edi, %r12d
je 0x23d95
imulq %r14, %rdx
movq (%rsp), %rcx
leaq (%rcx,%rdx,4), %rcx
mulss %xmm4, %xmm6
addss (%rcx,%r10,4), %xmm6
movss %xmm6, (%rcx,%r10,4)
jmp 0x23d95
incq %rax
cmpq %rbp, %rax
jne 0x23bab
movq 0x50(%rsp), %rcx
movq %rcx, %rax
movq 0x40(%rsp), %r13
movq 0x38(%rsp), %r8
cmpq %r8, %rcx
jne 0x23ac7
movslq %r13d, %rax
movq %rax, 0x18(%rsp)
testq %rax, %rax
jle 0x23ead
movslq %r15d, %rax
movq %rax, 0x8(%rsp)
movslq 0x30(%rsp), %rax
movq %rax, (%rsp)
xorl %eax, %eax
xorps %xmm1, %xmm1
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x8(%rsp)
jle 0x23e9a
xorl %ebp, %ebp
cmpq $0x0, (%rsp)
jle 0x23e88
xorps %xmm0, %xmm0
movq (%rsp), %rax
xorl %ecx, %ecx
movq %rcx, %rdx
imulq %r14, %rdx
addss (%rbx,%rdx,4), %xmm0
incq %rcx
decq %rax
jne 0x23e07
ucomiss %xmm1, %xmm0
jb 0x23e29
xorps %xmm2, %xmm2
sqrtss %xmm0, %xmm2
jmp 0x23e34
callq 0x95e0
xorps %xmm1, %xmm1
movaps %xmm0, %xmm2
addss 0xf384(%rip), %xmm2     # 0x331c0
cmpq $0x0, (%rsp)
jle 0x23e88
movq (%rsp), %r12
xorl %r15d, %r15d
movss %xmm2, 0x10(%rsp)
movq %r15, %r13
imulq %r14, %r13
movss (%rbx,%r13,4), %xmm0
ucomiss %xmm1, %xmm0
jb 0x23e68
sqrtss %xmm0, %xmm0
jmp 0x23e76
callq 0x95e0
movss 0x10(%rsp), %xmm2
xorps %xmm1, %xmm1
divss %xmm2, %xmm0
movss %xmm0, (%rbx,%r13,4)
incq %r15
decq %r12
jne 0x23e50
addq $0x4, %rbx
incq %rbp
cmpq 0x8(%rsp), %rbp
jl 0x23df3
movq 0x20(%rsp), %rax
incq %rax
cmpq 0x18(%rsp), %rax
jl 0x23de0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq