// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/vl/covdet.c
// Function: vl_find_local_extrema_2
vl_size
vl_find_local_extrema_2 (vl_index ** extrema, vl_size * bufferSize,
                         float const* map,
                         vl_size width, vl_size height,
                         double threshold)
{
  vl_index x, y ;
  vl_size const xo = 1 ;
  vl_size const yo = width ;
  float const *pt = map + xo + yo ;

  vl_size numExtrema = 0 ;
  vl_size requiredSize = 0 ;
#define CHECK_NEIGHBORS_2(v,CMP,SGN)     (\
v CMP ## = SGN threshold &&               \
v CMP *(pt + xo) &&                       \
v CMP *(pt - xo) &&                       \
v CMP *(pt + yo) &&                       \
v CMP *(pt - yo) &&                       \
\
v CMP *(pt + yo + xo) &&                  \
v CMP *(pt + yo - xo) &&                  \
v CMP *(pt - yo + xo) &&                  \
v CMP *(pt - yo - xo) )

  for (y = 1 ; y < (signed)height - 1 ; ++y) {
    for (x = 1 ; x < (signed)width - 1 ; ++x) {
      float value = *pt ;
      if (CHECK_NEIGHBORS_2(value,>,+) || CHECK_NEIGHBORS_2(value,<,-)) {
        numExtrema ++ ;
        requiredSize += sizeof(vl_index) * 2 ;
        if (*bufferSize < requiredSize) {
          int err = _vl_resize_buffer((void**)extrema, bufferSize,
                                      requiredSize + 2000 * 2 * sizeof(vl_index)) ;
          if (err != VL_ERR_OK) abort() ;
        }
        (*extrema) [2 * (numExtrema - 1) + 0] = x ;
        (*extrema) [2 * (numExtrema - 1) + 1] = y ;
      }
      pt += xo ;
    }
    pt += 2*xo ;
  }
  return numExtrema ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbx
leaq (%rdx,%rcx,4), %r13
addq $0x4, %r13
decl %r8d
movslq %r8d, %r8
leal -0x1(%rcx), %eax
movslq %eax, %r14
movapd 0x22426(%rip), %xmm3    # 0x2d0a0
xorpd %xmm0, %xmm3
leaq (,%rcx,4), %r15
negq %r15
pushq $0x1
popq %r9
xorl %r10d, %r10d
xorl %edx, %edx
movq %r9, %r11
movapd %xmm0, 0x40(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq %r8, 0x18(%rsp)
movapd %xmm3, 0x30(%rsp)
cmpq %r8, %r11
jge 0xae24
addq $0x8, %r13
movq %r9, %rbp
cmpq %r14, %rbp
jge 0xae1c
movss -0x8(%r13), %xmm2
cvtss2sd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jb 0xad1b
ucomiss -0x4(%r13), %xmm2
jbe 0xad1b
ucomiss -0xc(%r13), %xmm2
jbe 0xad1b
ucomiss -0x8(%r13,%rbx,4), %xmm2
jbe 0xad1b
ucomiss -0x8(%r13,%r15), %xmm2
jbe 0xad1b
ucomiss -0x4(%r13,%rbx,4), %xmm2
jbe 0xad1b
ucomiss -0xc(%r13,%rbx,4), %xmm2
jbe 0xad1b
ucomiss -0x4(%r13,%r15), %xmm2
jbe 0xad1b
ucomiss -0xc(%r13,%r15), %xmm2
ja 0xad9b
ucomisd %xmm1, %xmm3
jb 0xae0a
movss -0x4(%r13), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xae0a
movss -0xc(%r13), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xae0a
movss -0x8(%r13,%rbx,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xae0a
movss -0x8(%r13,%r15), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xae0a
movss -0x4(%r13,%rbx,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xae0a
movss -0xc(%r13,%rbx,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xae0a
movss -0x4(%r13,%r15), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xae0a
movss -0xc(%r13,%r15), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xae0a
leaq 0x10(%rdx), %r12
cmpq %r12, (%rsi)
jae 0xadf1
addq $0x7d10, %rdx           # imm = 0x7D10
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r10, 0x28(%rsp)
movq %r11, 0x20(%rsp)
callq 0xabf9
movq 0x20(%rsp), %r11
movq 0x28(%rsp), %r10
pushq $0x1
popq %r9
movapd 0x30(%rsp), %xmm3
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movapd 0x40(%rsp), %xmm0
testl %eax, %eax
jne 0xae36
leaq 0x1(%r10), %rax
movq (%rdi), %rcx
shlq $0x4, %r10
movq %rbp, (%rcx,%r10)
movq %r11, 0x8(%rcx,%r10)
movq %rax, %r10
jmp 0xae0d
movq %rdx, %r12
incq %rbp
addq $0x4, %r13
movq %r12, %rdx
jmp 0xacc0
incq %r11
jmp 0xacb0
movq %r10, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x90b0