// File: /workspace/github_c_makefile_star2_O3/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 $0x78, %rsp
decl %r8d
movslq %r8d, %r8
cmpq $0x2, %r8
jl 0xb2ff
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
leaq (%rdx,%rcx,4), %r14
addq $0x4, %r14
movq %rcx, %r9
shlq $0x20, %r9
addq %rax, %r9
movq %r9, %r10
sarq $0x20, %r10
movapd 0x26fc3(%rip), %xmm3    # 0x320d0
xorpd %xmm0, %xmm3
sarq $0x1e, %r9
addq $-0x4, %r9
leaq -0x1(%r10), %r12
shlq $0x2, %rcx
movq %rcx, %rax
negq %rax
movq %rax, 0x48(%rsp)
movl $0x1, %r15d
xorl %edx, %edx
movq $0x0, (%rsp)
cmpq $0x2, %r10
jl 0xb2ed
leaq (%r14,%r9), %r11
leaq (%r14,%rcx), %r13
movq 0x48(%rsp), %rax
leaq (%r14,%rax), %rbp
xorl %ebx, %ebx
movq %rbx, %rax
incq %rbx
movss (%r14,%rax,4), %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jb 0xb1b3
ucomiss 0x4(%r14,%rax,4), %xmm2
jbe 0xb1b3
ucomiss -0x4(%r14,%rax,4), %xmm2
jbe 0xb1b3
ucomiss (%r13,%rax,4), %xmm2
jbe 0xb1b3
ucomiss (%rbp,%rax,4), %xmm2
jbe 0xb1b3
ucomiss 0x4(%r13,%rax,4), %xmm2
jbe 0xb1b3
ucomiss -0x4(%r13,%rax,4), %xmm2
jbe 0xb1b3
ucomiss 0x4(%rbp,%rax,4), %xmm2
jbe 0xb1b3
ucomiss -0x4(%rbp,%rax,4), %xmm2
ja 0xb23a
ucomisd %xmm1, %xmm3
jb 0xb2e1
movss 0x4(%r14,%rax,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb2e1
movss -0x4(%r14,%rax,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb2e1
movss (%r13,%rax,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb2e1
movss (%rbp,%rax,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb2e1
movss 0x4(%r13,%rax,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb2e1
movss -0x4(%r13,%rax,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb2e1
movss 0x4(%rbp,%rax,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb2e1
movss -0x4(%rbp,%rax,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb2e1
movq %r11, 0x40(%rsp)
leaq 0x10(%rdx), %rax
movq %rax, 0x38(%rsp)
cmpq %rax, (%rsi)
jae 0xb2bb
addq $0x7d10, %rdx           # imm = 0x7D10
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rdi
movq %rsi, 0x10(%rsp)
movq 0x10(%rsp), %rsi
movapd %xmm0, 0x60(%rsp)
movq %rcx, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %r9, 0x20(%rsp)
movq %r10, 0x18(%rsp)
movapd %xmm3, 0x50(%rsp)
callq 0xb06e
movapd 0x50(%rsp), %xmm3
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %r9
movq 0x28(%rsp), %r8
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x30(%rsp), %rcx
movapd 0x60(%rsp), %xmm0
testl %eax, %eax
jne 0xb31a
movq (%rsp), %r11
leaq 0x1(%r11), %rax
movq (%rdi), %rdx
shlq $0x4, %r11
movq %rbx, (%rdx,%r11)
movq %r15, 0x8(%rdx,%r11)
movq %rax, (%rsp)
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %r11
cmpq %rbx, %r12
jne 0xb159
movq %r11, %r14
addq $0x8, %r14
incq %r15
cmpq %r8, %r15
jne 0xb13c
jmp 0xb307
movq $0x0, (%rsp)
movq (%rsp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x90b0