// File: /workspace/github_c_makefile_star2_O3/zpole[P]IICV/vl/slic.c
// Function: vl_slic_segment
void
vl_slic_segment (vl_uint32 * segmentation,
                 float const * image,
                 vl_size width,
                 vl_size height,
                 vl_size numChannels,
                 vl_size regionSize,
                 float regularization,
                 vl_size minRegionSize)
{
  vl_index i, x, y, u, v, k, region ;
  vl_uindex iter ;
  vl_size const numRegionsX = (vl_size) ceil((double) width / regionSize) ;
  vl_size const numRegionsY = (vl_size) ceil((double) height / regionSize) ;
  vl_size const numRegions = numRegionsX * numRegionsY ;
  vl_size const numPixels = width * height ;
  float * centers ;
  float * edgeMap ;
  float previousEnergy = VL_INFINITY_F ;
  float startingEnergy ;
  vl_uint32 * masses ;
  vl_size const maxNumIterations = 100 ;

  assert(segmentation) ;
  assert(image) ;
  assert(width >= 1) ;
  assert(height >= 1) ;
  assert(numChannels >= 1) ;
  assert(regionSize >= 1) ;
  assert(regularization >= 0) ;

#define atimage(x,y,k) image[(x)+(y)*width+(k)*width*height]
#define atEdgeMap(x,y) edgeMap[(x)+(y)*width]

  edgeMap = vl_calloc(numPixels, sizeof(float)) ;
  masses = vl_malloc(sizeof(vl_uint32) * numPixels) ;
  centers = vl_malloc(sizeof(float) * (2 + numChannels) * numRegions) ;

  /* compute edge map (gradient strength) */
  for (k = 0 ; k < (signed)numChannels ; ++k) {
    for (y = 1 ; y < (signed)height-1 ; ++y) {
      for (x = 1 ; x < (signed)width-1 ; ++x) {
        float a = atimage(x-1,y,k) ;
        float b = atimage(x+1,y,k) ;
        float c = atimage(x,y+1,k) ;
        float d = atimage(x,y-1,k) ;
        atEdgeMap(x,y) += (a - b)  * (a - b) + (c - d) * (c - d) ;
      }
    }
  }

  /* initialize K-means centers */
  i = 0 ;
  for (v = 0 ; v < (signed)numRegionsY ; ++v) {
    for (u = 0 ; u < (signed)numRegionsX ; ++u) {
      vl_index xp ;
      vl_index yp ;
      vl_index centerx = 0 ;
      vl_index centery = 0 ;
      float minEdgeValue = VL_INFINITY_F ;

      x = (vl_index) vl_round_d(regionSize * (u + 0.5)) ;
      y = (vl_index) vl_round_d(regionSize * (v + 0.5)) ;

      x = VL_MAX(VL_MIN(x, (signed)width-1),0) ;
      y = VL_MAX(VL_MIN(y, (signed)height-1),0) ;

      /* search in a 3x3 neighbourhood the smallest edge response */
      for (yp = VL_MAX(0, y-1) ; yp <= VL_MIN((signed)height-1, y+1) ; ++ yp) {
        for (xp = VL_MAX(0, x-1) ; xp <= VL_MIN((signed)width-1, x+1) ; ++ xp) {
          float thisEdgeValue = atEdgeMap(xp,yp) ;
          if (thisEdgeValue < minEdgeValue) {
            minEdgeValue = thisEdgeValue ;
            centerx = xp ;
            centery = yp ;
          }
        }
      }

      /* initialize the new center at this location */
      centers[i++] = (float) centerx ;
      centers[i++] = (float) centery ;
      for (k  = 0 ; k < (signed)numChannels ; ++k) {
        centers[i++] = atimage(centerx,centery,k) ;
      }
    }
  }

  /* run k-means iterations */
  for (iter = 0 ; iter < maxNumIterations ; ++iter) {
    float factor = regularization / (regionSize * regionSize) ;
    float energy = 0 ;

    /* assign pixels to centers */
    for (y = 0 ; y < (signed)height ; ++y) {
      for (x = 0 ; x < (signed)width ; ++x) {
        vl_index u = floor((double)x / regionSize - 0.5) ;
        vl_index v = floor((double)y / regionSize - 0.5) ;
        vl_index up, vp ;
        float minDistance = VL_INFINITY_F ;

        for (vp = VL_MAX(0, v) ; vp <= VL_MIN((signed)numRegionsY-1, v+1) ; ++vp) {
          for (up = VL_MAX(0, u) ; up <= VL_MIN((signed)numRegionsX-1, u+1) ; ++up) {
            vl_index region = up  + vp * numRegionsX ;
            float centerx = centers[(2 + numChannels) * region + 0]  ;
            float centery = centers[(2 + numChannels) * region + 1] ;
            float spatial = (x - centerx) * (x - centerx) + (y - centery) * (y - centery) ;
            float appearance = 0 ;
            float distance ;
            for (k = 0 ; k < (signed)numChannels ; ++k) {
              float centerz = centers[(2 + numChannels) * region + k + 2]  ;
              float z = atimage(x,y,k) ;
              appearance += (z - centerz) * (z - centerz) ;
            }
            distance = appearance + factor * spatial ;
            if (minDistance > distance) {
              minDistance = distance ;
              segmentation[x + y * width] = (vl_uint32)region ;
            }
          }
        }
        energy += minDistance ;
      }
    }

    /*
     VL_PRINTF("vl:slic: iter %d: energy: %g\n", iter, energy) ;
    */

    /* check energy termination conditions */
    if (iter == 0) {
      startingEnergy = energy ;
    } else {
      if ((previousEnergy - energy) < 1e-5 * (startingEnergy - energy)) {
        break ;
      }
    }
    previousEnergy = energy ;

    /* recompute centers */
    memset(masses, 0, sizeof(vl_uint32) * width * height) ;
    memset(centers, 0, sizeof(float) * (2 + numChannels) * numRegions) ;

    for (y = 0 ; y < (signed)height ; ++y) {
      for (x = 0 ; x < (signed)width ; ++x) {
        vl_index pixel = x + y * width ;
        vl_index region = segmentation[pixel] ;
        masses[region] ++ ;
        centers[region * (2 + numChannels) + 0] += x ;
        centers[region * (2 + numChannels) + 1] += y ;
        for (k = 0 ; k < (signed)numChannels ; ++k) {
          centers[region * (2 + numChannels) + k + 2] += atimage(x,y,k) ;
        }
      }
    }

    for (region = 0 ; region < (signed)numRegions ; ++region) {
      float mass = VL_MAX(masses[region], 1e-8) ;
      for (i = (2 + numChannels) * region ;
           i < (signed)(2 + numChannels) * (region + 1) ;
           ++i) {
        centers[i] /= mass ;
      }
    }
  }

  vl_free(masses) ;
  vl_free(centers) ;
  vl_free(edgeMap) ;

  /* elimiate small regions */
  {
    vl_uint32 * cleaned = vl_calloc(numPixels, sizeof(vl_uint32)) ;
    vl_uindex * segment = vl_malloc(sizeof(vl_uindex) * numPixels) ;
    vl_size segmentSize ;
    vl_uint32 label ;
    vl_uint32 cleanedLabel ;
    vl_size numExpanded ;
    vl_index const dx [] = {+1, -1,  0,  0} ;
    vl_index const dy [] = { 0,  0, +1, -1} ;
    vl_index direction ;
    vl_index pixel ;

    for (pixel = 0 ; pixel < (signed)numPixels ; ++pixel) {
      if (cleaned[pixel]) continue ;
      label = segmentation[pixel] ;
      numExpanded = 0 ;
      segmentSize = 0 ;
      segment[segmentSize++] = pixel ;

      /*
       find cleanedLabel as the label of an already cleaned
       region neihbour of this pixel
       */
      cleanedLabel = label + 1 ;
      cleaned[pixel] = label + 1 ;
      x = pixel % width ;
      y = pixel / width ;
      for (direction = 0 ; direction < 4 ; ++direction) {
        vl_index xp = x + dx[direction] ;
        vl_index yp = y + dy[direction] ;
        vl_index neighbor = xp + yp * width ;
        if (0 <= xp && xp < (signed)width &&
            0 <= yp && yp < (signed)height &&
            cleaned[neighbor]) {
          cleanedLabel = cleaned[neighbor] ;
        }
      }

      /* expand the segment */
      while (numExpanded < segmentSize) {
        vl_index open = segment[numExpanded++] ;
        x = open % width ;
        y = open / width ;
        for (direction = 0 ; direction < 4 ; ++direction) {
          vl_index xp = x + dx[direction] ;
          vl_index yp = y + dy[direction] ;
          vl_index neighbor = xp + yp * width ;
          if (0 <= xp && xp < (signed)width &&
              0 <= yp && yp < (signed)height &&
              cleaned[neighbor] == 0 &&
              segmentation[neighbor] == label) {
            cleaned[neighbor] = label + 1 ;
            segment[segmentSize++] = neighbor ;
          }
        }
      }

      /* change label to cleanedLabel if the semgent is too small */
      if (segmentSize < minRegionSize) {
        while (segmentSize > 0) {
          cleaned[segment[--segmentSize]] = cleanedLabel ;
        }
      }
    }
    /* restore base 0 indexing of the regions */
    for (pixel = 0 ; pixel < (signed)numPixels ; ++pixel) cleaned[pixel] -- ;

    memcpy(segmentation, cleaned, numPixels * sizeof(vl_uint32)) ;
    vl_free(cleaned) ;
    vl_free(segment) ;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movss %xmm0, 0x14(%rsp)
movq %r8, %rbp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x60(%rsp)
movq %rdi, 0x48(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq %rdx, %xmm1
movq 0x2f25(%rip), %xmm2     # 0x32180
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x2f29(%rip), %xmm3     # 0x32190
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r9, 0x98(%rsp)
movq %r9, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movapd %xmm2, 0xc0(%rsp)
divsd %xmm2, %xmm0
callq 0x99c0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x3952(%rip), %xmm0     # 0x32c10
cvttsd2si %xmm0, %r15
andq %rcx, %r15
orq %rax, %r15
movq %rbx, %xmm1
punpckldq 0x2eaa(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2eb2(%rip), %xmm1     # 0x32190
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0xc0(%rsp), %xmm0
callq 0x99c0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x3904(%rip), %xmm0     # 0x32c10
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %r15, 0x50(%rsp)
movq %rdx, 0x40(%rsp)
imulq %rdx, %r15
movq %rbx, 0x8(%rsp)
movq %r14, (%rsp)
imulq %r14, %rbx
movl $0x4, %esi
movq %rbx, %rdi
callq 0x98f0
movq %rax, 0x80(%rsp)
movq %rbx, 0xe0(%rsp)
leaq (,%rbx,4), %r12
movq %r12, %rdi
callq 0x95b0
movq %rax, 0x108(%rsp)
leaq 0x2(%rbp), %rax
movq %rax, 0x38(%rsp)
movq %rax, %rdi
movq %r15, 0x90(%rsp)
imulq %r15, %rdi
shlq $0x2, %rdi
movq %rdi, 0xf8(%rsp)
callq 0x95b0
movq %rax, %r13
movq %rbp, 0x88(%rsp)
movslq %ebp, %r14
testq %r14, %r14
jle 0x2f4a2
movq 0x8(%rsp), %rax
shlq $0x20, %rax
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %rsi, %rax
sarq $0x20, %rax
movq (%rsp), %rdx
movq %rdx, %rcx
shlq $0x20, %rcx
addq %rsi, %rcx
sarq $0x20, %rcx
movq 0x80(%rsp), %rsi
addq $0x4, %rsi
movq %rsi, 0x30(%rsp)
leaq (,%rdx,4), %r9
leaq -0x1(%rcx), %rdi
movq 0x60(%rsp), %r10
leaq 0x4(%r10), %r8
xorl %edx, %edx
movq %rdx, 0x18(%rsp)
cmpq $0x2, %rax
jl 0x2f48b
movl $0x1, %r11d
cmpq $0x1, %rcx
jle 0x2f480
leaq 0x1(%r11), %rbx
movq %r9, %r15
imulq %r11, %r15
decq %r11
movq 0x30(%rsp), %rdx
leaq (%rdx,%r15), %rbp
addq %r10, %r15
imulq %r9, %r11
addq %r8, %r11
movq %r9, %rsi
imulq %rbx, %rsi
addq %r8, %rsi
xorl %edx, %edx
movss (%r15,%rdx,4), %xmm0
subss 0x8(%r15,%rdx,4), %xmm0
movss (%rsi,%rdx,4), %xmm1
subss (%r11,%rdx,4), %xmm1
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
addss (%rbp,%rdx,4), %xmm0
movss %xmm0, (%rbp,%rdx,4)
incq %rdx
cmpq %rdx, %rdi
jne 0x2f443
movq %rbx, %r11
jmp 0x2f486
incq %r11
movq %r11, %rbx
cmpq %rax, %rbx
jne 0x2f410
movq 0x18(%rsp), %rdx
incq %rdx
addq %r12, %r10
addq %r12, %r8
cmpq %r14, %rdx
jne 0x2f3fb
movslq 0x40(%rsp), %rax
movq %rax, 0xa0(%rsp)
testq %rax, %rax
movss 0x14(%rsp), %xmm1
jle 0x2f708
movq 0x50(%rsp), %rax
movq %rax, %rcx
shlq $0x20, %rcx
movq %rcx, 0x68(%rsp)
cltq
movq %rax, 0x18(%rsp)
movq (%rsp), %rcx
movq %rcx, %rax
shlq $0x20, %rax
movq %rax, 0x20(%rsp)
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
addq %rdx, %rax
sarq $0x20, %rax
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %rax
shlq $0x20, %rax
movq %rax, 0x8(%rsp)
addq %rdx, %rax
sarq $0x20, %rax
movq %rax, 0x70(%rsp)
leaq (,%rcx,4), %rbx
xorl %ebp, %ebp
xorl %ecx, %ecx
cmpq $0x0, 0x18(%rsp)
movq %rcx, 0xa8(%rsp)
jle 0x2f6e7
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
addsd 0x2c9a(%rip), %xmm0     # 0x321e0
mulsd 0xc0(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x30(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
addsd 0x2c71(%rip), %xmm0     # 0x321e0
mulsd 0xc0(%rsp), %xmm0
callq 0x9230
movq %rax, %r15
movsd 0xb0(%rsp), %xmm0
callq 0x9230
movq 0x70(%rsp), %rsi
cmpq %rsi, %rax
cmovgeq %rsi, %rax
testq %rax, %rax
movl $0x0, %edx
cmovgq %rax, %rdx
cmpq $0x2, %rax
movl $0x1, %ecx
cmovlq %rcx, %rax
decq %rax
leaq 0x1(%rdx), %rcx
cmpq %rdx, %rsi
cmovleq %rsi, %rcx
movl $0x0, %edx
movl $0x0, %esi
cmpq %rcx, %rax
jg 0x2f66f
movq 0x28(%rsp), %rsi
cmpq %rsi, %r15
cmovgeq %rsi, %r15
testq %r15, %r15
movl $0x0, %edx
cmovgq %r15, %rdx
cmpq $0x2, %r15
movl $0x1, %edi
cmovlq %rdi, %r15
decq %r15
leaq 0x1(%rdx), %rdi
cmpq %rdx, %rsi
cmovleq %rsi, %rdi
movq %rdi, %r8
negq %r8
movq %rbx, %r9
imulq %rax, %r9
addq 0x80(%rsp), %r9
xorl %esi, %esi
xorl %edx, %edx
movss 0x2c80(%rip), %xmm0     # 0x322a8
cmpq %rdi, %r15
jle 0x2f632
movaps %xmm0, %xmm1
jmp 0x2f65d
movq %r15, %r10
movss (%r9,%r10,4), %xmm1
ucomiss %xmm1, %xmm0
cmovaq %rax, %rdx
minss %xmm0, %xmm1
cmovaq %r10, %rsi
leaq (%r8,%r10), %r11
incq %r11
incq %r10
movaps %xmm1, %xmm0
cmpq $0x1, %r11
jne 0x2f635
leaq 0x1(%rax), %r10
addq %rbx, %r9
movaps %xmm1, %xmm0
cmpq %rcx, %rax
movq %r10, %rax
jne 0x2f628
xorps %xmm0, %xmm0
cvtsi2ss %rsi, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %rdx, %xmm1
leaq 0x2(%rbp), %rax
movss %xmm0, (%r13,%rbp,4)
movss %xmm1, 0x4(%r13,%rbp,4)
testq %r14, %r14
jle 0x2f6c9
imulq (%rsp), %rdx
movq 0x60(%rsp), %rcx
leaq (%rcx,%rsi,4), %rcx
leaq (%rcx,%rdx,4), %rcx
movq %r14, %rdx
movss 0x14(%rsp), %xmm1
movss (%rcx), %xmm0
movss %xmm0, (%r13,%rax,4)
incq %rax
addq %r12, %rcx
decq %rdx
jne 0x2f6b1
jmp 0x2f6cf
movss 0x14(%rsp), %xmm1
movq 0x30(%rsp), %rcx
incq %rcx
movq %rax, %rbp
cmpq 0x18(%rsp), %rcx
jne 0x2f55a
jmp 0x2f6ea
movq %rbp, %rax
movq 0xa8(%rsp), %rcx
incq %rcx
movq %rax, %rbp
cmpq 0xa0(%rsp), %rcx
jne 0x2f522
jmp 0x2f729
shlq $0x20, 0x8(%rsp)
movq (%rsp), %rax
shlq $0x20, %rax
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rax
shlq $0x20, %rax
movq %rax, 0x68(%rsp)
shlq $0x20, 0x40(%rsp)
movq 0x98(%rsp), %rcx
imulq %rcx, %rcx
testq %rcx, %rcx
movq 0x48(%rsp), %rbx
js 0x2f74f
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
jmp 0x2f767
movq %rcx, %rax
shrq %rax
andl $0x1, %ecx
orq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
divss %xmm0, %xmm1
movss %xmm1, 0x14(%rsp)
sarq $0x20, 0x8(%rsp)
sarq $0x20, 0x20(%rsp)
movq 0x40(%rsp), %rax
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rcx, %rax
sarq $0x20, %rax
movq %rax, 0x40(%rsp)
movq 0x68(%rsp), %rbp
addq %rcx, %rbp
sarq $0x20, %rbp
movq %rbp, 0x68(%rsp)
movslq 0x90(%rsp), %rbp
movq 0x38(%rsp), %rcx
movslq %ecx, %rax
movq %rax, 0xf0(%rsp)
movq (%rsp), %rax
leaq (,%rax,4), %rax
movq %rax, 0xd8(%rsp)
leaq 0x8(%r13), %rax
movq %rax, 0x98(%rsp)
leaq (,%rcx,4), %rax
movq %rax, 0x90(%rsp)
movq 0x50(%rsp), %rax
imulq %rcx, %rax
shlq $0x2, %rax
movq %rax, 0xb0(%rsp)
movq 0x88(%rsp), %rax
leaq 0x8(,%rax,4), %rax
movq %rax, 0x30(%rsp)
movss 0x2a85(%rip), %xmm0     # 0x322a8
movq $0x0, 0x78(%rsp)
movss %xmm0, 0x5c(%rsp)
movq %rbp, 0x100(%rsp)
cmpq $0x0, 0x8(%rsp)
jle 0x2fa94
xorps %xmm7, %xmm7
movq 0x60(%rsp), %rbp
xorl %r15d, %r15d
cmpq $0x0, 0x20(%rsp)
movq %rbp, 0x88(%rsp)
movq %r15, 0x110(%rsp)
jle 0x2fa67
xorps %xmm0, %xmm0
cvtsi2sd %r15, %xmm0
divsd 0xc0(%rsp), %xmm0
addsd 0x29a2(%rip), %xmm0     # 0x32228
movss %xmm7, 0x28(%rsp)
callq 0x9880
movss 0x28(%rsp), %xmm7
movss 0x2a09(%rip), %xmm6     # 0x322a8
cvttsd2si %xmm0, %rax
testq %rax, %rax
movl $0x0, %edx
cmovgq %rax, %rdx
leaq 0x1(%rax), %rsi
movq 0x40(%rsp), %rcx
cmpq %rax, %rcx
cmovleq %rcx, %rsi
movq %rsi, 0x18(%rsp)
xorps %xmm8, %xmm8
cvtsi2ss %r15, %xmm8
movq %r15, %rax
imulq (%rsp), %rax
leaq (%rbx,%rax,4), %rbx
movq 0x50(%rsp), %rax
movq %rdx, 0x70(%rsp)
imulq %rdx, %rax
movq %rax, 0xa0(%rsp)
xorl %r15d, %r15d
movss %xmm8, 0xa8(%rsp)
movaps %xmm6, %xmm1
movq 0x18(%rsp), %rax
cmpq %rax, 0x70(%rsp)
jg 0x2fa51
xorps %xmm0, %xmm0
cvtsi2sd %r15, %xmm0
divsd 0xc0(%rsp), %xmm0
addsd 0x28ff(%rip), %xmm0     # 0x32228
movss %xmm7, 0x28(%rsp)
callq 0x9880
movss 0xa8(%rsp), %xmm8
movss 0x28(%rsp), %xmm7
movss 0x295c(%rip), %xmm6     # 0x322a8
movss 0x14(%rsp), %xmm5
cvttsd2si %xmm0, %rdx
testq %rdx, %rdx
movl $0x0, %eax
cmovgq %rdx, %rax
leaq 0x1(%rdx), %rcx
movq 0x68(%rsp), %rsi
cmpq %rdx, %rsi
cmovleq %rsi, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %r15, %xmm0
movq 0xa0(%rsp), %rdx
addq %rax, %rdx
imulq 0x90(%rsp), %rdx
addq 0x98(%rsp), %rdx
movq 0x70(%rsp), %rsi
movaps %xmm6, %xmm1
cmpq %rcx, %rax
jg 0x2fa37
movq %rsi, %rdi
imulq 0x50(%rsp), %rdi
movq %rdx, %r8
movq %rax, %r9
xorpd %xmm2, %xmm2
testq %r14, %r14
jle 0x2f9e4
movq %rbp, %r10
xorl %r11d, %r11d
movss (%r10), %xmm3
subss (%r8,%r11,4), %xmm3
mulss %xmm3, %xmm3
addss %xmm3, %xmm2
incq %r11
addq %r12, %r10
cmpq %r11, %r14
jne 0x2f9c6
leaq (%r9,%rdi), %r10
movq %r10, %r11
imulq 0x38(%rsp), %r11
movaps %xmm0, %xmm3
subss (%r13,%r11,4), %xmm3
movaps %xmm8, %xmm4
subss 0x4(%r13,%r11,4), %xmm4
mulss %xmm4, %xmm4
mulss %xmm3, %xmm3
addss %xmm4, %xmm3
mulss %xmm5, %xmm3
addss %xmm2, %xmm3
ucomiss %xmm3, %xmm1
jbe 0x2fa26
movl %r10d, (%rbx,%r15,4)
movaps %xmm3, %xmm1
leaq 0x1(%r9), %r10
addq 0x30(%rsp), %r8
cmpq %rcx, %r9
movq %r10, %r9
jne 0x2f9b7
leaq 0x1(%rsi), %rdi
addq 0xb0(%rsp), %rdx
cmpq 0x18(%rsp), %rsi
movq %rdi, %rsi
jne 0x2f99f
addss %xmm1, %xmm7
incq %r15
addq $0x4, %rbp
cmpq 0x20(%rsp), %r15
jne 0x2f8fd
movq 0x110(%rsp), %r15
incq %r15
movq 0x88(%rsp), %rbp
addq 0xd8(%rsp), %rbp
cmpq 0x8(%rsp), %r15
movq 0x48(%rsp), %rbx
jne 0x2f851
jmp 0x2fa97
xorps %xmm7, %xmm7
movaps %xmm7, %xmm2
cmpq $0x0, 0x78(%rsp)
movq 0x108(%rsp), %r15
movq 0x100(%rsp), %rbp
je 0x2fae6
movss 0x5c(%rsp), %xmm0
subss %xmm7, %xmm0
cvtss2sd %xmm0, %xmm0
movss 0xbc(%rsp), %xmm2
movaps %xmm2, %xmm1
subss %xmm7, %xmm1
cvtss2sd %xmm1, %xmm1
mulsd 0x2a14(%rip), %xmm1     # 0x324f0
ucomisd %xmm0, %xmm1
ja 0x2fc5a
movss %xmm2, 0x18(%rsp)
movss %xmm7, 0x28(%rsp)
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x9400
movq %r13, %rdi
xorl %esi, %esi
movq 0xf8(%rsp), %rdx
callq 0x9400
cmpq $0x0, 0x8(%rsp)
jle 0x2fbca
movq 0x60(%rsp), %rax
xorl %ecx, %ecx
cmpq $0x0, 0x20(%rsp)
jle 0x2fbb4
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
movq %rcx, %rdx
imulq (%rsp), %rdx
movq %rax, %rsi
xorl %edi, %edi
leaq (%rdi,%rdx), %r8
movl (%rbx,%r8,4), %r8d
incl (%r15,%r8,4)
imulq 0x38(%rsp), %r8
xorps %xmm1, %xmm1
cvtsi2ss %rdi, %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movsd (%r13,%r8,4), %xmm2
addps %xmm1, %xmm2
movlps %xmm2, (%r13,%r8,4)
testq %r14, %r14
jle 0x2fba6
leaq (,%r8,4), %r8
addq %r13, %r8
movq %rsi, %r9
xorl %r10d, %r10d
movss (%r9), %xmm1
addss 0x8(%r8,%r10,4), %xmm1
movss %xmm1, 0x8(%r8,%r10,4)
incq %r10
addq %r12, %r9
cmpq %r10, %r14
jne 0x2fb88
incq %rdi
addq $0x4, %rsi
cmpq 0x20(%rsp), %rdi
jne 0x2fb45
incq %rcx
addq 0xd8(%rsp), %rax
cmpq 0x8(%rsp), %rcx
jne 0x2fb24
testq %rbp, %rbp
movq 0xf0(%rsp), %rsi
movss 0x3867(%rip), %xmm2     # 0x33444
movss 0x28(%rsp), %xmm3
jle 0x2fc2e
xorl %eax, %eax
movl (%r15,%rax,4), %ecx
movaps %xmm2, %xmm0
testl %ecx, %ecx
je 0x2fbfa
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
movq %rax, %rcx
imulq 0x38(%rsp), %rcx
incq %rax
movq %rax, %rdx
imulq %rsi, %rdx
cmpq %rdx, %rcx
jge 0x2fc29
movss (%r13,%rcx,4), %xmm1
divss %xmm0, %xmm1
movss %xmm1, (%r13,%rcx,4)
incq %rcx
jmp 0x2fc0d
cmpq %rbp, %rax
jne 0x2fbe7
movq 0x78(%rsp), %rcx
incq %rcx
movss %xmm3, 0x5c(%rsp)
movss 0x18(%rsp), %xmm0
movss %xmm0, 0xbc(%rsp)
movq %rcx, 0x78(%rsp)
cmpq $0x64, %rcx
jne 0x2f83a
movq %r15, %rdi
callq 0x9580
movq %r13, %rdi
callq 0x9580
movq 0x80(%rsp), %rdi
callq 0x9580
movl $0x4, %esi
movq 0xe0(%rsp), %r14
movq %r14, %rdi
callq 0x98f0
movq %rax, %r13
leaq (,%r14,8), %rdi
callq 0x95b0
movq %rax, %rbp
movslq %r14d, %rcx
testq %rcx, %rcx
jle 0x2fdfb
xorl %edx, %edx
leaq 0x379c(%rip), %rdi      # 0x33450
leaq 0x37b5(%rip), %r8       # 0x33470
movq %rcx, 0x30(%rsp)
cmpl $0x0, (%r13,%rdx,4)
jne 0x2fdd6
movq 0x48(%rsp), %rax
movl (%rax,%rdx,4), %r10d
movq %rdx, (%rbp)
leal 0x1(%r10), %r11d
movl %r11d, (%r13,%rdx,4)
movq %rdx, 0x38(%rsp)
movq %rdx, %rax
xorl %edx, %edx
divq (%rsp)
xorl %ebx, %ebx
movl %r11d, %r9d
movq (%rbx,%rdi), %rcx
addq %rdx, %rcx
js 0x2fd2e
cmpq 0x20(%rsp), %rcx
jge 0x2fd2e
movq (%rbx,%r8), %rsi
addq %rax, %rsi
js 0x2fd2e
cmpq 0x8(%rsp), %rsi
jge 0x2fd2e
imulq (%rsp), %rsi
leaq (,%rcx,4), %rcx
addq %r13, %rcx
movl (%rcx,%rsi,4), %ecx
testl %ecx, %ecx
cmovnel %ecx, %r9d
addq $0x8, %rbx
cmpq $0x20, %rbx
jne 0x2fcf5
movl $0x1, %ebx
xorl %r14d, %r14d
movq (%rbp,%r14,8), %rax
xorl %edx, %edx
divq (%rsp)
xorl %r15d, %r15d
movq (%r15,%rdi), %rsi
addq %rdx, %rsi
js 0x2fd96
cmpq 0x20(%rsp), %rsi
jge 0x2fd96
movq (%r15,%r8), %rcx
addq %rax, %rcx
js 0x2fd96
cmpq 0x8(%rsp), %rcx
jge 0x2fd96
imulq (%rsp), %rcx
addq %rsi, %rcx
cmpl $0x0, (%r13,%rcx,4)
jne 0x2fd96
movq 0x48(%rsp), %rsi
cmpl %r10d, (%rsi,%rcx,4)
jne 0x2fd96
movl %r11d, (%r13,%rcx,4)
movq %rcx, (%rbp,%rbx,8)
incq %rbx
addq $0x8, %r15
cmpq $0x20, %r15
jne 0x2fd4e
incq %r14
cmpq %rbx, %r14
jb 0x2fd40
cmpq 0xe8(%rsp), %rbx
setae %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rdx
jne 0x2fdd6
movq -0x8(%rbp,%rbx,8), %rax
movl %r9d, (%r13,%rax,4)
decq %rbx
jne 0x2fdc7
incq %rdx
cmpq %rcx, %rdx
jne 0x2fcc0
testq %rcx, %rcx
movq 0x48(%rsp), %rbx
jle 0x2fdfb
xorl %eax, %eax
decl (%r13,%rax,4)
incq %rax
cmpq %rax, %rcx
jne 0x2fdee
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x95a0
movq %r13, %rdi
callq 0x9580
movq %rbp, %rdi
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9580
nop