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

  vl_size numExtrema = 0 ;
  vl_size requiredSize = 0 ;

#define CHECK_NEIGHBORS_3(v,CMP,SGN)     (\
v CMP ## = SGN threshold &&               \
v CMP *(pt + xo) &&                       \
v CMP *(pt - xo) &&                       \
v CMP *(pt + zo) &&                       \
v CMP *(pt - zo) &&                       \
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) &&                  \
\
v CMP *(pt + xo      + zo) &&             \
v CMP *(pt - xo      + zo) &&             \
v CMP *(pt + yo      + zo) &&             \
v CMP *(pt - yo      + zo) &&             \
v CMP *(pt + yo + xo + zo) &&             \
v CMP *(pt + yo - xo + zo) &&             \
v CMP *(pt - yo + xo + zo) &&             \
v CMP *(pt - yo - xo + zo) &&             \
\
v CMP *(pt + xo      - zo) &&             \
v CMP *(pt - xo      - zo) &&             \
v CMP *(pt + yo      - zo) &&             \
v CMP *(pt - yo      - zo) &&             \
v CMP *(pt + yo + xo - zo) &&             \
v CMP *(pt + yo - xo - zo) &&             \
v CMP *(pt - yo + xo - zo) &&             \
v CMP *(pt - yo - xo - zo) )

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r8, %r14
leal -0x1(%r8), %eax
leaq (,%r8,4), %r10
leaq -0x4(,%r8,4), %r11
leaq 0x4(,%r8,4), %r8
imulq %rcx, %r14
leaq (%rdx,%rcx,4), %rdx
leaq (%rdx,%r14,4), %r15
addq $0x4, %r15
decl %r9d
movslq %r9d, %r9
movslq %eax, %rdx
leal -0x1(%rcx), %eax
movslq %eax, %rbp
movapd 0x229e5(%rip), %xmm3    # 0x2d0a0
xorpd %xmm0, %xmm3
leaq (,%rcx,8), %rax
leaq (,%r14,4), %rbx
negq %rbx
movq %rbx, 0x28(%rsp)
leaq (,%rcx,4), %rbx
negq %rbx
imulq %rcx, %r11
movq %r11, 0x8(%rsp)
pushq $0x4
popq %r13
subq %r10, %r13
movq %r10, %r11
movq %rdx, %r10
xorq $-0x4, %r11
imulq %rcx, %r11
movq %r11, 0x18(%rsp)
imulq %rcx, %r8
movq %r8, 0x10(%rsp)
imulq %rcx, %r13
movq %r13, 0x38(%rsp)
pushq $0x1
popq %r11
movq $0x0, 0x30(%rsp)
movq %r11, %r12
xorl %edx, %edx
movq %rbx, 0x20(%rsp)
cmpq %r9, %r12
jge 0xabdd
movq %r11, %r8
cmpq %r10, %r8
jge 0xabd2
addq $0x8, %r15
movq %r11, %rbx
movq %r8, (%rsp)
cmpq %rbp, %rbx
jge 0xabca
movss -0x8(%r15), %xmm2
cvtss2sd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jb 0xa8fd
ucomiss -0x4(%r15), %xmm2
jbe 0xa8fd
ucomiss -0xc(%r15), %xmm2
jbe 0xa8fd
ucomiss -0x8(%r15,%r14,4), %xmm2
jbe 0xa8fd
movq 0x28(%rsp), %r13
ucomiss -0x8(%r15,%r13), %xmm2
jbe 0xa8fd
ucomiss -0x8(%r15,%rcx,4), %xmm2
jbe 0xa8fd
movq 0x20(%rsp), %r13
ucomiss -0x8(%r15,%r13), %xmm2
jbe 0xa8fd
ucomiss -0x4(%r15,%rcx,4), %xmm2
jbe 0xa8fd
ucomiss -0xc(%r15,%rcx,4), %xmm2
jbe 0xa8fd
movq 0x20(%rsp), %r13
ucomiss -0x4(%r15,%r13), %xmm2
jbe 0xa8fd
movq 0x20(%rsp), %r13
ucomiss -0xc(%r15,%r13), %xmm2
movq 0x38(%rsp), %r13
jbe 0xa8fd
ucomiss -0x4(%r15,%r14,4), %xmm2
jbe 0xa8fd
ucomiss -0xc(%r15,%r14,4), %xmm2
jbe 0xa8fd
movq 0x10(%rsp), %r8
ucomiss -0x8(%r15,%r8), %xmm2
movq (%rsp), %r8
jbe 0xa8fd
movq 0x8(%rsp), %r11
ucomiss -0x8(%r15,%r11), %xmm2
pushq $0x1
popq %r11
jbe 0xa8fd
movq 0x10(%rsp), %r8
ucomiss -0x4(%r15,%r8), %xmm2
movq (%rsp), %r8
jbe 0xa8fd
movq 0x10(%rsp), %r8
ucomiss -0xc(%r15,%r8), %xmm2
movq (%rsp), %r8
jbe 0xa8fd
movq 0x8(%rsp), %r11
ucomiss -0x4(%r15,%r11), %xmm2
pushq $0x1
popq %r11
jbe 0xa8fd
movq 0x8(%rsp), %r11
ucomiss -0xc(%r15,%r11), %xmm2
pushq $0x1
popq %r11
jbe 0xa8fd
movq 0x28(%rsp), %r8
ucomiss -0x4(%r15,%r8), %xmm2
movq (%rsp), %r8
jbe 0xa8fd
movq 0x28(%rsp), %r8
ucomiss -0xc(%r15,%r8), %xmm2
movq (%rsp), %r8
jbe 0xa8fd
ucomiss -0x8(%r15,%r13), %xmm2
jbe 0xa8fd
movq 0x18(%rsp), %r11
ucomiss -0x8(%r15,%r11), %xmm2
pushq $0x1
popq %r11
jbe 0xa8fd
ucomiss -0x4(%r15,%r13), %xmm2
jbe 0xa8fd
ucomiss -0xc(%r15,%r13), %xmm2
jbe 0xa8fd
movq 0x18(%rsp), %r11
ucomiss -0x4(%r15,%r11), %xmm2
pushq $0x1
popq %r11
jbe 0xa8fd
movq 0x18(%rsp), %r11
ucomiss -0xc(%r15,%r11), %xmm2
pushq $0x1
popq %r11
ja 0xaafe
ucomisd %xmm1, %xmm3
jb 0xab9d
movss -0x4(%r15), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movss -0xc(%r15), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movss -0x8(%r15,%r14,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movq 0x28(%rsp), %r8
movss -0x8(%r15,%r8), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xabaf
movss -0x8(%r15,%rcx,4), %xmm1
ucomiss %xmm2, %xmm1
movq (%rsp), %r8
jbe 0xab9d
movq 0x20(%rsp), %r13
movss -0x8(%r15,%r13), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movss -0x4(%r15,%rcx,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movss -0xc(%r15,%rcx,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movq 0x20(%rsp), %r13
movss -0x4(%r15,%r13), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movss -0xc(%r15,%r13), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movss -0x4(%r15,%r14,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movss -0xc(%r15,%r14,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movq 0x10(%rsp), %r8
movss -0x8(%r15,%r8), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xabaf
movq 0x8(%rsp), %r11
movss -0x8(%r15,%r11), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xabb8
movq 0x10(%rsp), %r8
movss -0x4(%r15,%r8), %xmm1
ucomiss %xmm2, %xmm1
pushq $0x1
popq %r11
jbe 0xabaf
movq 0x10(%rsp), %r8
movss -0xc(%r15,%r8), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xabaf
movq 0x8(%rsp), %r11
movss -0x4(%r15,%r11), %xmm1
ucomiss %xmm2, %xmm1
movq (%rsp), %r8
jbe 0xabc1
movq 0x8(%rsp), %r11
movss -0xc(%r15,%r11), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xabc1
movq 0x28(%rsp), %r13
movss -0x4(%r15,%r13), %xmm1
ucomiss %xmm2, %xmm1
pushq $0x1
popq %r11
jbe 0xab9d
movss -0xc(%r15,%r13), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movq 0x38(%rsp), %r13
movss -0x8(%r15,%r13), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movq 0x18(%rsp), %r11
movss -0x8(%r15,%r11), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xabc1
movss -0x4(%r15,%r13), %xmm1
ucomiss %xmm2, %xmm1
pushq $0x1
popq %r11
jbe 0xab9d
movss -0xc(%r15,%r13), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xab9d
movq 0x18(%rsp), %r11
movss -0x4(%r15,%r11), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xabc1
movss -0xc(%r15,%r11), %xmm1
ucomiss %xmm2, %xmm1
pushq $0x1
popq %r11
jbe 0xab9d
movq %rax, 0x68(%rsp)
leaq 0x18(%rdx), %r13
cmpq %r13, (%rsi)
jae 0xab74
addq $0xbb98, %rdx           # imm = 0xBB98
movapd %xmm0, 0x80(%rsp)
movq %rcx, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdi, 0x50(%rsp)
movq %r9, 0x48(%rsp)
movq %r10, 0x40(%rsp)
movapd %xmm3, 0x70(%rsp)
callq 0xabf9
movq (%rsp), %r8
movapd 0x70(%rsp), %xmm3
movq 0x40(%rsp), %r10
movq 0x48(%rsp), %r9
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rcx
movapd 0x80(%rsp), %xmm0
testl %eax, %eax
jne 0xabf4
movq (%rdi), %rax
movq 0x30(%rsp), %r11
imulq $0x18, %r11, %rdx
incq %r11
movq %r11, 0x30(%rsp)
movq %rbx, (%rax,%rdx)
movq %r8, 0x8(%rax,%rdx)
movq %r12, 0x10(%rax,%rdx)
movq 0x68(%rsp), %rax
jmp 0xabc4
movq %rdx, %r13
incq %rbx
addq $0x4, %r15
movq %r13, %rdx
jmp 0xa74e
movq %rdx, %r13
movq (%rsp), %r8
jmp 0xaba0
movq %rdx, %r13
pushq $0x1
popq %r11
jmp 0xabb2
movq %rdx, %r13
pushq $0x1
popq %r11
jmp 0xaba0
incq %r8
jmp 0xa73a
addq %rax, %r15
incq %r12
jmp 0xa72e
movq 0x30(%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x90b0