// File: /workspace/github_cpp_makefile_star2_O1/manikandan5[P]Image-Matching-Stitching-Warping/siftpp/sift.cpp
// Function: VL::Sift::detectKeypoints(float, float)
void
Sift::detectKeypoints(VL::float_t threshold, VL::float_t edgeThreshold)
{
  keypoints.clear() ;

  int nValidatedKeypoints = 0 ;

  // Process one octave per time
  for(int o = omin ; o < omin + O ; ++o) {
        
    int const xo = 1 ;
    int const yo = getOctaveWidth(o) ;
    int const so = getOctaveWidth(o) * getOctaveHeight(o) ;
    int const ow = getOctaveWidth(o) ;
    int const oh = getOctaveHeight(o) ;

    VL::float_t xperiod = getOctaveSamplingPeriod(o) ;

    // -----------------------------------------------------------------
    //                                           Difference of Gaussians
    // -----------------------------------------------------------------
    pixel_t* dog = temp ;
    tempIsGrad = false ;
    {
      pixel_t* pt = dog ;
      for(int s = smin ; s <= smax-1 ; ++s) {
        pixel_t* srca = getLevel(o, s  ) ;
        pixel_t* srcb = getLevel(o, s+1) ;
        pixel_t* enda = srcb ;
        while( srca != enda ) {
          *pt++ = *srcb++ - *srca++ ;
        }
      }
    }
    
    // -----------------------------------------------------------------
    //                                           Find points of extremum
    // -----------------------------------------------------------------
    {
      pixel_t* pt  = dog + xo + yo + so ;
      for(int s = smin+1 ; s <= smax-2 ; ++s) {
        for(int y = 1 ; y < oh - 1 ; ++y) {
          for(int x = 1 ; x < ow - 1 ; ++x) {          
            pixel_t v = *pt ;
            
            // assert( (pt - x*xo - y*yo - (s-smin)*so) - dog == 0 ) ;
            
#define CHECK_NEIGHBORS(CMP,SGN)                    \
            ( v CMP ## = SGN 0.8 * threshold &&     \
              v CMP *(pt + xo) &&                   \
              v CMP *(pt - xo) &&                   \
              v CMP *(pt + so) &&                   \
              v CMP *(pt - so) &&                   \
              v CMP *(pt + yo) &&                   \
              v CMP *(pt - yo) &&                   \
                                                    \
              v CMP *(pt + yo + xo) &&              \
              v CMP *(pt + yo - xo) &&              \
              v CMP *(pt - yo + xo) &&              \
              v CMP *(pt - yo - xo) &&              \
                                                    \
              v CMP *(pt + xo      + so) &&         \
              v CMP *(pt - xo      + so) &&         \
              v CMP *(pt + yo      + so) &&         \
              v CMP *(pt - yo      + so) &&         \
              v CMP *(pt + yo + xo + so) &&         \
              v CMP *(pt + yo - xo + so) &&         \
              v CMP *(pt - yo + xo + so) &&         \
              v CMP *(pt - yo - xo + so) &&         \
                                                    \
              v CMP *(pt + xo      - so) &&         \
              v CMP *(pt - xo      - so) &&         \
              v CMP *(pt + yo      - so) &&         \
              v CMP *(pt - yo      - so) &&         \
              v CMP *(pt + yo + xo - so) &&         \
              v CMP *(pt + yo - xo - so) &&         \
              v CMP *(pt - yo + xo - so) &&         \
              v CMP *(pt - yo - xo - so) )
            
            if( CHECK_NEIGHBORS(>,+) || CHECK_NEIGHBORS(<,-) ) {
              
              Keypoint k ;
              k.ix = x ;
              k.iy = y ;
              k.is = s ;
              keypoints.push_back(k) ;
            }
            pt += 1 ;
          }
          pt += 2 ;
        }
        pt += 2*yo ;
      }
    }

    // -----------------------------------------------------------------
    //                                               Refine local maxima
    // -----------------------------------------------------------------
    { // refine
      KeypointsIter siter ;
      KeypointsIter diter ;
      
      for(diter = siter = keypointsBegin() + nValidatedKeypoints ; 
          siter != keypointsEnd() ; 
          ++siter) {
       
        int x = int( siter->ix ) ;
        int y = int( siter->iy ) ;
        int s = int( siter->is ) ;
                
        VL::float_t Dx=0,Dy=0,Ds=0,Dxx=0,Dyy=0,Dss=0,Dxy=0,Dxs=0,Dys=0 ;
        VL::float_t  b [3] ;
        pixel_t* pt ;
        int dx = 0 ;
        int dy = 0 ;

        // must be exec. at least once
        for(int iter = 0 ; iter < 5 ; ++iter) {

          VL::float_t A[3*3] ;          

          x += dx ;
          y += dy ;

          pt = dog 
            + xo * x
            + yo * y
            + so * (s - smin) ;

#define at(dx,dy,ds) (*( pt + (dx)*xo + (dy)*yo + (ds)*so))
#define Aat(i,j)     (A[(i)+(j)*3])    
          
          /* Compute the gradient. */
          Dx = 0.5 * (at(+1,0,0) - at(-1,0,0)) ;
          Dy = 0.5 * (at(0,+1,0) - at(0,-1,0));
          Ds = 0.5 * (at(0,0,+1) - at(0,0,-1)) ;
          
          /* Compute the Hessian. */
          Dxx = (at(+1,0,0) + at(-1,0,0) - 2.0 * at(0,0,0)) ;
          Dyy = (at(0,+1,0) + at(0,-1,0) - 2.0 * at(0,0,0)) ;
          Dss = (at(0,0,+1) + at(0,0,-1) - 2.0 * at(0,0,0)) ;
          
          Dxy = 0.25 * ( at(+1,+1,0) + at(-1,-1,0) - at(-1,+1,0) - at(+1,-1,0) ) ;
          Dxs = 0.25 * ( at(+1,0,+1) + at(-1,0,-1) - at(-1,0,+1) - at(+1,0,-1) ) ;
          Dys = 0.25 * ( at(0,+1,+1) + at(0,-1,-1) - at(0,-1,+1) - at(0,+1,-1) ) ;
          
          /* Solve linear system. */
          Aat(0,0) = Dxx ;
          Aat(1,1) = Dyy ;
          Aat(2,2) = Dss ;
          Aat(0,1) = Aat(1,0) = Dxy ;
          Aat(0,2) = Aat(2,0) = Dxs ;
          Aat(1,2) = Aat(2,1) = Dys ;
          
          b[0] = - Dx ;
          b[1] = - Dy ;
          b[2] = - Ds ;
          
          // Gauss elimination
          for(int j = 0 ; j < 3 ; ++j) {

            // look for leading pivot
            VL::float_t maxa = 0 ;
            VL::float_t maxabsa = 0 ;
            int   maxi = -1 ;
            int i ;
            for(i = j ; i < 3 ; ++i) {
              VL::float_t a    = Aat(i,j) ;
              VL::float_t absa = fabsf( a ) ;
              if ( absa > maxabsa ) {
                maxa    = a ;
                maxabsa = absa ;
                maxi    = i ;
              }
            }

            // singular?
            if( maxabsa < 1e-10f ) {
              b[0] = 0 ;
              b[1] = 0 ;
              b[2] = 0 ;
              break ;
            }

            i = maxi ;

            // swap j-th row with i-th row and
            // normalize j-th row
            for(int jj = j ; jj < 3 ; ++jj) {
              std::swap( Aat(j,jj) , Aat(i,jj) ) ;
              Aat(j,jj) /= maxa ;
            }
            std::swap( b[j], b[i] ) ;
            b[j] /= maxa ;

            // elimination
            for(int ii = j+1 ; ii < 3 ; ++ii) {
              VL::float_t x = Aat(ii,j) ;
              for(int jj = j ; jj < 3 ; ++jj) {
                Aat(ii,jj) -= x * Aat(j,jj) ;                
              }
              b[ii] -= x * b[j] ;
            }
          }

          // backward substitution
          for(int i = 2 ; i > 0 ; --i) {
            VL::float_t x = b[i] ;
            for(int ii = i-1 ; ii >= 0 ; --ii) {
              b[ii] -= x * Aat(ii,i) ;
            }
          }

          /* If the translation of the keypoint is big, move the keypoint
           * and re-iterate the computation. Otherwise we are all set.
           */
          dx= ((b[0] >  0.6 && x < ow-2) ?  1 : 0 )
            + ((b[0] < -0.6 && x > 1   ) ? -1 : 0 ) ;
          
          dy= ((b[1] >  0.6 && y < oh-2) ?  1 : 0 )
            + ((b[1] < -0.6 && y > 1   ) ? -1 : 0 ) ;

          /*          
          std::cout<<x<<","<<y<<"="<<at(0,0,0)
                   <<"("
                   <<at(0,0,0)+0.5 * (Dx * b[0] + Dy * b[1] + Ds * b[2])<<")"
                   <<" "<<std::flush ; 
          */

          if( dx == 0 && dy == 0 ) break ;
        }
        
        /* std::cout<<std::endl ; */
        
        // Accept-reject keypoint
        {
          VL::float_t val = at(0,0,0) + 0.5 * (Dx * b[0] + Dy * b[1] + Ds * b[2]) ; 
          VL::float_t score = (Dxx+Dyy)*(Dxx+Dyy) / (Dxx*Dyy - Dxy*Dxy) ; 
          VL::float_t xn = x + b[0] ;
          VL::float_t yn = y + b[1] ;
          VL::float_t sn = s + b[2] ;
          
          if(fast_abs(val) > threshold &&
             score < (edgeThreshold+1)*(edgeThreshold+1)/edgeThreshold && 
             score >= 0 &&
             fast_abs(b[0]) < 1.5 &&
             fast_abs(b[1]) < 1.5 &&
             fast_abs(b[2]) < 1.5 &&
             xn >= 0    &&
             xn <= ow-1 &&
             yn >= 0    &&
             yn <= oh-1 &&
             sn >= smin &&
             sn <= smax ) {
            
            diter->o  = o ;
       
            diter->ix = x ;
            diter->iy = y ;
            diter->is = s ;

            diter->x = xn * xperiod ; 
            diter->y = yn * xperiod ; 
            diter->s = sn ;

            diter->sigma = getScaleFromIndex(o,sn) ;

            ++diter ;
          }
        }
      } // next candidate keypoint

      // prepare for next octave
      keypoints.resize( diter - keypoints.begin() ) ;
      nValidatedKeypoints = keypoints.size() ;
    } // refine block

  } // next octave
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movaps %xmm0, %xmm11
movq 0x60(%rdi), %rax
cmpq %rax, 0x68(%rdi)
je 0x6e413
movq %rax, 0x68(%rdi)
cmpl $0x0, 0xc(%rdi)
jle 0x6f3d1
leaq 0x60(%rdi), %rax
movq %rax, 0xe8(%rsp)
cvtss2sd %xmm11, %xmm2
movsd 0x29bda(%rip), %xmm3    # 0x98010
mulsd %xmm2, %xmm3
mulsd 0x29bd6(%rip), %xmm2    # 0x98018
movl 0x14(%rdi), %eax
movss 0x2e63(%rip), %xmm0     # 0x712b0
addss %xmm1, %xmm0
mulss %xmm0, %xmm0
divss %xmm1, %xmm0
xorl %r8d, %r8d
movss 0x2e5b(%rip), %xmm13    # 0x712c0
movsd 0x29bb2(%rip), %xmm14   # 0x98020
movss 0x29b69(%rip), %xmm15   # 0x97fe0
movl %eax, %edx
movss %xmm11, 0x4c(%rsp)
movsd %xmm2, 0xe0(%rsp)
movsd %xmm3, 0xd8(%rsp)
movaps %xmm0, 0x150(%rsp)
movq %rdi, 0x40(%rsp)
movl %edx, %esi
subl %eax, %esi
jl 0x6f3e3
testl %edx, %edx
movl %edx, %eax
js 0x6e4b8
movl 0x20(%rdi), %edx
movl %eax, %ecx
sarl %cl, %edx
jmp 0x6e4c1
movl 0x20(%rdi), %edx
movl %eax, %ecx
negb %cl
shll %cl, %edx
movl %edx, 0x34(%rsp)
testl %eax, %eax
js 0x6e4d2
movl 0x20(%rdi), %edx
movl %eax, %ecx
sarl %cl, %edx
jmp 0x6e4db
movl 0x20(%rdi), %edx
movl %eax, %ecx
negb %cl
shll %cl, %edx
movl %edx, 0x60(%rsp)
testl %eax, %eax
js 0x6e4ee
movl 0x24(%rdi), %r13d
movl %eax, %ecx
sarl %cl, %r13d
jmp 0x6e4f9
movl 0x24(%rdi), %r13d
movl %eax, %ecx
negb %cl
shll %cl, %r13d
testl %eax, %eax
js 0x6e508
movl 0x20(%rdi), %r9d
movl %eax, %ecx
sarl %cl, %r9d
jmp 0x6e513
movl 0x20(%rdi), %r9d
movl %eax, %ecx
negb %cl
shll %cl, %r9d
movq %r9, 0xb0(%rsp)
testl %eax, %eax
js 0x6e52a
movl 0x24(%rdi), %r9d
movl %eax, %ecx
sarl %cl, %r9d
jmp 0x6e535
movl 0x24(%rdi), %r9d
movl %eax, %ecx
negb %cl
shll %cl, %r9d
movq %r9, 0xa8(%rsp)
testl %eax, %eax
movl %eax, 0x30(%rsp)
movq %r8, 0x120(%rsp)
js 0x6e55c
movl %eax, %ecx
movl $0x1, %eax
shll %cl, %eax
cvtsi2ss %eax, %xmm4
jmp 0x6e57a
movl %eax, %ecx
negb %cl
movl $0x1, %eax
shll %cl, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0x2d3a(%rip), %xmm4     # 0x712b0
divss %xmm0, %xmm4
movq 0x30(%rdi), %rax
movq %rax, 0xc8(%rsp)
movb $0x0, 0x3c(%rdi)
movl 0x18(%rdi), %eax
movl 0x1c(%rdi), %edi
movl %eax, %edx
cmpl %edi, %eax
jge 0x6e652
movl 0x30(%rsp), %ebp
movl %ebp, %eax
negb %al
movq 0x40(%rsp), %rbx
movl 0x20(%rbx), %r9d
movl 0x24(%rbx), %r8d
movl %r9d, %r10d
movl %eax, %ecx
shll %cl, %r10d
movl %ebp, %ecx
sarl %cl, %r9d
movl %r8d, %r11d
movl %eax, %ecx
shll %cl, %r11d
movl %ebp, %ecx
sarl %cl, %r8d
testl %ebp, %ebp
movq 0x48(%rbx), %rax
cmovsl %r10d, %r9d
movslq %esi, %rcx
cmovsl %r11d, %r8d
imull %r9d, %r8d
xorl %esi, %esi
movl %r8d, %r9d
movq 0xc8(%rsp), %r10
movl %edx, %r11d
movl %r11d, %ebx
leal 0x1(%rbx), %r11d
subl %edx, %ebx
imull %r8d, %ebx
movl %r11d, %ebp
subl %edx, %ebp
imull %r8d, %ebp
cmpl %ebp, %ebx
je 0x6e647
movslq %esi, %rbx
shlq $0x2, %rbx
movslq %r9d, %r14
shlq $0x2, %r14
movq %r14, %r15
subq %rbx, %r15
movq (%rax,%rcx,8), %r12
addq %r12, %rbx
addq %r12, %r14
xorl %r12d, %r12d
movss (%r14,%r12), %xmm0
subss (%rbx,%r12), %xmm0
movss %xmm0, (%r10,%r12)
addq $0x4, %r12
cmpq %r12, %r15
jne 0x6e629
addq %r12, %r10
addl %r8d, %esi
addl %r8d, %r9d
cmpl %edi, %r11d
jne 0x6e5ee
imull 0x60(%rsp), %r13d
movslq 0x34(%rsp), %rax
movq %rax, 0xf8(%rsp)
movl %r13d, 0x7c(%rsp)
movslq %r13d, %rax
movq %rax, 0xf0(%rsp)
movq 0x40(%rsp), %rcx
movl 0x1c(%rcx), %eax
addl $-0x2, %eax
cmpl %eax, %edx
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %r8
jge 0x6ec5b
movl %edx, %r9d
movq 0xf0(%rsp), %rax
leaq (,%rax,4), %r10
movq 0xf8(%rsp), %rdx
leaq (%r10,%rdx,4), %r11
movq 0xc8(%rsp), %rax
leaq 0x4(%rax,%r11), %rbp
leal (%rdx,%rdx), %eax
cltq
movq %rax, 0x128(%rsp)
leal -0x2(%rdi), %ebx
leal -0x2(%r8), %eax
movq %r10, %r14
negq %r14
movq %r14, 0xc0(%rsp)
leaq (,%rdx,4), %r14
movl %eax, %edx
movq %r14, %rax
subq %r10, %rax
movq %rax, 0x148(%rsp)
movq %r14, %r15
negq %r15
movq %r10, %r12
movq %r14, 0xb8(%rsp)
subq %r14, %r12
movq %r12, 0x138(%rsp)
movq %r15, 0x140(%rsp)
subq %r10, %r15
movq %r15, 0x130(%rsp)
incl %r9d
cmpl $0x3, %r8d
jl 0x6ec3f
movl $0x1, %r15d
cmpl $0x3, %edi
jl 0x6ec2b
leaq (%r10,%rbp), %r12
movq 0xc0(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x60(%rsp)
movq 0xb8(%rsp), %rax
leaq (%rbp,%rax), %rax
movq %rax, 0x28(%rsp)
leaq (%rbp,%r11), %rax
movq %rax, 0x38(%rsp)
movq 0x148(%rsp), %rax
leaq (%rbp,%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x140(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x20(%rsp)
movq 0x138(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x18(%rsp)
movq 0x130(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x50(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
movq %r14, %rax
incq %r14
movss (%rbp,%rax,4), %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
ucomisd %xmm3, %xmm1
jb 0x6e938
ucomiss 0x4(%rbp,%rax,4), %xmm0
jbe 0x6e938
ucomiss -0x4(%rbp,%rax,4), %xmm0
jbe 0x6e938
ucomiss (%r12,%rax,4), %xmm0
jbe 0x6e938
movq 0x60(%rsp), %rsi
ucomiss (%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x28(%rsp), %rsi
ucomiss (%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x20(%rsp), %rsi
ucomiss (%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x28(%rsp), %rsi
ucomiss 0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x28(%rsp), %rsi
ucomiss -0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x20(%rsp), %rsi
ucomiss 0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x20(%rsp), %rsi
ucomiss -0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
ucomiss 0x4(%r12,%rax,4), %xmm0
jbe 0x6e938
ucomiss -0x4(%r12,%rax,4), %xmm0
jbe 0x6e938
movq 0x38(%rsp), %rsi
ucomiss (%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x18(%rsp), %rsi
ucomiss (%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x38(%rsp), %rsi
ucomiss 0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x38(%rsp), %rsi
ucomiss -0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x18(%rsp), %rsi
ucomiss 0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x18(%rsp), %rsi
ucomiss -0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x60(%rsp), %rsi
ucomiss 0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x60(%rsp), %rsi
ucomiss -0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x58(%rsp), %rsi
ucomiss (%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x50(%rsp), %rsi
ucomiss (%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x58(%rsp), %rsi
ucomiss 0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x58(%rsp), %rsi
ucomiss -0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x50(%rsp), %rsi
ucomiss 0x4(%rsi,%rax,4), %xmm0
jbe 0x6e938
movq 0x50(%rsp), %rsi
ucomiss -0x4(%rsi,%rax,4), %xmm0
ja 0x6eb2c
ucomisd %xmm1, %xmm2
jb 0x6ec1b
movss 0x4(%rbp,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movss -0x4(%rbp,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movss (%r12,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x60(%rsp), %rsi
movss (%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x28(%rsp), %rsi
movss (%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x20(%rsp), %rsi
movss (%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x28(%rsp), %rsi
movss 0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x28(%rsp), %rsi
movss -0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x20(%rsp), %rsi
movss 0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x20(%rsp), %rsi
movss -0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movss 0x4(%r12,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movss -0x4(%r12,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x38(%rsp), %rsi
movss (%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x18(%rsp), %rsi
movss (%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x38(%rsp), %rsi
movss 0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x38(%rsp), %rsi
movss -0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x18(%rsp), %rsi
movss 0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x18(%rsp), %rsi
movss -0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x60(%rsp), %rsi
movss 0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x60(%rsp), %rsi
movss -0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x58(%rsp), %rsi
movss (%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x50(%rsp), %rsi
movss (%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x58(%rsp), %rsi
movss 0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x58(%rsp), %rsi
movss -0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x50(%rsp), %rsi
movss 0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movq 0x50(%rsp), %rsi
movss -0x4(%rsi,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6ec1b
movl %r14d, 0x84(%rsp)
movl %r15d, 0x88(%rsp)
movl %r9d, 0x8c(%rsp)
movq 0x68(%rcx), %rsi
cmpq 0x70(%rcx), %rsi
je 0x6eb6f
movups 0x80(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, 0x68(%rcx)
jmp 0x6ec1b
movq 0xe8(%rsp), %rdi
movl %edx, 0xd0(%rsp)
leaq 0x80(%rsp), %rdx
movaps %xmm4, 0x100(%rsp)
movl %r9d, 0xd4(%rsp)
movq %r10, 0x118(%rsp)
movq %r11, 0x110(%rsp)
callq 0x70816
movl 0xd0(%rsp), %edx
movq 0x110(%rsp), %r11
movq 0x118(%rsp), %r10
movl 0xd4(%rsp), %r9d
movq 0xa8(%rsp), %r8
movq 0xb0(%rsp), %rdi
movaps 0x100(%rsp), %xmm4
movss 0x293f5(%rip), %xmm15   # 0x97fe0
movsd 0x2942c(%rip), %xmm14   # 0x98020
movss 0x26c3(%rip), %xmm13    # 0x712c0
movsd 0xd8(%rsp), %xmm3
movsd 0xe0(%rsp), %xmm2
movq 0x40(%rsp), %rcx
movss 0x4c(%rsp), %xmm11
addq $-0x4, %r13
cmpl %r14d, %ebx
jne 0x6e7c1
subq %r13, %rbp
addq $0x8, %rbp
leal 0x1(%r15), %eax
cmpl %edx, %r15d
movl %eax, %r15d
jne 0x6e740
movq 0x128(%rsp), %rax
leaq (%rbp,%rax,4), %rbp
movl 0x1c(%rcx), %eax
addl $-0x2, %eax
cmpl %eax, %r9d
jl 0x6e72d
movslq 0x120(%rsp), %rdx
shlq $0x5, %rdx
addq 0x60(%rcx), %rdx
cmpq 0x68(%rcx), %rdx
je 0x6f357
movl 0x34(%rsp), %eax
negl %eax
movslq %eax, %r15
movl 0x7c(%rsp), %eax
negl %eax
movd %r8d, %xmm0
movd %edi, %xmm1
decl %edi
xorps %xmm2, %xmm2
cvtsi2ss %edi, %xmm2
movss %xmm2, 0x38(%rsp)
decl %r8d
xorps %xmm2, %xmm2
cvtsi2ss %r8d, %xmm2
movss %xmm2, 0xc0(%rsp)
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
xorps %xmm0, %xmm0
cvtsi2ssl 0x30(%rsp), %xmm0
movss %xmm0, 0xb8(%rsp)
movslq %eax, %r12
paddd 0x2938f(%rip), %xmm1    # 0x98060
movdqa %xmm1, 0x60(%rsp)
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
movaps %xmm4, 0x100(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x4(%rdx), %xmm1
movq %rdx, 0x28(%rsp)
movl 0xc(%rdx), %eax
movl %eax, 0x20(%rsp)
subl 0x18(%rcx), %eax
imull 0x7c(%rsp), %eax
movslq %eax, %rcx
xorps %xmm0, %xmm0
xorl %edx, %edx
movdqa %xmm1, %xmm2
movaps %xmm0, %xmm1
paddd %xmm2, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
movd %xmm0, %eax
movd %xmm1, %esi
movslq %esi, %rsi
movq 0xc8(%rsp), %rdi
leaq (%rdi,%rsi,4), %rsi
imull 0x34(%rsp), %eax
cltq
leaq (%rsi,%rax,4), %rax
leaq (%rax,%rcx,4), %rsi
movss -0x4(%rsi), %xmm0
movss 0x4(%rsi), %xmm3
movq 0xf8(%rsp), %rax
leaq (%rsi,%rax,4), %rdi
movss (%rdi), %xmm5
leaq (%rsi,%r15,4), %r8
movss (%r8), %xmm7
movq 0xf0(%rsp), %rax
movss (%rsi,%rax,4), %xmm6
movss (%rsi,%r12,4), %xmm8
movaps %xmm6, %xmm4
subss %xmm8, %xmm4
movaps %xmm3, %xmm2
addss %xmm0, %xmm2
cvtss2sd %xmm2, %xmm2
xorps %xmm9, %xmm9
cvtss2sd (%rsi), %xmm9
mulsd %xmm14, %xmm9
addsd %xmm9, %xmm2
cvtsd2ss %xmm2, %xmm2
unpcklps %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
addss %xmm7, %xmm5
cvtss2sd %xmm5, %xmm5
addsd %xmm9, %xmm5
cvtsd2ss %xmm5, %xmm5
addss %xmm8, %xmm6
cvtss2sd %xmm6, %xmm6
addsd %xmm9, %xmm6
xorps %xmm8, %xmm8
cvtsd2ss %xmm6, %xmm8
movss 0x4(%rsi,%rax,4), %xmm6
movss 0x4(%rdi), %xmm9
unpcklps %xmm6, %xmm9            # xmm9 = xmm9[0],xmm6[0],xmm9[1],xmm6[1]
movss -0x4(%rsi,%r12,4), %xmm10
movss -0x4(%r8), %xmm6
unpcklps %xmm10, %xmm6           # xmm6 = xmm6[0],xmm10[0],xmm6[1],xmm10[1]
addps %xmm9, %xmm6
movss -0x4(%rsi,%rax,4), %xmm9
movss -0x4(%rdi), %xmm10
unpcklps %xmm9, %xmm10           # xmm10 = xmm10[0],xmm9[0],xmm10[1],xmm9[1]
subps %xmm10, %xmm6
movss 0x4(%rsi,%r12,4), %xmm9
movss 0x4(%r8), %xmm10
unpcklps %xmm9, %xmm10           # xmm10 = xmm10[0],xmm9[0],xmm10[1],xmm9[1]
movss (%rdi,%rax,4), %xmm9
addss (%r8,%r12,4), %xmm9
subss (%r8,%rax,4), %xmm9
subss (%rdi,%r12,4), %xmm9
subps %xmm10, %xmm6
movss %xmm2, 0x80(%rsp)
movss %xmm5, 0x90(%rsp)
movss %xmm8, 0xa0(%rsp)
mulps 0x2921c(%rip), %xmm6    # 0x98070
movss %xmm6, 0x8c(%rsp)
movlps %xmm6, 0x84(%rsp)
movaps %xmm6, %xmm8
shufps $0x55, %xmm6, %xmm8     # xmm8 = xmm8[1,1],xmm6[1,1]
movss %xmm8, 0x98(%rsp)
mulss %xmm15, %xmm9
movss %xmm9, 0x94(%rsp)
movss %xmm9, 0x9c(%rsp)
unpcklps %xmm7, %xmm0            # xmm0 = xmm0[0],xmm7[0],xmm0[1],xmm7[1]
mulss %xmm13, %xmm4
subps %xmm0, %xmm3
mulps 0x291dd(%rip), %xmm3    # 0x98080
movaps %xmm3, %xmm0
movaps 0x22c3(%rip), %xmm7     # 0x71170
xorps %xmm7, %xmm0
movlps %xmm0, 0x8(%rsp)
movaps %xmm4, %xmm0
xorps %xmm7, %xmm0
movss %xmm0, 0x10(%rsp)
movl $0x24, %edi
leaq 0x84(%rsp), %r8
leaq 0x80(%rsp), %r10
movq %r10, %r9
xorl %r11d, %r11d
xorps %xmm0, %xmm0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
xorps %xmm8, %xmm8
movaps 0x222d(%rip), %xmm12    # 0x71120
movaps %xmm0, %xmm9
movss (%r10,%r13,4), %xmm10
movaps %xmm10, %xmm0
andps %xmm12, %xmm0
leal (%r11,%r13), %eax
ucomiss %xmm9, %xmm0
movaps %xmm9, %xmm7
cmpltss %xmm0, %xmm7
andps %xmm7, %xmm10
andnps %xmm8, %xmm7
orps %xmm10, %xmm7
maxss %xmm9, %xmm0
cmoval %eax, %ebx
leaq (%r11,%r13), %rax
incq %rax
incq %r13
movaps %xmm7, %xmm8
cmpq $0x3, %rax
jne 0x6eef3
movss 0x2909d(%rip), %xmm8    # 0x97fe4
ucomiss %xmm0, %xmm8
ja 0x6f042
movslq %ebx, %rax
leaq (%r9,%rax,4), %rbx
xorl %r13d, %r13d
movaps 0x220d(%rip), %xmm10    # 0x71170
movss (%r10,%r13), %xmm8
movss (%rbx,%r13), %xmm9
movss %xmm9, (%r10,%r13)
movss %xmm8, (%rbx,%r13)
movss (%r10,%r13), %xmm8
divss %xmm7, %xmm8
movss %xmm8, (%r10,%r13)
addq $0xc, %r13
cmpq %r13, %rdi
jne 0x6ef63
movss 0x8(%rsp,%r11,4), %xmm8
movss 0x8(%rsp,%rax,4), %xmm9
movss %xmm9, 0x8(%rsp,%r11,4)
movss %xmm8, 0x8(%rsp,%rax,4)
movss 0x8(%rsp,%r11,4), %xmm8
divss %xmm7, %xmm8
movss %xmm8, 0x8(%rsp,%r11,4)
cmpq $0x1, %r11
ja 0x6f05b
leaq (%r11,%r11,2), %rbx
movq %r8, %r13
movq %r11, %rbp
leaq 0x1(%rbp), %rax
leaq (%rbx,%rbp), %r14
incq %r14
movss 0x80(%rsp,%r14,4), %xmm7
movaps %xmm7, %xmm8
xorps %xmm10, %xmm8
xorl %r14d, %r14d
movss (%r10,%r14), %xmm9
mulss %xmm8, %xmm9
addss (%r13,%r14), %xmm9
movss %xmm9, (%r13,%r14)
addq $0xc, %r14
cmpq %r14, %rdi
jne 0x6eff8
movss 0x8(%rsp,%rax,4), %xmm8
mulss 0x8(%rsp,%r11,4), %xmm7
subss %xmm7, %xmm8
movss %xmm8, 0x8(%rsp,%rax,4)
addq $0x4, %r13
testq %rbp, %rbp
movq %rax, %rbp
je 0x6efd8
jmp 0x6f05b
movq $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movaps 0x2115(%rip), %xmm10    # 0x71170
movss 0x28f81(%rip), %xmm7    # 0x97fe4
ucomiss %xmm0, %xmm7
ja 0x6f089
leaq 0x1(%r11), %rax
addq $0x10, %r10
addq $0xc, %r9
addq $-0xc, %rdi
addq $0x10, %r8
cmpq $0x2, %r11
movq %rax, %r11
jb 0x6eedc
movl $0x2, %r9d
movl $0x3, %edi
leaq 0x9c(%rsp), %r8
movss 0x8(%rsp,%r9,4), %xmm0
xorps %xmm10, %xmm0
movq %r8, %rax
movq %rdi, %r10
movss (%rax), %xmm7
mulss %xmm0, %xmm7
addss (%rsp,%r10,4), %xmm7
movss %xmm7, (%rsp,%r10,4)
decq %r10
addq $-0x4, %rax
cmpq $0x1, %r10
ja 0x6f0ad
leaq -0x1(%r9), %rax
decq %rdi
addq $-0x10, %r8
cmpq $0x1, %r9
movq %rax, %r9
ja 0x6f09c
movdqa 0x60(%rsp), %xmm0
pcmpgtd %xmm1, %xmm0
pshufd $0x50, %xmm0, %xmm8     # xmm8 = xmm0[0,0,1,1]
pshufd $0x50, %xmm1, %xmm9     # xmm9 = xmm1[0,0,1,1]
pcmpgtd 0x211f(%rip), %xmm9     # 0x71220
cvtps2pd 0x8(%rsp), %xmm0
movapd 0x28f82(%rip), %xmm7    # 0x98090
cmpltpd %xmm0, %xmm7
andpd %xmm8, %xmm7
cmpltpd 0x28f7f(%rip), %xmm0    # 0x980a0
andpd %xmm9, %xmm0
movapd %xmm7, %xmm8
xorpd %xmm0, %xmm8
movmskpd %xmm8, %eax
testb $0x1, %al
jne 0x6f13d
shrb %al
je 0x6f168
pshufd $0xe8, %xmm7, %xmm7     # xmm7 = xmm7[0,2,2,3]
pand 0x28f66(%rip), %xmm7    # 0x980b0
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
pslld $0x1f, %xmm0
psrad $0x1f, %xmm0
paddd %xmm7, %xmm0
incl %edx
cmpl $0x5, %edx
jne 0x6ed09
xorps %xmm8, %xmm8
cvtss2sd (%rsi), %xmm8
movsd 0x8(%rsp), %xmm7
movaps %xmm3, %xmm0
mulps %xmm7, %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulss %xmm7, %xmm3
addss %xmm0, %xmm3
movss 0x10(%rsp), %xmm0
mulss %xmm0, %xmm4
addss %xmm3, %xmm4
xorps %xmm3, %xmm3
cvtss2sd %xmm4, %xmm3
mulsd 0x1eca(%rip), %xmm3     # 0x71070
addsd %xmm8, %xmm3
cvtsd2ss %xmm3, %xmm3
movaps 0x1f6a(%rip), %xmm4     # 0x71120
andps %xmm4, %xmm3
ucomiss %xmm11, %xmm3
jbe 0x6f33d
movaps %xmm2, %xmm3
addss %xmm5, %xmm3
mulss %xmm3, %xmm3
mulss %xmm6, %xmm6
mulss %xmm5, %xmm2
subss %xmm6, %xmm2
divss %xmm2, %xmm3
xorps %xmm2, %xmm2
cmpleps %xmm3, %xmm2
cmpltps 0x150(%rsp), %xmm3
andps %xmm2, %xmm3
movd %xmm3, %eax
movaps %xmm7, %xmm2
andps %xmm4, %xmm2
cmpltps 0x28ebd(%rip), %xmm2    # 0x980c0
unpcklps %xmm2, %xmm2            # xmm2 = xmm2[0,0,1,1]
movmskpd %xmm2, %ecx
andl %ecx, %eax
andb $0x2, %cl
shrb %cl
andb %cl, %al
cmpb $0x1, %al
movq 0x40(%rsp), %rcx
movq 0x28(%rsp), %rdx
jne 0x6f347
movaps %xmm0, %xmm2
andps %xmm4, %xmm2
movss 0x28db5(%rip), %xmm3    # 0x97fe8
ucomiss %xmm2, %xmm3
jbe 0x6f347
cvtdq2ps %xmm1, %xmm2
addps %xmm2, %xmm7
ucomiss 0x20bf(%rip), %xmm7     # 0x71308
jb 0x6f347
movss 0x38(%rsp), %xmm2
ucomiss %xmm7, %xmm2
jb 0x6f347
movaps %xmm7, %xmm2
shufps $0x55, %xmm7, %xmm2     # xmm2 = xmm2[1,1],xmm7[1,1]
ucomiss 0x209c(%rip), %xmm2     # 0x71308
jb 0x6f347
movss 0xc0(%rsp), %xmm3
ucomiss %xmm2, %xmm3
jb 0x6f347
movl 0x20(%rsp), %esi
xorps %xmm2, %xmm2
cvtsi2ss %esi, %xmm2
xorps %xmm3, %xmm3
cvtsi2ssl 0x18(%rcx), %xmm3
addss %xmm2, %xmm0
ucomiss %xmm3, %xmm0
jb 0x6f347
xorps %xmm2, %xmm2
cvtsi2ssl 0x1c(%rcx), %xmm2
ucomiss %xmm0, %xmm2
jb 0x6f347
movl 0x30(%rsp), %eax
movq 0x18(%rsp), %rbx
movl %eax, (%rbx)
movq %xmm1, 0x4(%rbx)
movl %esi, 0xc(%rbx)
mulps 0x100(%rsp), %xmm7
movlps %xmm7, 0x10(%rbx)
movss %xmm0, 0x18(%rbx)
cvtsi2ssl 0x10(%rcx), %xmm1
movss 0x4(%rcx), %xmm2
movss %xmm2, 0x20(%rsp)
divss %xmm1, %xmm0
addss 0xb8(%rsp), %xmm0
callq 0x4a80
movq 0x28(%rsp), %rdx
movss 0x28cd7(%rip), %xmm15   # 0x97fe0
movsd 0x28d0e(%rip), %xmm14   # 0x98020
movss 0x1fa5(%rip), %xmm13    # 0x712c0
movq 0x40(%rsp), %rcx
movss 0x4c(%rsp), %xmm11
mulss 0x20(%rsp), %xmm0
movss %xmm0, 0x1c(%rbx)
addq $0x20, %rbx
movq %rbx, 0x18(%rsp)
jmp 0x6f347
movq 0x40(%rsp), %rcx
movq 0x28(%rsp), %rdx
addq $0x20, %rdx
cmpq 0x68(%rcx), %rdx
jne 0x6ece8
jmp 0x6f35c
movq %rdx, 0x18(%rsp)
movq 0x18(%rsp), %rsi
subq 0x60(%rcx), %rsi
sarq $0x5, %rsi
movq 0xe8(%rsp), %rdi
callq 0x707e2
movss 0x28c61(%rip), %xmm15   # 0x97fe0
movsd 0x28c98(%rip), %xmm14   # 0x98020
movss 0x1f2f(%rip), %xmm13    # 0x712c0
movq 0x40(%rsp), %rdi
movss 0x4c(%rsp), %xmm11
movq 0x68(%rdi), %r8
subq 0x60(%rdi), %r8
sarq $0x5, %r8
movl 0x30(%rsp), %edx
incl %edx
movl 0x14(%rdi), %eax
movl 0xc(%rdi), %ecx
addl %eax, %ecx
cmpl %ecx, %edx
movsd 0xe0(%rsp), %xmm2
movsd 0xd8(%rsp), %xmm3
jl 0x6e49f
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28dc1(%rip), %rdi     # 0x981ab
leaq 0x28dd4(%rip), %rsi     # 0x981c5
leaq 0x28ddd(%rip), %rcx     # 0x981d5
movl $0x59, %edx
callq 0x4340