// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/liop.c
// Function: vl_liopdesc_new
VlLiopDesc *
vl_liopdesc_new (vl_int numNeighbours, vl_int numSpatialBins,
                 float radius, vl_size sideLength)
{
  vl_index i, t ;
  VlLiopDesc * self = vl_calloc(sizeof(VlLiopDesc), 1);

  assert(radius <= sideLength/2) ;

  self->numNeighbours = numNeighbours ;
  self->numSpatialBins = numSpatialBins ;
  self->neighRadius = radius ;
  self->intensityThreshold = DEFAULT_INTENSITY_THRESHOLD ;

  self->dimension = factorial(numNeighbours) * numSpatialBins ;

  /*
   Precompute a list of pixels within a circular patch inside
   the square image. Leave a suitable marging for sampling around
   these pixels.
   */

  self->patchSize = 0 ;
  self->patchPixels = vl_malloc(sizeof(vl_uindex)*sideLength*sideLength) ;
  self->patchSideLength = sideLength ;

  {
    vl_index x, y ;
    vl_index center = (sideLength - 1) / 2 ;
    double t = center - radius + 0.6 ;
    vl_index t2 = (vl_index) (t * t) ;
    for (y = 0 ; y < (signed)sideLength ; ++y) {
      for (x = 0 ; x < (signed)sideLength ; ++x) {
        vl_index dx = x - center ;
        vl_index dy = y - center ;
        if (x == 0 && y == 0) continue ;
        if (dx*dx + dy*dy <= t2) {
          self->patchPixels[self->patchSize++] = x + y * sideLength ;
        }
      }
    }
  }

  self->patchIntensities = vl_malloc(sizeof(vl_uindex)*self->patchSize) ;
  self->patchPermutation = vl_malloc(sizeof(vl_uindex)*self->patchSize) ;

  /*
   Precompute the samples in the circular neighbourhood of each
   measurement point.
   */

  self->neighPermutation = vl_malloc(sizeof(vl_uindex) * self->numNeighbours) ;
  self->neighIntensities = vl_malloc(sizeof(float) * self->numNeighbours) ;
  self->neighSamplesX = vl_calloc(sizeof(double), self->numNeighbours * self->patchSize) ;
  self->neighSamplesY = vl_calloc(sizeof(double), self->numNeighbours * self->patchSize) ;

  for (i = 0 ; i < (signed)self->patchSize ; ++i) {
    vl_index pixel ;
    double x, y ;
    double dangle = 2*VL_PI / (double)self->numNeighbours ;
    double angle0 ;
    vl_index center = (sideLength - 1) / 2 ;

    pixel = self->patchPixels[i] ;
    x = (pixel % (signed)self->patchSideLength) - center ;
    y = (pixel / (signed)self->patchSideLength) - center ;

    angle0 = atan2(y,x) ;

    for (t = 0 ; t < (signed)self->numNeighbours ; ++t) {
      double x1 = x + radius * cos(angle0 + dangle * t) + center ;
      double y1 = y + radius * sin(angle0 + dangle * t) + center ;
      self->neighSamplesX[t + (signed)self->numNeighbours * i] = x1 ;
      self->neighSamplesY[t + (signed)self->numNeighbours * i] = y1 ;
    }
  }
  return self ;
}

