// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/covdet.c
// Function: vl_covdet_new
VlCovDet *
vl_covdet_new (VlCovDetMethod method)
{
  VlCovDet * self = vl_calloc(sizeof(VlCovDet),1) ;
  self->method = method ;
  self->octaveResolution = 3 ;
  self->firstOctave = -1 ;
  switch (self->method) {
    case VL_COVDET_METHOD_DOG :
      self->peakThreshold = VL_COVDET_DOG_DEF_PEAK_THRESHOLD ;
      self->edgeThreshold = VL_COVDET_DOG_DEF_EDGE_THRESHOLD ;
      self->lapPeakThreshold = 0  ; /* not used */
      break ;
    case VL_COVDET_METHOD_HARRIS_LAPLACE:
    case VL_COVDET_METHOD_MULTISCALE_HARRIS:
      self->peakThreshold = VL_COVDET_HARRIS_DEF_PEAK_THRESHOLD ;
      self->edgeThreshold = VL_COVDET_HARRIS_DEF_EDGE_THRESHOLD ;
      self->lapPeakThreshold = VL_COVDET_LAP_DEF_PEAK_THRESHOLD ;
      break ;
    case VL_COVDET_METHOD_HESSIAN :
    case VL_COVDET_METHOD_HESSIAN_LAPLACE:
    case VL_COVDET_METHOD_MULTISCALE_HESSIAN:
      self->peakThreshold = VL_COVDET_HESSIAN_DEF_PEAK_THRESHOLD ;
      self->edgeThreshold = VL_COVDET_HESSIAN_DEF_EDGE_THRESHOLD ;
      self->lapPeakThreshold = VL_COVDET_LAP_DEF_PEAK_THRESHOLD ;
      break;
    default:
      assert(0) ;
  }

  self->nonExtremaSuppression = 0.5 ;
  self->features = NULL ;
  self->numFeatures = 0 ;
  self->numFeatureBufferSize = 0 ;
  self->patch = NULL ;
  self->patchBufferSize = 0 ;
  self->transposed = VL_FALSE ;
  self->aaAccurateSmoothing = VL_COVDET_AA_ACCURATE_SMOOTHING ;

  {
    vl_index const w = VL_COVDET_AA_PATCH_RESOLUTION ;
    vl_index i,j ;
    double step = (2.0 * VL_COVDET_AA_PATCH_EXTENT) / (2*w+1) ;
    double sigma = VL_COVDET_AA_RELATIVE_INTEGRATION_SIGMA ;
    for (j = -w ; j <= w ; ++j) {
      for (i = -w ; i <= w ; ++i) {
        double dx = i*step/sigma ;
        double dy = j*step/sigma ;
        self->aaMask[(i+w) + (2*w+1)*(j+w)] = exp(-0.5*(dx*dx+dy*dy)) ;
      }
    }
  }

  {
    /*
     Covers one octave of Laplacian filters, from sigma=1 to sigma=2.
     The spatial sampling step is 0.5.
     */
    vl_index s ;
    for (s = 0 ; s < VL_COVDET_LAP_NUM_LEVELS ; ++s) {
      double sigmaLap = pow(2.0, -0.5 +
                            (double)s / (VL_COVDET_LAP_NUM_LEVELS - 1)) ;
      double const sigmaImage = 1.0 / sqrt(2.0) ;
      double const step = 0.5 * sigmaImage ;
      double const sigmaDelta = sqrt(sigmaLap*sigmaLap - sigmaImage*sigmaImage) ;
      vl_size const w = VL_COVDET_LAP_PATCH_RESOLUTION ;
      vl_size const num = 2 * w + 1  ;
      float * pt = self->laplacians + s * (num * num) ;

      memset(pt, 0, num * num * sizeof(float)) ;

#define at(x,y) pt[(x+w)+(y+w)*(2*w+1)]
      at(0,0) = - 4.0 ;
      at(-1,0) = 1.0 ;
      at(+1,0) = 1.0 ;
      at(0,1) = 1.0 ;
      at(0,-1) = 1.0 ;
#undef at

      vl_imsmooth_f(pt, num,
                    pt, num, num, num,
                    sigmaDelta / step, sigmaDelta / step) ;

#if 0
      {
        char name [200] ;
        snprintf(name, 200, "/tmp/%f-lap.pgm", sigmaDelta) ;
        vl_pgm_write_f(name, pt, num, num) ;
      }
#endif

    }
  }
  return self ;
}

