// File: /workspace/github_c_makefile_star2_O2/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 $0x128, %rsp            # imm = 0x128
movss %xmm0, 0x4(%rsp)
movq %r8, %r13
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x50(%rsp)
movq %rdi, 0x30(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq %rdx, %xmm1
movq 0x3931(%rip), %xmm2     # 0x2d160
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x3935(%rip), %xmm3     # 0x2d170
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 0x9a40
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x4336(%rip), %xmm0     # 0x2dbc8
cvttsd2si %xmm0, %r12
andq %rcx, %r12
orq %rax, %r12
movq %rbx, %xmm1
punpckldq 0x38b6(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x38be(%rip), %xmm1     # 0x2d170
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0xc0(%rsp), %xmm0
callq 0x9a40
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x42e8(%rip), %xmm0     # 0x2dbc8
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %r12, 0x70(%rsp)
movq %r12, %rbp
movq %rdx, 0x40(%rsp)
imulq %rdx, %rbp
movq %rbx, %r12
imulq %r14, %r12
pushq $0x4
popq %rsi
movq %r12, %rdi
callq 0x9960
movq %rax, %r15
movq %r12, 0xe8(%rsp)
leaq (,%r12,4), %r12
movq %r12, %rdi
callq 0x95e0
movq %rax, 0xd0(%rsp)
leaq 0x2(%r13), %rax
movq %rax, 0x28(%rsp)
movq %rax, %rdi
movq %rbp, 0x88(%rsp)
imulq %rbp, %rdi
shlq $0x2, %rdi
movq %rdi, 0xf8(%rsp)
callq 0x95e0
movq %rax, %rbp
movq %r13, 0xa0(%rsp)
movslq %r13d, %r13
shlq $0x20, %rbx
movq %rbx, 0x58(%rsp)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
leaq (%rbx,%rcx), %rax
sarq $0x20, %rax
movq %rax, 0x18(%rsp)
movq %r14, %rax
shlq $0x20, %rax
movq %rax, 0x60(%rsp)
addq %rcx, %rax
sarq $0x20, %rax
movq %rax, 0x20(%rsp)
xorl %eax, %eax
testq %r13, %r13
cmovleq %rax, %r13
leaq (,%r14,4), %rcx
movq %rcx, 0x38(%rsp)
movq %r15, 0xd8(%rsp)
leaq (%r15,%r14,4), %rcx
movq 0x50(%rsp), %r8
leaq (%r8,%r14,8), %rdx
movq %r14, 0x8(%rsp)
leaq (%r8,%r14,4), %rsi
pushq $0x1
popq %r14
cmpq %r13, %rax
je 0x29a56
movq %rsi, %r9
movq %rdx, %r10
movq %r8, %r11
movq %rcx, %rbx
movq %r14, %r15
cmpq 0x18(%rsp), %r15
jge 0x29a48
incq %r15
movq %r14, %rdi
cmpq 0x20(%rsp), %rdi
jge 0x29a35
movss -0x4(%r9,%rdi,4), %xmm0
subss 0x4(%r9,%rdi,4), %xmm0
movss (%r10,%rdi,4), %xmm1
subss (%r11,%rdi,4), %xmm1
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
addss (%rbx,%rdi,4), %xmm0
movss %xmm0, (%rbx,%rdi,4)
incq %rdi
jmp 0x299f9
movq 0x38(%rsp), %rdi
addq %rdi, %rbx
addq %rdi, %r11
addq %rdi, %r10
addq %rdi, %r9
jmp 0x299ec
incq %rax
addq %r12, %r8
addq %r12, %rdx
addq %r12, %rsi
jmp 0x299d8
movq 0x40(%rsp), %rdx
movq %rdx, %rax
shlq $0x20, %rax
movq %rax, 0x78(%rsp)
movq 0x70(%rsp), %rax
movq %rax, %rcx
shlq $0x20, %rcx
movq %rcx, 0x90(%rsp)
cltq
xorl %ecx, %ecx
testq %rax, %rax
cmovleq %rcx, %rax
movq %rax, 0xb0(%rsp)
movslq %edx, %rax
testq %rax, %rax
cmovleq %rcx, %rax
movq %rax, 0xa8(%rsp)
xorl %r14d, %r14d
movss 0x4(%rsp), %xmm1
movq 0xd0(%rsp), %rbx
cmpq 0xa8(%rsp), %rcx
je 0x29c39
cvtsi2sd %rcx, %xmm0
addsd 0x36f4(%rip), %xmm0     # 0x2d1c0
mulsd 0xc0(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
xorl %eax, %eax
movq %rcx, 0x10(%rsp)
cmpq 0xb0(%rsp), %rax
je 0x29c31
movq %rax, 0x40(%rsp)
cvtsi2sd %rax, %xmm0
addsd 0x36be(%rip), %xmm0     # 0x2d1c0
mulsd 0xc0(%rsp), %xmm0
callq 0x9230
movq %rax, %r15
movsd 0x68(%rsp), %xmm0
callq 0x9230
movq 0x20(%rsp), %r9
cmpq %r9, %r15
cmovgeq %r9, %r15
testq %r15, %r15
movl $0x0, %edx
cmovgq %r15, %rdx
movq 0x18(%rsp), %r8
cmpq %r8, %rax
cmovgeq %r8, %rax
testq %rax, %rax
movl $0x0, %esi
cmovgq %rax, %rsi
cmpq $0x2, %rax
pushq $0x1
popq %rdi
cmovlq %rdi, %rax
decq %rax
leaq 0x1(%rsi), %rcx
cmpq %rsi, %r8
cmovleq %r8, %rcx
cmpq $0x2, %r15
cmovlq %rdi, %r15
decq %r15
leaq 0x1(%rdx), %rsi
cmpq %rdx, %r9
cmovleq %r9, %rsi
movq 0x38(%rsp), %r8
imulq %rax, %r8
addq 0xd8(%rsp), %r8
movss 0x36da(%rip), %xmm0     # 0x2d270
xorl %edx, %edx
xorl %edi, %edi
cmpq %rcx, %rax
jg 0x29bce
movq %r15, %r9
cmpq %rsi, %r9
jg 0x29bc4
movss (%r8,%r9,4), %xmm1
ucomiss %xmm1, %xmm0
cmovaq %rax, %rdx
cmovaq %r9, %rdi
minss %xmm0, %xmm1
incq %r9
movaps %xmm1, %xmm0
jmp 0x29ba2
incq %rax
addq 0x38(%rsp), %r8
jmp 0x29b9a
cvtsi2ss %rdi, %xmm0
cvtsi2ss %rdx, %xmm1
movss %xmm0, (%rbp,%r14,4)
movss %xmm1, 0x4(%rbp,%r14,4)
addq $0x2, %r14
imulq 0x8(%rsp), %rdx
movq 0x50(%rsp), %rax
leaq (%rax,%rdi,4), %rax
leaq (%rax,%rdx,4), %rax
movq %r13, %rcx
movss 0x4(%rsp), %xmm1
subq $0x1, %rcx
jb 0x29c1f
movss (%rax), %xmm0
movss %xmm0, (%rbp,%r14,4)
incq %r14
addq %r12, %rax
jmp 0x29c06
movq 0x40(%rsp), %rax
incq %rax
movq 0x10(%rsp), %rcx
jmp 0x29ae2
incq %rcx
jmp 0x29ab1
movq 0x98(%rsp), %rcx
imulq %rcx, %rcx
testq %rcx, %rcx
js 0x29c51
cvtsi2ss %rcx, %xmm0
jmp 0x29c66
movq %rcx, %rax
shrq %rax
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
movq 0x30(%rsp), %r14
divss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
movq 0x58(%rsp), %rax
sarq $0x20, %rax
movq 0x60(%rsp), %rcx
sarq $0x20, %rcx
movq 0x78(%rsp), %rdx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %rsi, %rdx
sarq $0x20, %rdx
movq %rdx, 0x78(%rsp)
movq 0x90(%rsp), %rdx
addq %rsi, %rdx
sarq $0x20, %rdx
movq %rdx, 0x90(%rsp)
xorl %r15d, %r15d
testq %rcx, %rcx
movl $0x0, %edx
movq %rcx, 0x60(%rsp)
cmovgq %rcx, %rdx
movq %rdx, 0x68(%rsp)
testq %rax, %rax
movl $0x0, %ecx
movq %rax, 0x58(%rsp)
cmovgq %rax, %rcx
movq %rcx, 0xe0(%rsp)
movslq 0x88(%rsp), %rax
testq %rax, %rax
cmovleq %r15, %rax
movq %rax, 0x108(%rsp)
movq 0x28(%rsp), %rax
movslq %eax, %rcx
movq %rcx, 0x100(%rsp)
leaq 0x8(%rbp), %rcx
movq %rcx, 0x88(%rsp)
leaq (,%rax,4), %rcx
movq %rcx, 0x120(%rsp)
movq 0x70(%rsp), %rcx
imulq %rax, %rcx
shlq $0x2, %rcx
movq %rcx, 0xb0(%rsp)
movq 0xa0(%rsp), %rax
leaq 0x8(,%rax,4), %rax
movq %rax, 0x20(%rsp)
movss 0x3510(%rip), %xmm0     # 0x2d270
movss %xmm0, 0x4c(%rsp)
cmpq $0x64, %r15
je 0x2a137
xorpd %xmm2, %xmm2
movq 0x50(%rsp), %rax
movq %rax, 0x80(%rsp)
xorl %eax, %eax
movq %r15, 0x110(%rsp)
cmpq 0xe0(%rsp), %rax
movss %xmm2, 0x10(%rsp)
je 0x29fc0
cvtsi2sd %rax, %xmm0
divsd 0xc0(%rsp), %xmm0
addsd 0x343b(%rip), %xmm0     # 0x2d1f0
movq %rax, %rbx
callq 0x98f0
movss 0x10(%rsp), %xmm2
cvttsd2si %xmm0, %rax
testq %rax, %rax
movl $0x0, %edx
cmovgq %rax, %rdx
leaq 0x1(%rax), %rsi
movq 0x78(%rsp), %rcx
cmpq %rax, %rcx
cmovleq %rcx, %rsi
movq %rsi, 0x18(%rsp)
cvtsi2ss %rbx, %xmm7
movq %rbx, 0x118(%rsp)
movq %rbx, %rax
imulq 0x8(%rsp), %rax
leaq (%r14,%rax,4), %r15
movq 0x70(%rsp), %rax
movq %rdx, 0xa8(%rsp)
imulq %rdx, %rax
movq %rax, 0x98(%rsp)
movq 0x80(%rsp), %rbx
xorl %r14d, %r14d
movss %xmm7, 0xa0(%rsp)
cmpq 0x68(%rsp), %r14
je 0x29f83
movss %xmm2, 0x10(%rsp)
cvtsi2sd %r14, %xmm0
divsd 0xc0(%rsp), %xmm0
addsd 0x3399(%rip), %xmm0     # 0x2d1f0
callq 0x98f0
movss 0xa0(%rsp), %xmm7
movss 0x4(%rsp), %xmm6
cvttsd2si %xmm0, %rax
testq %rax, %rax
movl $0x0, %esi
cmovgq %rax, %rsi
leaq 0x1(%rax), %rcx
movq 0x90(%rsp), %rdx
cmpq %rax, %rdx
cmovleq %rdx, %rcx
cvtsi2ss %r14, %xmm0
movq 0x98(%rsp), %rax
movq %rsi, 0x40(%rsp)
leaq (%rax,%rsi), %rdx
imulq 0x120(%rsp), %rdx
addq 0x88(%rsp), %rdx
movss 0x33b2(%rip), %xmm1     # 0x2d270
movq 0xa8(%rsp), %rsi
cmpq 0x18(%rsp), %rsi
jg 0x29f6d
movq %rsi, %rdi
imulq 0x70(%rsp), %rdi
movq %rdx, %r8
movq 0x40(%rsp), %r9
cmpq %rcx, %r9
jg 0x29f5d
leaq (%r9,%rdi), %r10
movq %r10, %rax
imulq 0x28(%rsp), %rax
movss (%rbp,%rax,4), %xmm4
movaps %xmm7, %xmm2
subss 0x4(%rbp,%rax,4), %xmm2
mulss %xmm2, %xmm2
xorpd %xmm3, %xmm3
movq %rbx, %r11
xorl %eax, %eax
cmpq %rax, %r13
je 0x29f30
movss (%r11), %xmm5
subss (%r8,%rax,4), %xmm5
mulss %xmm5, %xmm5
addss %xmm5, %xmm3
incq %rax
addq %r12, %r11
jmp 0x29f10
movaps %xmm0, %xmm5
subss %xmm4, %xmm5
mulss %xmm5, %xmm5
addss %xmm2, %xmm5
mulss %xmm6, %xmm5
addss %xmm3, %xmm5
ucomiss %xmm5, %xmm1
jbe 0x29f53
movl %r10d, (%r15,%r14,4)
movaps %xmm5, %xmm1
incq %r9
addq 0x20(%rsp), %r8
jmp 0x29ee2
incq %rsi
addq 0xb0(%rsp), %rdx
jmp 0x29ec6
movss 0x10(%rsp), %xmm2
addss %xmm1, %xmm2
incq %r14
addq $0x4, %rbx
jmp 0x29e30
movq 0x118(%rsp), %rcx
incq %rcx
movq 0x80(%rsp), %rax
addq 0x38(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %rcx, %rax
movq 0x30(%rsp), %r14
movq 0xd0(%rsp), %rbx
movq 0x110(%rsp), %r15
jmp 0x29d8b
movapd %xmm2, %xmm3
testq %r15, %r15
je 0x29ffd
movss 0x4c(%rsp), %xmm0
subss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movss 0xbc(%rsp), %xmm3
movaps %xmm3, %xmm1
subss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
mulsd 0x34bd(%rip), %xmm1     # 0x2d4b0
ucomisd %xmm0, %xmm1
ja 0x2a137
movss %xmm3, 0x18(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x9420
movq %rbp, %rdi
xorl %esi, %esi
movq 0xf8(%rsp), %rdx
callq 0x9420
movq 0x50(%rsp), %rax
xorl %ecx, %ecx
cmpq 0xe0(%rsp), %rcx
je 0x2a0c2
cvtsi2ss %rcx, %xmm0
movq %rcx, %rdx
imulq 0x8(%rsp), %rdx
movq %rax, %rsi
xorl %edi, %edi
cmpq 0x68(%rsp), %rdi
je 0x2a0b5
leaq (%rdi,%rdx), %r8
movl (%r14,%r8,4), %r9d
incl (%rbx,%r9,4)
cvtsi2ss %rdi, %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
imulq 0x28(%rsp), %r9
leaq (,%r9,4), %r8
addq %rbp, %r8
movsd (%rbp,%r9,4), %xmm2
addps %xmm1, %xmm2
movlps %xmm2, (%rbp,%r9,4)
movq %rsi, %r9
xorl %r10d, %r10d
cmpq %r10, %r13
je 0x2a0ac
movss (%r9), %xmm1
addss 0x8(%r8,%r10,4), %xmm1
movss %xmm1, 0x8(%r8,%r10,4)
incq %r10
addq %r12, %r9
jmp 0x2a08c
incq %rdi
addq $0x4, %rsi
jmp 0x2a04a
incq %rcx
addq 0x38(%rsp), %rax
jmp 0x2a029
xorl %eax, %eax
movss 0x10(%rsp), %xmm2
cmpq 0x108(%rsp), %rax
je 0x2a11a
movl (%rbx,%rax,4), %ecx
movss 0x4295(%rip), %xmm0     # 0x2e374
testl %ecx, %ecx
je 0x2a0e8
cvtsi2ss %rcx, %xmm0
movq %rax, %rcx
imulq 0x28(%rsp), %rcx
incq %rax
movq %rax, %rdx
imulq 0x100(%rsp), %rdx
cmpq %rdx, %rcx
jge 0x2a0ca
movss (%rbp,%rcx,4), %xmm1
divss %xmm0, %xmm1
movss %xmm1, (%rbp,%rcx,4)
incq %rcx
jmp 0x2a100
incq %r15
movss 0x18(%rsp), %xmm0
movss %xmm0, 0xbc(%rsp)
movss %xmm2, 0x4c(%rsp)
jmp 0x29d66
movq %rbx, %rdi
callq 0x95b0
movq %rbp, %rdi
callq 0x95b0
movq 0xd8(%rsp), %rdi
callq 0x95b0
pushq $0x4
popq %rsi
movq 0xe8(%rsp), %rbx
movq %rbx, %rdi
callq 0x9960
movq %rax, %r13
leaq (,%rbx,8), %rdi
callq 0x95e0
movq %rax, %rbp
movslq %ebx, %rcx
xorl %eax, %eax
testq %rcx, %rcx
cmovleq %rax, %rcx
leaq 0x41f3(%rip), %rdi      # 0x2e380
leaq 0x420c(%rip), %r8       # 0x2e3a0
movq %rcx, 0x20(%rsp)
cmpq %rcx, %rax
je 0x2a2c5
cmpl $0x0, (%r13,%rax,4)
jne 0x2a2bd
movl (%r14,%rax,4), %r10d
movq %rax, (%rbp)
leal 0x1(%r10), %r11d
movl %r11d, (%r13,%rax,4)
movq %rax, 0x28(%rsp)
xorl %edx, %edx
divq 0x8(%rsp)
xorl %ebx, %ebx
movl %r11d, %r9d
cmpq $0x20, %rbx
je 0x2a216
movq (%rbx,%rdi), %rcx
addq %rdx, %rcx
js 0x2a210
cmpq 0x60(%rsp), %rcx
jge 0x2a210
movq (%rbx,%r8), %rsi
addq %rax, %rsi
js 0x2a210
cmpq 0x58(%rsp), %rsi
jge 0x2a210
imulq 0x8(%rsp), %rsi
leaq (,%rcx,4), %rcx
addq %r13, %rcx
movl (%rcx,%rsi,4), %ecx
testl %ecx, %ecx
cmovnel %ecx, %r9d
addq $0x8, %rbx
jmp 0x2a1d0
pushq $0x1
popq %rbx
xorl %r14d, %r14d
cmpq %rbx, %r14
jae 0x2a28a
movq (%rbp,%r14,8), %rax
xorl %edx, %edx
divq 0x8(%rsp)
xorl %r15d, %r15d
cmpq $0x20, %r15
je 0x2a285
movq (%r15,%rdi), %rsi
addq %rdx, %rsi
js 0x2a27f
cmpq 0x60(%rsp), %rsi
jge 0x2a27f
movq (%r15,%r8), %rcx
addq %rax, %rcx
js 0x2a27f
cmpq 0x58(%rsp), %rcx
jge 0x2a27f
imulq 0x8(%rsp), %rcx
addq %rsi, %rcx
cmpl $0x0, (%r13,%rcx,4)
jne 0x2a27f
movq 0x30(%rsp), %rsi
cmpl %r10d, (%rsi,%rcx,4)
jne 0x2a27f
movl %r11d, (%r13,%rcx,4)
movq %rcx, (%rbp,%rbx,8)
incq %rbx
addq $0x8, %r15
jmp 0x2a230
incq %r14
jmp 0x2a21c
cmpq 0xf0(%rsp), %rbx
setae %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
movq 0x30(%rsp), %r14
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
jne 0x2a2bd
movq -0x8(%rbp,%rbx,8), %rdx
movl %r9d, (%r13,%rdx,4)
decq %rbx
jne 0x2a2ae
incq %rax
jmp 0x2a199
xorl %eax, %eax
cmpq %rax, %rcx
je 0x2a2d6
decl (%r13,%rax,4)
incq %rax
jmp 0x2a2c7
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x95d0
movq %r13, %rdi
callq 0x95b0
movq %rbp, %rdi
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x95b0
nopl (%rax)