// Assembly:
subq $0xc8, %rsp
movl %edi, 0xc4(%rsp)
movl %esi, 0xc0(%rsp)
movss %xmm0, 0xbc(%rsp)
movq %rdx, 0xb0(%rsp)
movl $0x68, %edi
movl $0x1, %esi
callq 0x9a70
movq %rax, 0x98(%rsp)
movl 0xc4(%rsp), %ecx
movq 0x98(%rsp), %rax
movl %ecx, (%rax)
movl 0xc0(%rsp), %ecx
movq 0x98(%rsp), %rax
movl %ecx, 0x4(%rax)
movss 0xbc(%rsp), %xmm0
movq 0x98(%rsp), %rax
movss %xmm0, 0x40(%rax)
movq 0x98(%rsp), %rax
movss 0x21bda(%rip), %xmm0    # 0x59f80
movss %xmm0, 0x8(%rax)
movl 0xc4(%rsp), %edi
callq 0x38920
imull 0xc0(%rsp), %eax
movslq %eax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x98(%rsp), %rax
movq $0x0, 0x20(%rax)
movq 0xb0(%rsp), %rdi
shlq $0x3, %rdi
imulq 0xb0(%rsp), %rdi
callq 0x9660
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0xb0(%rsp), %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0xb0(%rsp), %rax
subq $0x1, %rax
shrq %rax
movq %rax, 0x80(%rsp)
cvtsi2ssq 0x80(%rsp), %xmm0
subss 0xbc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x20c37(%rip), %xmm1    # 0x59088
addsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x78(%rsp), %xmm0
mulsd 0x78(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x70(%rsp)
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq 0xb0(%rsp), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x3859c
movq $0x0, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq 0xb0(%rsp), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x38581
movq 0x90(%rsp), %rax
subq 0x80(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x88(%rsp), %rax
subq 0x80(%rsp), %rax
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x90(%rsp)
jne 0x38503
cmpq $0x0, 0x88(%rsp)
jne 0x38503
jmp 0x38568
movq 0x68(%rsp), %rax
imulq 0x68(%rsp), %rax
movq 0x60(%rsp), %rcx
imulq 0x60(%rsp), %rcx
addq %rcx, %rax
cmpq 0x70(%rsp), %rax
jg 0x38566
movq 0x90(%rsp), %rdx
movq 0x88(%rsp), %rax
imulq 0xb0(%rsp), %rax
addq %rax, %rdx
movq 0x98(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x98(%rsp), %rsi
movq 0x20(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x20(%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x38568
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x384a5
jmp 0x38583
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x3847d
movq 0x98(%rsp), %rax
movq 0x20(%rax), %rdi
shlq $0x3, %rdi
callq 0x9660
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x98(%rsp), %rax
movq 0x20(%rax), %rdi
shlq $0x3, %rdi
callq 0x9660
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x98(%rsp), %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
callq 0x9660
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x98(%rsp), %rax
movslq (%rax), %rdi
shlq $0x2, %rdi
callq 0x9660
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x98(%rsp), %rax
movslq (%rax), %rsi
movq 0x98(%rsp), %rax
imulq 0x20(%rax), %rsi
movl $0x8, %edi
callq 0x9a70
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x58(%rax)
movq 0x98(%rsp), %rax
movslq (%rax), %rsi
movq 0x98(%rsp), %rax
imulq 0x20(%rax), %rsi
movl $0x8, %edi
callq 0x9a70
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x60(%rax)
movq $0x0, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movq 0x98(%rsp), %rcx
movq 0x20(%rcx), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x3890a
movq 0x98(%rsp), %rax
cvtsi2sdl (%rax), %xmm1
movsd 0x20b64(%rip), %xmm0    # 0x59230
divsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0xb0(%rsp), %rax
subq $0x1, %rax
shrq %rax
movq %rax, 0x30(%rsp)
movq 0x98(%rsp), %rax
movq 0x28(%rax), %rax
movq 0xa8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq 0x98(%rsp), %rcx
movq 0x18(%rcx), %rcx
movslq %ecx, %rcx
cqto
idivq %rcx
subq 0x30(%rsp), %rdx
cvtsi2sd %rdx, %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x58(%rsp), %rax
movq 0x98(%rsp), %rcx
movq 0x18(%rcx), %rcx
movslq %ecx, %rcx
cqto
idivq %rcx
subq 0x30(%rsp), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
callq 0x9820
movsd %xmm0, 0x38(%rsp)
movq $0x0, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq 0x98(%rsp), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jge 0x388ef
movsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rsp)
movss 0xbc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x38(%rsp), %xmm1
movsd 0x40(%rsp), %xmm0
cvtsi2sdq 0xa0(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x94e0
movsd (%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsi2sdq 0x30(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movss 0xbc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x38(%rsp), %xmm1
movsd 0x40(%rsp), %xmm0
cvtsi2sdq 0xa0(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x99e0
movsd 0x10(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x18(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsi2sdq 0x30(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x28(%rsp), %xmm0
movq 0x98(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa0(%rsp), %rcx
movq 0x98(%rsp), %rdx
movslq (%rdx), %rdx
imulq 0xa8(%rsp), %rdx
addq %rdx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x20(%rsp), %xmm0
movq 0x98(%rsp), %rax
movq 0x60(%rax), %rax
movq 0xa0(%rsp), %rcx
movq 0x98(%rsp), %rdx
movslq (%rdx), %rdx
imulq 0xa8(%rsp), %rdx
addq %rdx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x3877c
jmp 0x388f1
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
jmp 0x38698
movq 0x98(%rsp), %rax
addq $0xc8, %rsp
retq
nopw (%rax,%rax)