// Assembly:
subq $0x98, %rsp
movl %edi, 0x94(%rsp)
movl $0x12568, %edi          # imm = 0x12568
movl $0x1, %esi
callq 0x9a70
movq %rax, 0x88(%rsp)
movl 0x94(%rsp), %ecx
movq 0x88(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x88(%rsp), %rax
movq $0x3, 0x30(%rax)
movq 0x88(%rsp), %rax
movq $-0x1, 0x38(%rax)
movq 0x88(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, 0xc(%rsp)
subl $0x1, %eax
je 0xd5f7
jmp 0xd5bd
movl 0xc(%rsp), %eax
addl $-0x2, %eax
subl $0x2, %eax
jb 0xd677
jmp 0xd5cf
movl 0xc(%rsp), %eax
subl $0x4, %eax
je 0xd636
jmp 0xd5da
movl 0xc(%rsp), %eax
subl $0x5, %eax
je 0xd677
jmp 0xd5e9
movl 0xc(%rsp), %eax
subl $0x6, %eax
je 0xd636
jmp 0xd6b8
movq 0x88(%rsp), %rax
movsd 0x4baa1(%rip), %xmm0    # 0x590a8
movsd %xmm0, 0x18(%rax)
movq 0x88(%rsp), %rax
movsd 0x4ba94(%rip), %xmm0    # 0x590b0
movsd %xmm0, 0x20(%rax)
movq 0x88(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rax)
jmp 0xd6ba
movq 0x88(%rsp), %rax
movsd 0x4ba7a(%rip), %xmm0    # 0x590c0
movsd %xmm0, 0x18(%rax)
movq 0x88(%rsp), %rax
movsd 0x4ba55(%rip), %xmm0    # 0x590b0
movsd %xmm0, 0x20(%rax)
movq 0x88(%rsp), %rax
movsd 0x4ba38(%rip), %xmm0    # 0x590a8
movsd %xmm0, 0x28(%rax)
jmp 0xd6ba
movq 0x88(%rsp), %rax
movsd 0x4ba31(%rip), %xmm0    # 0x590b8
movsd %xmm0, 0x18(%rax)
movq 0x88(%rsp), %rax
movsd 0x4ba14(%rip), %xmm0    # 0x590b0
movsd %xmm0, 0x20(%rax)
movq 0x88(%rsp), %rax
movsd 0x4b9f7(%rip), %xmm0    # 0x590a8
movsd %xmm0, 0x28(%rax)
jmp 0xd6ba
jmp 0xd6ba
movq 0x88(%rsp), %rax
movsd 0x4b9b6(%rip), %xmm0    # 0x59080
movsd %xmm0, 0x40(%rax)
movq 0x88(%rsp), %rax
movq $0x0, 0x50(%rax)
movq 0x88(%rsp), %rax
movq $0x0, 0x58(%rax)
movq 0x88(%rsp), %rax
movq $0x0, 0x60(%rax)
movq 0x88(%rsp), %rax
movq $0x0, 0x68(%rax)
movq 0x88(%rsp), %rax
movq $0x0, 0x70(%rax)
movq 0x88(%rsp), %rax
movl $0x0, 0x78(%rax)
movq 0x88(%rsp), %rax
movl $0x0, 0x100(%rax)
movq $0x14, 0x80(%rsp)
movsd 0x4b97c(%rip), %xmm0    # 0x590d0
movsd %xmm0, 0x68(%rsp)
movsd 0x4b966(%rip), %xmm0    # 0x590c8
movsd %xmm0, 0x60(%rsp)
movq $-0x14, 0x70(%rsp)
cmpq $0x14, 0x70(%rsp)
jg 0xd84b
movq $-0x14, 0x78(%rsp)
cmpq $0x14, 0x78(%rsp)
jg 0xd836
cvtsi2sdq 0x78(%rsp), %xmm0
mulsd 0x68(%rsp), %xmm0
divsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
cvtsi2sdq 0x70(%rsp), %xmm0
mulsd 0x68(%rsp), %xmm0
divsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x58(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movsd 0x50(%rsp), %xmm0
mulsd 0x50(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x4b8fc(%rip), %xmm0    # 0x590e8
mulsd %xmm1, %xmm0
callq 0x9c10
cvtsd2ss %xmm0, %xmm0
movq 0x88(%rsp), %rax
movq 0x78(%rsp), %rcx
addq $0x14, %rcx
movq 0x70(%rsp), %rdx
addq $0x14, %rdx
imulq $0x29, %rdx, %rdx
addq %rdx, %rcx
movss %xmm0, 0x4fd0(%rax,%rcx,4)
movq 0x78(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x78(%rsp)
jmp 0xd786
jmp 0xd838
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0xd771
movq $0x0, 0x48(%rsp)
cmpq $0xa, 0x48(%rsp)
jge 0xda02
cvtsi2sdq 0x48(%rsp), %xmm0
movsd 0x4b881(%rip), %xmm1    # 0x590f0
divsd %xmm1, %xmm0
movsd 0x4b86d(%rip), %xmm1    # 0x590e8
addsd %xmm0, %xmm1
movsd 0x4b859(%rip), %xmm0    # 0x590e0
callq 0x92b0
movsd %xmm0, 0x40(%rsp)
movsd 0x4b846(%rip), %xmm0    # 0x590e0
callq 0x9b20
movaps %xmm0, %xmm1
movsd 0x4b82e(%rip), %xmm0    # 0x590d8
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x4b7c4(%rip), %xmm0    # 0x59080
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x40(%rsp), %xmm0
movsd 0x40(%rsp), %xmm2
movsd 0x38(%rsp), %xmm1
mulsd 0x38(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x9b20
movsd %xmm0, 0x28(%rsp)
movq $0x10, 0x20(%rsp)
movq $0x21, 0x18(%rsp)
movq 0x88(%rsp), %rax
addq $0x7b18, %rax           # imm = 0x7B18
imulq $0x441, 0x48(%rsp), %rcx # imm = 0x441
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movl $0x1104, %edx           # imm = 0x1104
callq 0x9480
movq 0x10(%rsp), %rax
movss 0x4b837(%rip), %xmm0    # 0x59194
movss %xmm0, 0x880(%rax)
movq 0x10(%rsp), %rax
movss 0x4b81e(%rip), %xmm0    # 0x59190
movss %xmm0, 0x87c(%rax)
movq 0x10(%rsp), %rax
movss 0x4b809(%rip), %xmm0    # 0x59190
movss %xmm0, 0x884(%rax)
movq 0x10(%rsp), %rax
movss 0x4b7f4(%rip), %xmm0    # 0x59190
movss %xmm0, 0x904(%rax)
movq 0x10(%rsp), %rax
movss 0x4b7df(%rip), %xmm0    # 0x59190
movss %xmm0, 0x7fc(%rax)
movq 0x10(%rsp), %rdi
movq 0x10(%rsp), %rdx
movsd 0x28(%rsp), %xmm0
divsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
divsd 0x30(%rsp), %xmm1
movl $0x21, %r9d
movq %r9, %rsi
movq %r9, %rcx
movq %r9, %r8
callq 0x98e0
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0xd854
movq 0x88(%rsp), %rax
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)