// File: /workspace/github_c_makefile_star2_O1/zpole[P]IICV/vl/covdet.c
// Function: vl_covdet_extract_patch_helper
vl_bool
vl_covdet_extract_patch_helper (VlCovDet * self,
                                double * sigma1,
                                double * sigma2,
                                float * patch,
                                vl_size resolution,
                                double extent,
                                double sigma,
                                double A_ [4],
                                double T_ [2],
                                double d1, double d2)
{
  vl_index o, s ;
  double factor ;
  double sigma_ ;
  float const * level ;
  vl_size width, height ;
  double step ;

  double A [4] = {A_[0], A_[1], A_[2], A_[3]} ;
  double T [2] = {T_[0], T_[1]} ;

  VlScaleSpaceGeometry geom = vl_scalespace_get_geometry(self->gss) ;
  VlScaleSpaceOctaveGeometry oct ;

  /* Starting from a pre-smoothed image at scale sigma_
     because of the mapping A the resulting smoothing in
     the warped patch is S, where

        sigma_^2 I = A S A',

        S = sigma_^2 inv(A) inv(A)' = sigma_^2 V D^-2 V',

        A = U D V'.

     Thus we rotate A by V to obtain an axis-aligned smoothing:

        A = U*D,

        S = sigma_^2 D^-2.

     Then we search the scale-space for the best sigma_ such
     that the target smoothing is approximated from below:

        max sigma_(o,s) :    simga_(o,s) factor <= sigma,
        factor = max{abs(D11), abs(D22)}.
   */


  /*
   Determine the best level (o,s) such that sigma_(o,s) factor <= sigma.
   This can be obtained by scanning octaves from smallest to largest
   and stopping when no level in the octave satisfies the relation.

   Given the range of octave availables, do the best you can.
   */

  factor = 1.0 / VL_MIN(d1, d2) ;

  for (o = geom.firstOctave + 1 ; o <= geom.lastOctave ; ++o) {
    s = vl_floor_d(vl_log2_d(sigma / (factor * geom.baseScale)) - o) ;
    s = VL_MAX(s, geom.octaveFirstSubdivision) ;
    s = VL_MIN(s, geom.octaveLastSubdivision) ;
    sigma_ = geom.baseScale * pow(2.0, o + (double)s / geom.octaveResolution) ;
    /*VL_PRINTF(".. %d D=%g %g; sigma_=%g factor*sigma_=%g\n", o, d1, d2, sigma_, factor* sigma_) ;*/
    if (factor * sigma_ > sigma) {
      o -- ;
      break ;
    }
  }
  o = VL_MIN(o, geom.lastOctave) ;
  s = vl_floor_d(vl_log2_d(sigma / (factor * geom.baseScale)) - o) ;
  s = VL_MAX(s, geom.octaveFirstSubdivision) ;
  s = VL_MIN(s, geom.octaveLastSubdivision) ;
  sigma_ = geom.baseScale * pow(2.0, o + (double)s / geom.octaveResolution) ;
  if (sigma1) *sigma1 = sigma_ / d1 ;
  if (sigma2) *sigma2 = sigma_ / d2 ;

  /*VL_PRINTF("%d %d %g %g %g %g\n", o, s, factor, sigma_, factor * sigma_, sigma) ;*/

  /*
   Now the scale space level to be used for this warping has been
   determined.

   If the patch is partially or completely out of the image boundary,
   create a padded copy of the required region first.
   */

  level = vl_scalespace_get_level(self->gss, o, s) ;
  oct = vl_scalespace_get_octave_geometry(self->gss, o) ;
  width = oct.width ;
  height = oct.height ;
  step = oct.step ;

  A[0] /= step ;
  A[1] /= step ;
  A[2] /= step ;
  A[3] /= step ;
  T[0] /= step ;
  T[1] /= step ;

  {
    /*
     Warp the patch domain [x0hat,y0hat,x1hat,y1hat] to the image domain/
     Obtain a box [x0,y0,x1,y1] enclosing that wrapped box, and then
     an integer vertexes version [x0i, y0i, x1i, y1i], making room
     for one pixel at the boundary to simplify bilinear interpolation
     later on.
     */
    vl_index x0i, y0i, x1i, y1i ;
    double x0 = +VL_INFINITY_D ;
    double x1 = -VL_INFINITY_D ;
    double y0 = +VL_INFINITY_D ;
    double y1 = -VL_INFINITY_D ;
    double boxx [4] = {extent, extent, -extent, -extent} ;
    double boxy [4] = {-extent, extent, extent, -extent} ;
    int i ;
    for (i = 0 ; i < 4 ; ++i) {
      double x = A[0] * boxx[i] + A[2] * boxy[i] + T[0] ;
      double y = A[1] * boxx[i] + A[3] * boxy[i] + T[1] ;
      x0 = VL_MIN(x0, x) ;
      x1 = VL_MAX(x1, x) ;
      y0 = VL_MIN(y0, y) ;
      y1 = VL_MAX(y1, y) ;
    }

    /* Leave one pixel border for bilinear interpolation. */
    x0i = floor(x0) - 1 ;
    y0i = floor(y0) - 1 ;
    x1i = ceil(x1) + 1 ;
    y1i = ceil(y1) + 1 ;

    /*
     If the box [x0i,y0i,x1i,y1i] is not fully contained in the
     image domain, then create a copy of this region by padding
     the image. The image is extended by continuity.
     */

    if (x0i < 0 || x1i > (signed)width-1 ||
        y0i < 0 || y1i > (signed)height-1) {
      vl_index xi, yi ;

      /* compute the amount of l,r,t,b padding needed to complete the patch */
      vl_index padx0 = VL_MAX(0, - x0i) ;
      vl_index pady0 = VL_MAX(0, - y0i) ;
      vl_index padx1 = VL_MAX(0, x1i - ((signed)width - 1)) ;
      vl_index pady1 = VL_MAX(0, y1i - ((signed)height - 1)) ;

      /* make enough room for the patch */
      vl_index patchWidth = x1i - x0i + 1 ;
      vl_index patchHeight = y1i - y0i + 1 ;
      vl_size patchBufferSize = patchWidth * patchHeight * sizeof(float) ;
      if (patchBufferSize > self->patchBufferSize) {
        int err = _vl_resize_buffer((void**)&self->patch, &self->patchBufferSize, patchBufferSize) ;
        if (err) return vl_set_last_error(VL_ERR_ALLOC, NULL) ;
      }

      if (pady0 < patchHeight - pady1) {
        /* start by filling the central horizontal band */
        for (yi = y0i + pady0 ; yi < y0i + patchHeight - pady1 ; ++ yi) {
          float *dst = self->patch + (yi - y0i) * patchWidth ;
          float const *src = level + yi * width + VL_MIN(VL_MAX(0, x0i),(signed)width-1) ;
          for (xi = x0i ; xi < x0i + padx0 ; ++xi) *dst++ = *src ;
          for ( ; xi < x0i + patchWidth - padx1 - 2 ; ++xi) *dst++ = *src++ ;
          for ( ; xi < x0i + patchWidth ; ++xi) *dst++ = *src ;
        }
        /* now extend the central band up and down */
        for (yi = 0 ; yi < pady0 ; ++yi) {
          memcpy(self->patch + yi * patchWidth,
                 self->patch + pady0 * patchWidth,
                 patchWidth * sizeof(float)) ;
        }
        for (yi = patchHeight - pady1 ; yi < patchHeight ; ++yi) {
          memcpy(self->patch + yi * patchWidth,
                 self->patch + (patchHeight - pady1 - 1) * patchWidth,
                 patchWidth * sizeof(float)) ;
        }
      } else {
        /* should be handled better! */
        memset(self->patch, 0, self->patchBufferSize) ;
      }
#if 0
      {
        char name [200] ;
        snprintf(name, 200, "/tmp/%20.0f-ext.pgm", 1e10*vl_get_cpu_time()) ;
        vl_pgm_write_f(name, patch, patchWidth, patchWidth) ;
      }
#endif

      level = self->patch ;
      width = patchWidth ;
      height = patchHeight ;
      T[0] -= x0i ;
      T[1] -= y0i ;
    }
  }

  /*
   Resample by using bilinear interpolation.
   */
  {
    float * pt = patch ;
    double yhat = -extent ;
    vl_index xxi ;
    vl_index yyi ;
    double stephat = extent / resolution ;

    for (yyi = 0 ; yyi < 2 * (signed)resolution + 1 ; ++yyi) {
      double xhat = -extent ;
      double rx = A[2] * yhat + T[0] ;
      double ry = A[3] * yhat + T[1] ;
      for (xxi = 0 ; xxi < 2 * (signed)resolution + 1 ; ++xxi) {
        double x = A[0] * xhat + rx ;
        double y = A[1] * xhat + ry ;
        vl_index xi = vl_floor_d(x) ;
        vl_index yi = vl_floor_d(y) ;
        double i00 = level[yi * width + xi] ;
        double i10 = level[yi * width + xi + 1] ;
        double i01 = level[(yi + 1) * width + xi] ;
        double i11 = level[(yi + 1) * width + xi + 1] ;
        double wx = x - xi ;
        double wy = y - yi ;

        assert(xi >= 0 && xi <= (signed)width - 1) ;
        assert(yi >= 0 && yi <= (signed)height - 1) ;

        *pt++ =
        (1.0 - wy) * ((1.0 - wx) * i00 + wx * i10) +
        wy * ((1.0 - wx) * i01 + wx * i11) ;

        xhat += stephat ;
      }
      yhat += stephat ;
    }
  }
#if 0
    {
      char name [200] ;
      snprintf(name, 200, "/tmp/%20.0f.pgm", 1e10*vl_get_cpu_time()) ;
      vl_pgm_write_f(name, patch, 2*resolution+1, 2*resolution+1) ;
    }
#endif
  return VL_ERR_OK ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movsd %xmm3, 0x40(%rsp)
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, 0x70(%rsp)
movaps %xmm0, 0xc0(%rsp)
movq %r8, 0xe8(%rsp)
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, 0x18(%rsp)
movq 0x1d0(%rsp), %rax
movups (%r9), %xmm0
movaps %xmm0, 0xb0(%rsp)
movups 0x10(%r9), %xmm0
movaps %xmm0, 0xa0(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x90(%rsp)
movq (%rdi), %rsi
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0x98c0
movsd 0x8(%rsp), %xmm0
minsd 0x40(%rsp), %xmm0
movsd 0x26141(%rip), %xmm2    # 0x33260
divsd %xmm0, %xmm2
movq 0x10(%r14), %r14
movsd %xmm2, 0x20(%rsp)
cmpq 0x120(%rsp), %r14
jge 0xd216
incq %r14
movsd 0x140(%rsp), %xmm1
mulsd %xmm2, %xmm1
movsd 0x70(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x9080
xorps %xmm1, %xmm1
cvtsi2sd %r14, %xmm1
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
xorps %xmm2, %xmm2
cvtsi2sd %rcx, %xmm2
cmpneqpd %xmm0, %xmm2
xorpd %xmm3, %xmm3
cmpnlepd %xmm0, %xmm3
andpd %xmm2, %xmm3
movq %xmm3, %rax
addq %rcx, %rax
movq 0x130(%rsp), %rcx
cmpq %rcx, %rax
jg 0xd19d
movq %rcx, %rax
movq 0x138(%rsp), %rcx
cmpq %rcx, %rax
jl 0xd1ad
movq %rcx, %rax
movsd 0x140(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0x128(%rsp), %xmm2
unpcklps 0x25fac(%rip), %xmm2    # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x25fb4(%rip), %xmm2    # 0x33190
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
divsd %xmm3, %xmm0
addsd %xmm1, %xmm0
callq 0x9040
mulsd 0x50(%rsp), %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
ucomisd 0x70(%rsp), %xmm0
jbe 0xd12d
decq %r14
jmp 0xd219
incq %r14
movq 0x120(%rsp), %rbp
cmpq %rbp, %r14
cmovlq %r14, %rbp
mulsd 0x140(%rsp), %xmm2
movsd 0x70(%rsp), %xmm0
divsd %xmm2, %xmm0
callq 0x9080
xorps %xmm1, %xmm1
cvtsi2sd %rbp, %xmm1
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
cmpneqpd %xmm0, %xmm2
xorpd %xmm3, %xmm3
cmpnlepd %xmm0, %xmm3
andpd %xmm2, %xmm3
movq %xmm3, %r14
addq %rax, %r14
movq 0x130(%rsp), %rax
movq 0x138(%rsp), %rcx
cmpq %rax, %r14
cmovleq %rax, %r14
cmpq %rcx, %r14
cmovgeq %rcx, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
movsd 0x128(%rsp), %xmm2
unpcklps 0x25ed7(%rip), %xmm2    # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
movsd 0x140(%rsp), %xmm3
movsd %xmm3, 0x70(%rsp)
subpd 0x25ed0(%rip), %xmm2    # 0x33190
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
divsd %xmm3, %xmm0
addsd %xmm1, %xmm0
callq 0x9040
mulsd 0x70(%rsp), %xmm0
testq %r13, %r13
je 0xd2f4
movapd %xmm0, %xmm1
divsd 0x8(%rsp), %xmm1
movsd %xmm1, (%r13)
testq %r12, %r12
je 0xd305
divsd 0x40(%rsp), %xmm0
movsd %xmm0, (%r12)
movq 0x18(%rsp), %r15
movq (%r15), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x9050
movq %rax, %r12
movq (%r15), %rsi
leaq 0x170(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rdx
callq 0x95f0
movq (%r14), %rax
movq %rax, 0x68(%rsp)
movq 0x8(%r14), %r15
movsd 0x10(%r14), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0xb0(%rsp), %xmm2
divpd %xmm0, %xmm2
movapd 0xa0(%rsp), %xmm3
divpd %xmm0, %xmm3
movapd 0x90(%rsp), %xmm4
divpd %xmm0, %xmm4
movdqa 0xc0(%rsp), %xmm1
movq %xmm1, (%r14)
movq %xmm1, 0x8(%r14)
movdqa 0x25d46(%rip), %xmm5    # 0x330d0
pxor %xmm1, %xmm5
pshufd $0x44, %xmm5, %xmm0     # xmm0 = xmm5[0,1,0,1]
movdqa %xmm0, 0x10(%r14)
movq %xmm5, 0x150(%rsp)
movq %xmm1, 0x158(%rsp)
movq %xmm1, 0x160(%rsp)
movdqa %xmm5, 0x70(%rsp)
movq %xmm5, 0x168(%rsp)
movapd 0x25dd5(%rip), %xmm5    # 0x331a0
movapd 0x25ddd(%rip), %xmm0    # 0x331b0
xorl %eax, %eax
movsd 0x150(%rsp,%rax,8), %xmm6
unpcklpd %xmm6, %xmm6            # xmm6 = xmm6[0,0]
mulpd %xmm3, %xmm6
movsd 0x170(%rsp,%rax,8), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm2, %xmm1
addpd %xmm6, %xmm1
addpd %xmm4, %xmm1
minpd %xmm1, %xmm0
maxpd %xmm1, %xmm5
incq %rax
cmpq $0x4, %rax
jne 0xd3d5
movapd %xmm4, 0x90(%rsp)
movapd %xmm3, 0xa0(%rsp)
movapd %xmm2, 0xb0(%rsp)
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
movapd %xmm5, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
callq 0x9880
movapd %xmm0, 0x20(%rsp)
movapd 0x40(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x9880
movapd 0x20(%rsp), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
addpd 0x25cf3(%rip), %xmm2    # 0x33160
cvttsd2si %xmm2, %r14
movq %r14, %xmm1
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
cvttsd2si %xmm2, %rax
movq %rax, %xmm0
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movdqa %xmm1, 0xf0(%rsp)
movapd 0x50(%rsp), %xmm0
callq 0x99c0
movsd 0x25dbb(%rip), %xmm1    # 0x33260
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x38(%rsp)
movapd 0x50(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x99c0
movsd 0x25d95(%rip), %xmm15   # 0x33260
addsd %xmm15, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x8(%rsp)
pshufd $0xee, 0xf0(%rsp), %xmm0 # xmm0 = mem[2,3,2,3]
movq %r14, 0x20(%rsp)
testq %r14, %r14
movq 0x68(%rsp), %r10
js 0xd52b
movq %r10, %rax
shlq $0x20, %rax
addq %r13, %rax
sarq $0x20, %rax
cmpq 0x38(%rsp), %rax
jl 0xd52b
movq %xmm0, %rax
testq %rax, %rax
js 0xd52b
movq %r15, %rax
shlq $0x20, %rax
addq %r13, %rax
sarq $0x20, %rax
cmpq 0x8(%rsp), %rax
jge 0xd8cd
movq 0x20(%rsp), %rdx
movq %rdx, %r14
negq %r14
xorl %eax, %eax
testq %r14, %r14
cmovleq %rax, %r14
movq %xmm0, %rcx
movq %rcx, %rsi
negq %rsi
testq %rsi, %rsi
movl $0x0, %r9d
movq %rsi, 0xd0(%rsp)
cmovgq %rsi, %r9
movq %r10, %rsi
shlq $0x20, %rsi
addq %r13, %rsi
sarq $0x20, %rsi
movq 0x38(%rsp), %rdi
movq %rdi, %rbp
movq %rsi, 0xd8(%rsp)
subq %rsi, %rbp
testq %rbp, %rbp
cmovleq %rax, %rbp
shlq $0x20, %r15
addq %r13, %r15
sarq $0x20, %r15
movq 0x8(%rsp), %r8
movq %r8, %rsi
subq %r15, %rsi
testq %rsi, %rsi
cmovleq %rax, %rsi
movq %rdi, %r13
subq %rdx, %r13
incq %r13
movq %rcx, 0x50(%rsp)
subq %rcx, %r8
movq %r8, 0xe0(%rsp)
leaq 0x1(%r8), %r15
movq %r15, %rdx
imulq %r13, %rdx
shlq $0x2, %rdx
movq 0x18(%rsp), %rax
cmpq 0x70(%rax), %rdx
jbe 0xd66d
movq %r9, 0x40(%rsp)
movq %rsi, 0x88(%rsp)
movq 0x18(%rsp), %rax
leaq 0x70(%rax), %rsi
leaq 0x68(%rax), %rdi
callq 0xb062
movl %eax, %ecx
testl %eax, %eax
je 0xd618
movl $0x2, %edi
xorl %esi, %esi
xorl %eax, %eax
movl %ecx, 0x14(%rsp)
callq 0x9150
movl 0x14(%rsp), %ecx
jmp 0xd618
movapd 0xc0(%rsp), %xmm11
movapd 0xb0(%rsp), %xmm12
movapd 0xa0(%rsp), %xmm13
movapd 0x90(%rsp), %xmm14
testl %ecx, %ecx
movsd 0x25c15(%rip), %xmm15   # 0x33260
movq 0x68(%rsp), %r10
movq 0x88(%rsp), %rsi
movq 0x40(%rsp), %r9
je 0xd669
xorl %ecx, %ecx
movq %r10, %r13
jmp 0xd8fa
movl %eax, 0x14(%rsp)
subq %rsi, %r15
cmpq %r15, %r9
jge 0xd856
movq %r15, 0x68(%rsp)
movq 0x50(%rsp), %rax
movq %r9, 0x40(%rsp)
addq %r9, %rax
movq %rsi, 0x88(%rsp)
movq 0x8(%rsp), %rcx
subq %rsi, %rcx
incq %rcx
cmpq %rcx, %rax
jge 0xd798
movq %rcx, %r11
movq 0x18(%rsp), %rcx
movq 0x68(%rcx), %rcx
movq %rcx, 0x8(%rsp)
xorl %edx, %edx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
cmovgq %rdi, %rdx
movq 0xd8(%rsp), %rcx
cmpq %rcx, %rdx
cmovgeq %rcx, %rdx
leaq (%r12,%rdx,4), %rdx
addq %rdi, %r14
notq %rbp
movq 0x38(%rsp), %rsi
addq %rsi, %rbp
incq %rsi
leaq 0x1(%rdi), %rcx
cmpq %rcx, %r14
cmovgq %r14, %rcx
movq %rcx, 0x38(%rsp)
movq 0x20(%rsp), %r12
movq %rax, %rdi
subq 0x50(%rsp), %rdi
imulq %r13, %rdi
movq %rax, %r8
movq %r10, %rcx
imulq %r10, %r8
movq 0x8(%rsp), %r9
leaq (%r9,%rdi,4), %rdi
leaq (%rdx,%r8,4), %r8
movq %r12, %r9
movq %r12, %r10
testq %r12, %r12
jns 0xd747
movd (%r8), %xmm0
movd %xmm0, (%rdi)
addq $0x4, %rdi
incq %r10
cmpq %r14, %r10
jl 0xd72d
movq 0x38(%rsp), %r9
cmpq %rbp, %r9
jge 0xd768
movd (%r8), %xmm0
addq $0x4, %r8
movd %xmm0, (%rdi)
addq $0x4, %rdi
incq %r9
cmpq %rbp, %r9
jl 0xd74c
movq %rbp, %r9
cmpq %rsi, %r9
jge 0xd789
movq %rsi, %r10
subq %r9, %r10
xorl %r9d, %r9d
movd (%r8), %xmm0
movd %xmm0, (%rdi,%r9,4)
incq %r9
cmpq %r9, %r10
jne 0xd776
incq %rax
cmpq %r11, %rax
movq %rcx, %r10
jl 0xd6ff
cmpq $0x0, 0x50(%rsp)
movq 0x18(%rsp), %r14
jns 0xd7fd
movq 0x40(%rsp), %rax
imulq %r13, %rax
movq %rax, 0x40(%rsp)
leaq (,%r13,4), %rax
movq %rax, 0x20(%rsp)
movq 0xd0(%rsp), %rax
cmpq $0x2, %rax
movl $0x1, %r12d
cmovgeq %rax, %r12
xorl %ebp, %ebp
movq 0x20(%rsp), %r15
movq 0x68(%r14), %rdi
movq 0x40(%rsp), %rax
leaq (%rdi,%rax,4), %rsi
addq %rbp, %rdi
movq %r15, %rdx
callq 0x95a0
addq %r15, %rbp
decq %r12
jne 0xd7dd
movq 0x68(%rsp), %r15
cmpq 0xe0(%rsp), %r15
movq %r14, %rbp
movq 0x88(%rsp), %r12
jg 0xd86a
leaq -0x1(%r15), %rax
imulq %r13, %rax
movq %rax, 0x20(%rsp)
leaq (,%r13,4), %r14
imulq %r13, %r15
shlq $0x2, %r15
movq 0x68(%rbp), %rdi
movq 0x20(%rsp), %rax
leaq (%rdi,%rax,4), %rsi
addq %r15, %rdi
movq %r14, %rdx
callq 0x95a0
addq %r14, %r15
decq %r12
jne 0xd834
jmp 0xd86a
movq 0x18(%rsp), %rbp
movq 0x68(%rbp), %rdi
movq 0x70(%rbp), %rdx
xorl %esi, %esi
callq 0x9400
movdqa 0xf0(%rsp), %xmm0
movq %xmm0, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
cvtsi2sdq 0x50(%rsp), %xmm1
movq 0x68(%rbp), %r12
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd 0x90(%rsp), %xmm14
subpd %xmm0, %xmm14
movb $0x1, %cl
movapd 0xc0(%rsp), %xmm11
movapd 0xb0(%rsp), %xmm12
movapd 0xa0(%rsp), %xmm13
movsd 0x25999(%rip), %xmm15   # 0x33260
movl 0x14(%rsp), %eax
jmp 0xd8fa
movb $0x1, %cl
movq %r10, %r13
movapd 0xc0(%rsp), %xmm11
movapd 0xb0(%rsp), %xmm12
movapd 0xa0(%rsp), %xmm13
movapd 0x90(%rsp), %xmm14
testb %cl, %cl
je 0xda9e
movq 0xe8(%rsp), %rax
testl %eax, %eax
js 0xda9c
movq %rax, %xmm0
punpckldq 0x25861(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x25869(%rip), %xmm0    # 0x33190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm11
leal 0x1(,%rax,2), %ecx
cmpl $0x2, %ecx
movl $0x1, %eax
cmovgel %ecx, %eax
xorl %ecx, %ecx
movapd 0x70(%rsp), %xmm0
movapd %xmm0, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd %xmm13, %xmm1
addpd %xmm14, %xmm1
movq %rax, %rdx
movapd 0x70(%rsp), %xmm2
movapd %xmm2, %xmm3
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
mulpd %xmm12, %xmm3
addpd %xmm1, %xmm3
cvttsd2si %xmm3, %rsi
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
cvttsd2si %xmm4, %rdi
movq %rsi, %xmm6
xorps %xmm5, %xmm5
cvtsi2sd %rsi, %xmm5
movq %rdi, %xmm7
xorpd %xmm8, %xmm8
xorps %xmm9, %xmm9
cvtsi2sd %rdi, %xmm9
punpcklqdq %xmm7, %xmm6    # xmm6 = xmm6[0],xmm7[0]
cmpnlepd %xmm3, %xmm8
unpcklpd %xmm9, %xmm5            # xmm5 = xmm5[0],xmm9[0]
cmpneqpd %xmm3, %xmm5
andpd %xmm8, %xmm5
paddq %xmm6, %xmm5
pshufd $0xee, %xmm5, %xmm6     # xmm6 = xmm5[2,3,2,3]
movq %xmm6, %rsi
leaq 0x1(%rsi), %rdi
xorps %xmm6, %xmm6
cvtsi2sd %rsi, %xmm6
imulq %r13, %rsi
movq %xmm5, %r8
addq %r8, %rsi
xorps %xmm5, %xmm5
cvtss2sd (%r12,%rsi,4), %xmm5
imulq %r13, %rdi
addq %r8, %rdi
xorps %xmm7, %xmm7
cvtss2sd 0x4(%r12,%rsi,4), %xmm7
xorps %xmm8, %xmm8
cvtss2sd (%r12,%rdi,4), %xmm8
xorps %xmm9, %xmm9
cvtss2sd 0x4(%r12,%rdi,4), %xmm9
xorps %xmm10, %xmm10
cvtsi2sd %r8, %xmm10
subsd %xmm10, %xmm3
subsd %xmm6, %xmm4
movapd %xmm15, %xmm6
movapd %xmm15, %xmm10
subsd %xmm4, %xmm6
subsd %xmm3, %xmm10
mulsd %xmm3, %xmm7
mulsd %xmm10, %xmm5
addsd %xmm7, %xmm5
mulsd %xmm9, %xmm3
mulsd %xmm8, %xmm10
addsd %xmm3, %xmm10
mulsd %xmm6, %xmm5
mulsd %xmm4, %xmm10
addsd %xmm5, %xmm10
xorps %xmm3, %xmm3
cvtsd2ss %xmm10, %xmm3
movss %xmm3, (%rbx)
addq $0x4, %rbx
addsd %xmm11, %xmm2
decq %rdx
jne 0xd96d
addsd %xmm11, %xmm0
incq %rcx
cmpq %rax, %rcx
jne 0xd952
xorl %eax, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq