// File: /workspace/github_c_makefile_star2_O3/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 $0xf8, %rsp
decl %r9d
movslq %r9d, %rax
movq %rax, 0x90(%rsp)
cmpq $0x2, %rax
jl 0xb049
movq %rsi, 0x40(%rsp)
movq %rdi, 0x38(%rsp)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %r8, %r10
imulq %rcx, %r10
leaq (%rdx,%rcx,4), %rdx
leaq (%rdx,%r10,4), %rbx
addq $0x4, %rbx
movq %r8, %r11
shlq $0x20, %r11
addq %rax, %r11
sarq $0x20, %r11
movq %rcx, %rdx
shlq $0x20, %rdx
addq %rax, %rdx
movq %rdx, %rax
movq %rdx, %r14
sarq $0x20, %r14
movapd 0x2763a(%rip), %xmm3    # 0x320d0
xorpd %xmm0, %xmm3
leaq (,%rcx,8), %rdx
sarq $0x1e, %rax
addq $-0x4, %rax
shlq $0x2, %r10
movq %r10, %r15
negq %r15
leaq (,%rcx,4), %r13
leaq (,%r8,4), %rbp
leaq 0x4(,%r8,4), %r12
imulq %rcx, %r12
movq %r12, 0xb0(%rsp)
movl $0x4, %r12d
subq %rbp, %r12
imulq %rcx, %r12
movq %r12, 0xa8(%rsp)
movq %r13, 0xc0(%rsp)
negq %r13
movq %r13, 0xa0(%rsp)
leaq -0x4(,%r8,4), %r12
movq %r15, %r8
imulq %rcx, %r12
movq %r12, 0x98(%rsp)
xorq $-0x4, %rbp
imulq %rcx, %rbp
movq %rbp, 0xb8(%rsp)
movl $0x1, %r15d
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq %r15, 0x48(%rsp)
cmpq $0x2, %r11
jl 0xb02e
movl $0x1, %r13d
cmpq $0x2, %r14
jl 0xb01e
leaq (%rbx,%rax), %r15
movq %r15, 0xc8(%rsp)
leaq (%rbx,%r10), %r12
leaq (%rbx,%r8), %rcx
movq %rcx, 0x8(%rsp)
movq 0xc0(%rsp), %r15
leaq (%rbx,%r15), %r9
movq %r9, 0x18(%rsp)
movq 0xb0(%rsp), %r15
leaq (%rbx,%r15), %r9
movq %r9, 0x50(%rsp)
movq 0xa8(%rsp), %r15
leaq (%rbx,%r15), %r9
movq 0xa0(%rsp), %r15
leaq (%rbx,%r15), %rcx
movq 0x98(%rsp), %r15
leaq (%rbx,%r15), %rdi
movq %rdi, 0x10(%rsp)
movq 0xb8(%rsp), %r15
leaq (%rbx,%r15), %rdi
movl $0x1, %r15d
movq %rcx, 0x30(%rsp)
movq %r9, %rbp
movss -0x4(%rbx,%r15,4), %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jb 0xad32
ucomiss (%rbx,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x8(%rbx,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x4(%r12,%r15,4), %xmm2
jbe 0xad32
movq 0x8(%rsp), %r9
ucomiss -0x4(%r9,%r15,4), %xmm2
jbe 0xad32
movq 0x18(%rsp), %r9
ucomiss -0x4(%r9,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x4(%rcx,%r15,4), %xmm2
jbe 0xad32
movq 0x18(%rsp), %r9
ucomiss (%r9,%r15,4), %xmm2
jbe 0xad32
movq 0x18(%rsp), %r9
ucomiss -0x8(%r9,%r15,4), %xmm2
movq 0x50(%rsp), %r9
jbe 0xad32
ucomiss (%rcx,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x8(%rcx,%r15,4), %xmm2
jbe 0xad32
ucomiss (%r12,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x8(%r12,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x4(%r9,%r15,4), %xmm2
jbe 0xad32
movq %rdi, %rsi
movq 0x10(%rsp), %rdi
ucomiss -0x4(%rdi,%r15,4), %xmm2
movq %rsi, %rdi
jbe 0xad32
ucomiss (%r9,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x8(%r9,%r15,4), %xmm2
jbe 0xad32
movq 0x10(%rsp), %rdi
ucomiss (%rdi,%r15,4), %xmm2
movq %rsi, %rdi
jbe 0xad32
movq 0x10(%rsp), %rdi
ucomiss -0x8(%rdi,%r15,4), %xmm2
movq %rsi, %rdi
jbe 0xad32
movq 0x8(%rsp), %r9
ucomiss (%r9,%r15,4), %xmm2
jbe 0xad32
movq 0x8(%rsp), %r9
ucomiss -0x8(%r9,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x4(%rbp,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x4(%rdi,%r15,4), %xmm2
jbe 0xad32
ucomiss (%rbp,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x8(%rbp,%r15,4), %xmm2
jbe 0xad32
ucomiss (%rdi,%r15,4), %xmm2
jbe 0xad32
ucomiss -0x8(%rdi,%r15,4), %xmm2
ja 0xaf0f
ucomisd %xmm1, %xmm3
jb 0xaff6
movss (%rbx,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movss -0x8(%rbx,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
movq %rbp, %r9
jbe 0xaff9
movss -0x4(%r12,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff9
movq 0x8(%rsp), %rcx
movss -0x4(%rcx,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb007
movq 0x18(%rsp), %r9
movss -0x4(%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
movq 0x30(%rsp), %rcx
jbe 0xaff6
movss -0x4(%rcx,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movq 0x18(%rsp), %r9
movss (%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movss -0x8(%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movss (%rcx,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
movq 0x50(%rsp), %r9
jbe 0xaff6
movss -0x8(%rcx,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movss (%r12,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movss -0x8(%r12,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movss -0x4(%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movq %rdi, %rsi
movq 0x10(%rsp), %rdi
movss -0x4(%rdi,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb00e
movss (%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
movq %rsi, %rdi
jbe 0xaff6
movss -0x8(%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movq 0x10(%rsp), %rdi
movss (%rdi,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
movq %rbp, %r9
jbe 0xb011
movss -0x8(%rdi,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xb011
movq 0x8(%rsp), %rdi
movss (%rdi,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
movq %rsi, %rdi
jbe 0xaff9
movq 0x8(%rsp), %rsi
movss -0x8(%rsi,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff9
movss -0x4(%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff9
movss -0x4(%rdi,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff9
movss (%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff9
movss -0x8(%r9,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff9
movss (%rdi,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movss -0x8(%rdi,%r15,4), %xmm1
ucomiss %xmm2, %xmm1
jbe 0xaff6
movq %rdi, 0x60(%rsp)
movq %r8, 0x68(%rsp)
movq %rdx, 0x70(%rsp)
movapd %xmm3, 0xd0(%rsp)
movq %rax, 0x78(%rsp)
movq %r11, 0x80(%rsp)
movq %r10, 0x88(%rsp)
movapd %xmm0, 0xe0(%rsp)
movq 0x28(%rsp), %rax
leaq 0x18(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x58(%rsp)
cmpq %rcx, (%rax)
jae 0xaf80
movq 0x28(%rsp), %rdx
addq $0xbb98, %rdx           # imm = 0xBB98
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0xb06e
testl %eax, %eax
jne 0xb069
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdx
leaq (%rdx,%rdx,2), %rcx
incq %rdx
movq %rdx, 0x20(%rsp)
movq %r15, (%rax,%rcx,8)
movq %r13, 0x8(%rax,%rcx,8)
movq 0x48(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movq 0x58(%rsp), %rax
movq %rax, 0x28(%rsp)
movapd 0xe0(%rsp), %xmm0
movq 0x88(%rsp), %r10
movq 0x80(%rsp), %r11
movq 0x78(%rsp), %rax
movapd 0xd0(%rsp), %xmm3
movq 0x70(%rsp), %rdx
movq 0x68(%rsp), %r8
movq %rbp, %r9
movq 0x30(%rsp), %rcx
movq 0x60(%rsp), %rdi
jmp 0xaff9
movq %rbp, %r9
incq %r15
cmpq %r15, %r14
jne 0xabd9
jmp 0xb016
movq 0x30(%rsp), %rcx
jmp 0xaff9
movq %rbp, %r9
movq %rsi, %rdi
jmp 0xaff9
movq 0xc8(%rsp), %rbx
addq $0x8, %rbx
incq %r13
cmpq %r11, %r13
jne 0xab54
addq %rdx, %rbx
movq 0x48(%rsp), %r15
incq %r15
cmpq 0x90(%rsp), %r15
jne 0xab3f
jmp 0xb052
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x90b0