// File: /workspace/github_c_makefile_star2_O3/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 $0x188, %rsp            # imm = 0x188
movsd %xmm3, 0x10(%rsp)
movsd %xmm2, (%rsp)
movsd %xmm1, 0x50(%rsp)
movaps %xmm0, 0xe0(%rsp)
movq %r8, 0x78(%rsp)
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r13
movq 0x1c0(%rsp), %rax
movups (%r9), %xmm0
movaps %xmm0, 0xa0(%rsp)
movups 0x10(%r9), %xmm0
movaps %xmm0, 0x90(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x80(%rsp)
movq %rdi, 0x8(%rsp)
movq (%rdi), %rsi
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x98c0
movsd (%rsp), %xmm0
minsd 0x10(%rsp), %xmm0
movsd 0x250e3(%rip), %xmm2    # 0x32270
divsd %xmm0, %xmm2
movq 0x10(%r14), %r14
movsd %xmm2, 0x40(%rsp)
movq 0x110(%rsp), %rbp
cmpq %rbp, %r14
jge 0xd28f
incq %r14
movsd 0x130(%rsp), %xmm1
mulsd %xmm2, %xmm1
movsd 0x50(%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 0x120(%rsp), %rcx
cmpq %rcx, %rax
jg 0xd20e
movq %rcx, %rax
movq 0x128(%rsp), %rcx
cmpq %rcx, %rax
jl 0xd21e
movq %rcx, %rax
movsd 0x130(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0x118(%rsp), %xmm2
unpcklps 0x24f3b(%rip), %xmm2    # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x24f43(%rip), %xmm2    # 0x32190
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
divsd %xmm3, %xmm0
addsd %xmm1, %xmm0
callq 0x9040
mulsd 0x20(%rsp), %xmm0
movsd 0x40(%rsp), %xmm2
mulsd %xmm2, %xmm0
ucomisd 0x50(%rsp), %xmm0
jbe 0xd19b
movq 0x110(%rsp), %rbp
decq %r14
jmp 0xd292
incq %r14
cmpq %rbp, %r14
cmovlq %r14, %rbp
mulsd 0x130(%rsp), %xmm2
movsd 0x50(%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 0x120(%rsp), %rax
movq 0x128(%rsp), %rcx
cmpq %rax, %r14
cmovleq %rax, %r14
cmpq %rcx, %r14
cmovgeq %rcx, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
movsd 0x118(%rsp), %xmm2
unpcklps 0x24e66(%rip), %xmm2    # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
movsd 0x130(%rsp), %xmm3
movsd %xmm3, 0x50(%rsp)
subpd 0x24e5f(%rip), %xmm2    # 0x32190
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
testq %r13, %r13
je 0xd364
movapd %xmm0, %xmm1
divsd (%rsp), %xmm1
movsd %xmm1, (%r13)
testq %r12, %r12
je 0xd375
divsd 0x10(%rsp), %xmm0
movsd %xmm0, (%r12)
movq 0x8(%rsp), %r15
movq (%r15), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x9050
movq %rax, %r12
movq (%r15), %rsi
leaq 0x160(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rdx
callq 0x95f0
movq (%r14), %rax
movq %rax, 0x38(%rsp)
movq 0x8(%r14), %r13
movsd 0x10(%r14), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0xa0(%rsp), %xmm2
divpd %xmm0, %xmm2
movapd 0x90(%rsp), %xmm3
divpd %xmm0, %xmm3
movapd 0x80(%rsp), %xmm4
divpd %xmm0, %xmm4
movdqa 0xe0(%rsp), %xmm1
movq %xmm1, (%r14)
movq %xmm1, 0x8(%r14)
movdqa 0x24cd6(%rip), %xmm5    # 0x320d0
pxor %xmm1, %xmm5
pshufd $0x44, %xmm5, %xmm0     # xmm0 = xmm5[0,1,0,1]
movdqa %xmm0, 0x10(%r14)
movq %xmm5, 0x140(%rsp)
movq %xmm1, 0x148(%rsp)
movq %xmm1, 0x150(%rsp)
movdqa %xmm5, 0x50(%rsp)
movq %xmm5, 0x158(%rsp)
movapd 0x24d65(%rip), %xmm5    # 0x321a0
movapd 0x24d6d(%rip), %xmm0    # 0x321b0
xorl %eax, %eax
movsd 0x140(%rsp,%rax,8), %xmm6
unpcklpd %xmm6, %xmm6            # xmm6 = xmm6[0,0]
mulpd %xmm3, %xmm6
movsd 0x160(%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 0xd445
movapd %xmm4, 0x80(%rsp)
movapd %xmm3, 0x90(%rsp)
movapd %xmm2, 0xa0(%rsp)
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
movapd %xmm5, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
callq 0x9880
movapd %xmm0, 0x40(%rsp)
movapd 0x10(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x9880
movapd 0x40(%rsp), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
addpd 0x24c83(%rip), %xmm2    # 0x32160
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, 0xd0(%rsp)
movapd 0x20(%rsp), %xmm0
callq 0x99c0
movsd 0x24d5b(%rip), %xmm1    # 0x32270
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, (%rsp)
movapd 0x20(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x99c0
movq %r14, %r9
movsd 0x24d33(%rip), %xmm15   # 0x32270
addsd %xmm15, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x70(%rsp)
movq 0x38(%rsp), %r11
leal -0x1(%r11), %eax
movslq %eax, %r10
pshufd $0xee, 0xd0(%rsp), %xmm0 # xmm0 = mem[2,3,2,3]
testq %r14, %r14
js 0xd590
cmpq %r10, (%rsp)
jg 0xd590
movq %xmm0, %rax
testq %rax, %rax
js 0xd590
movq %r13, %rax
shlq $0x20, %rax
addq %rbp, %rax
sarq $0x20, %rax
cmpq 0x70(%rsp), %rax
jge 0xd97b
movq %r9, %r14
negq %r14
xorl %eax, %eax
testq %r14, %r14
cmovleq %rax, %r14
movq %xmm0, %rcx
movq %rcx, %rdx
negq %rdx
testq %rdx, %rdx
movl $0x0, %r8d
movq %rdx, 0xc0(%rsp)
cmovgq %rdx, %r8
movq (%rsp), %rdx
movq %rdx, %r15
subq %r10, %r15
testq %r15, %r15
cmovleq %rax, %r15
shlq $0x20, %r13
addq %rbp, %r13
sarq $0x20, %r13
movq 0x70(%rsp), %rdi
movq %rdi, %rsi
subq %r13, %rsi
testq %rsi, %rsi
cmovleq %rax, %rsi
movq %rdx, %r13
subq %r9, %r13
incq %r13
movq %rcx, 0x20(%rsp)
subq %rcx, %rdi
movq %rdi, 0xc8(%rsp)
leaq 0x1(%rdi), %rbp
movq %rbp, %rdx
imulq %r13, %rdx
shlq $0x2, %rdx
movq 0x8(%rsp), %rax
cmpq 0x70(%rax), %rdx
movq %r9, 0x40(%rsp)
jbe 0xd677
movq %rsi, 0x68(%rsp)
leaq 0x70(%rax), %rsi
leaq 0x68(%rax), %rdi
movq %r8, 0x10(%rsp)
movq %r10, 0xb8(%rsp)
callq 0xb06e
movq 0xb8(%rsp), %r10
movq 0x10(%rsp), %r8
movq 0x68(%rsp), %rsi
movq 0x40(%rsp), %r9
movq 0x38(%rsp), %r11
testl %eax, %eax
je 0xd677
movl $0x2, %edi
xorl %esi, %esi
xorl %eax, %eax
callq 0x9150
jmp 0xdb3f
subq %rsi, %rbp
cmpq %rbp, %r8
jge 0xd922
movq %rbp, 0x38(%rsp)
movq 0x20(%rsp), %rax
movq %r8, 0x10(%rsp)
addq %r8, %rax
movq %rsi, 0x68(%rsp)
movq 0x70(%rsp), %rcx
subq %rsi, %rcx
incq %rcx
cmpq %rcx, %rax
jge 0xd869
movq %rcx, %rsi
movq 0x8(%rsp), %rcx
movq 0x68(%rcx), %rcx
xorl %edx, %edx
testq %r9, %r9
cmovgq %r9, %rdx
cmpq %r10, %rdx
cmovgeq %r10, %rdx
leaq (%r12,%rdx,4), %rdx
addq %r9, %r14
notq %r15
movq (%rsp), %r12
addq %r12, %r15
incq %r12
leaq 0x1(%r9), %rdi
cmpq %rdi, %r14
cmovgq %r14, %rdi
movq %rdi, (%rsp)
movdqa 0x24acb(%rip), %xmm0    # 0x321c0
movdqa 0x24903(%rip), %xmm1    # 0x32000
movdqa 0x2490b(%rip), %xmm2    # 0x32010
pcmpeqd %xmm3, %xmm3
movq %rax, %rdi
subq 0x20(%rsp), %rdi
imulq %r13, %rdi
movq %rax, %r8
imulq %r11, %r8
leaq (%rcx,%rdi,4), %rdi
leaq (%rdx,%r8,4), %r8
testq %r9, %r9
jns 0xd742
movss (%r8), %xmm4
movss %xmm4, (%rdi)
addq $0x4, %rdi
incq %r9
cmpq %r14, %r9
jl 0xd72e
movq (%rsp), %r9
cmpq %r15, %r9
jge 0xd763
movss (%r8), %xmm4
addq $0x4, %r8
movss %xmm4, (%rdi)
addq $0x4, %rdi
incq %r9
cmpq %r15, %r9
jl 0xd747
movq %r15, %r9
cmpq %r12, %r9
jge 0xd858
movss (%r8), %xmm4
movq %r12, %r10
subq %r9, %r10
leaq 0x3(%r10), %r8
andq $-0x4, %r8
decq %r10
movq %r10, %xmm5
pshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
pxor %xmm2, %xmm5
xorl %r9d, %r9d
movq %r9, %xmm6
pshufd $0x44, %xmm6, %xmm6     # xmm6 = xmm6[0,1,0,1]
movdqa %xmm6, %xmm7
por %xmm1, %xmm7
pxor %xmm2, %xmm7
movdqa %xmm7, %xmm8
pcmpgtd %xmm5, %xmm8
pcmpeqd %xmm5, %xmm7
pshufd $0xf5, %xmm7, %xmm9     # xmm9 = xmm7[1,1,3,3]
pand %xmm8, %xmm9
pshufd $0xf5, %xmm8, %xmm7     # xmm7 = xmm8[1,1,3,3]
por %xmm9, %xmm7
movd %xmm7, %r10d
notl %r10d
testb $0x1, %r10b
je 0xd7e1
movss %xmm4, (%rdi,%r9,4)
pxor %xmm3, %xmm7
pextrw $0x4, %xmm7, %r10d
testb $0x1, %r10b
je 0xd7f8
movss %xmm4, 0x4(%rdi,%r9,4)
por %xmm0, %xmm6
pxor %xmm2, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm5, %xmm7
pcmpeqd %xmm5, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm3, %xmm6
pextrw $0x0, %xmm6, %r10d
testb $0x1, %r10b
je 0xd838
movss %xmm4, 0x8(%rdi,%r9,4)
pextrw $0x4, %xmm6, %r10d
testb $0x1, %r10b
je 0xd84b
movss %xmm4, 0xc(%rdi,%r9,4)
addq $0x4, %r9
cmpq %r9, %r8
jne 0xd793
incq %rax
cmpq %rsi, %rax
movq 0x40(%rsp), %r9
jl 0xd709
cmpq $0x0, 0x20(%rsp)
movq 0x8(%rsp), %rcx
jns 0xd8cb
movq 0x10(%rsp), %rax
imulq %r13, %rax
movq %rax, 0x10(%rsp)
leaq (,%r13,4), %r14
movq 0xc0(%rsp), %rax
cmpq $0x2, %rax
movl $0x1, %r15d
cmovgeq %rax, %r15
xorl %r12d, %r12d
movq 0x68(%rcx), %rdi
movq 0x10(%rsp), %rax
leaq (%rdi,%rax,4), %rsi
addq %r12, %rdi
movq %r14, %rdx
movq %rcx, %rbp
callq 0x95a0
movq %rbp, %rcx
addq %r14, %r12
decq %r15
jne 0xd8a5
movq 0x38(%rsp), %rbp
cmpq 0xc8(%rsp), %rbp
movq %rcx, %r12
movq 0x68(%rsp), %r15
jg 0xd938
leaq -0x1(%rbp), %rax
imulq %r13, %rax
movq %rax, 0x40(%rsp)
leaq (,%r13,4), %r14
imulq %r13, %rbp
shlq $0x2, %rbp
movq 0x68(%r12), %rdi
movq 0x40(%rsp), %rax
leaq (%rdi,%rax,4), %rsi
addq %rbp, %rdi
movq %r14, %rdx
callq 0x95a0
addq %r14, %rbp
decq %r15
jne 0xd8ff
jmp 0xd938
movq 0x8(%rsp), %r12
movq 0x68(%r12), %rdi
movq 0x70(%r12), %rdx
xorl %esi, %esi
callq 0x9400
movq 0x68(%r12), %r12
movdqa 0xd0(%rsp), %xmm0
movq %xmm0, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x20(%rsp), %xmm1
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd 0x80(%rsp), %xmm14
subpd %xmm0, %xmm14
movsd 0x248f7(%rip), %xmm15   # 0x32270
jmp 0xd988
movq %r11, %r13
movapd 0x80(%rsp), %xmm14
movq 0x78(%rsp), %rax
testl %eax, %eax
movapd 0xe0(%rsp), %xmm11
movapd 0xa0(%rsp), %xmm12
movapd 0x90(%rsp), %xmm13
js 0xdb3d
movq %rax, %xmm0
punpckldq 0x247c0(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x247c8(%rip), %xmm0    # 0x32190
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 0x50(%rsp), %xmm0
movapd %xmm0, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd %xmm13, %xmm1
addpd %xmm14, %xmm1
movq %rax, %rdx
movapd 0x50(%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
pxor %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 0xda0e
addsd %xmm11, %xmm0
incq %rcx
cmpq %rax, %rcx
jne 0xd9f3
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq