// File: /workspace/github_cpp_makefile_star2_O2/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 $0xe8, %rsp
movss %xmm0, 0x54(%rsp)
movq %rdi, %rbx
movq 0x60(%rdi), %rax
cmpq %rax, 0x68(%rdi)
je 0x515fa
movq %rax, 0x68(%rbx)
leaq 0x60(%rbx), %rax
movq %rax, 0x68(%rsp)
movl 0x14(%rbx), %eax
cvtss2sd 0x54(%rsp), %xmm0
movsd 0x27eec(%rip), %xmm2    # 0x79500
mulsd %xmm0, %xmm2
mulsd 0x27ee8(%rip), %xmm0    # 0x79508
movss 0x2bf8(%rip), %xmm3     # 0x54220
addss %xmm1, %xmm3
mulss %xmm3, %xmm3
divss %xmm1, %xmm3
xorl %edx, %edx
movl %eax, %r14d
movq %rbx, 0x40(%rsp)
movsd %xmm0, 0x70(%rsp)
movsd %xmm2, 0xa8(%rsp)
movss %xmm3, 0x34(%rsp)
addl 0xc(%rbx), %eax
cmpl %eax, %r14d
jge 0x522fc
movq %rdx, 0x78(%rsp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x532d0
movl %eax, 0x3c(%rsp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x532d0
movl %eax, %ebp
movq %rbx, %rdi
movl %r14d, %esi
callq 0x53310
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x532d0
movq %rax, 0x60(%rsp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x53310
movq %rax, 0x58(%rsp)
testl %r14d, %r14d
movl %r14d, 0x1c(%rsp)
js 0x516cd
pushq $0x1
popq %rax
movl %r14d, %ecx
shll %cl, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x50(%rsp)
jmp 0x516ed
movl %r14d, %ecx
negb %cl
pushq $0x1
popq %rax
shll %cl, %eax
cvtsi2ss %eax, %xmm0
movss 0x2b3d(%rip), %xmm1     # 0x54220
divss %xmm0, %xmm1
movss %xmm1, 0x50(%rsp)
movl 0xc(%rsp), %eax
imull %ebp, %eax
movl %eax, 0xc(%rsp)
movq 0x40(%rsp), %r8
movq 0x30(%r8), %r14
movb $0x0, 0x3c(%r8)
movl 0x18(%r8), %ebp
movq %r14, 0xb0(%rsp)
movsd 0x70(%rsp), %xmm2
movss 0x2b0f(%rip), %xmm14    # 0x54230
movss 0x27da6(%rip), %xmm15   # 0x794d0
movl 0x1c(%r8), %eax
cmpl %eax, %ebp
jge 0x51783
movq %r8, %r15
movq %r8, %rdi
movl 0x1c(%rsp), %r12d
movl %r12d, %esi
movl %ebp, %edx
callq 0x53350
movq %rax, %rbx
incl %ebp
movq %r15, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x53350
movq %rax, %rcx
cmpq %rax, %rbx
je 0x5177c
movss (%rcx), %xmm0
subss (%rbx), %xmm0
addq $0x4, %rcx
addq $0x4, %rbx
movss %xmm0, (%r14)
addq $0x4, %r14
jmp 0x5175c
movq 0x40(%rsp), %r8
jmp 0x51712
movslq 0x3c(%rsp), %rdx
movslq 0xc(%rsp), %rcx
movq %rcx, 0xd0(%rsp)
leaq (,%rcx,4), %r14
leaq (%r14,%rdx,4), %rdi
movq 0xb0(%rsp), %rcx
leaq 0x4(%rcx,%rdi), %rbp
movl 0x18(%r8), %r9d
movq 0x58(%rsp), %rcx
leal -0x1(%rcx), %esi
movq 0x60(%rsp), %rcx
leal -0x1(%rcx), %r13d
leal (%rdx,%rdx), %ecx
movslq %ecx, %rcx
movq %r14, %rbx
negq %rbx
movq %rdx, 0xd8(%rsp)
leaq (,%rdx,4), %rdx
movq %rdx, %r10
negq %r10
movq %r14, %r11
subq %rdx, %r11
movq %r11, 0x28(%rsp)
movq %r10, %r15
subq %r14, %r15
movq %r15, 0x20(%rsp)
movq %rdx, %r11
subq %r14, %r11
movq %r11, 0x10(%rsp)
movsd 0xa8(%rsp), %xmm3
movss 0x34(%rsp), %xmm10
xorps %xmm12, %xmm12
movss 0x27cb5(%rip), %xmm13   # 0x794d8
addl $-0x2, %eax
cmpl %eax, %r9d
jge 0x51c33
incl %r9d
pushq $0x1
popq %rax
movl %eax, %r12d
cmpl %esi, %r12d
jge 0x51c25
addq $0x8, %rbp
movl %eax, %r15d
cmpl %r13d, %r15d
jge 0x51c1d
movss -0x8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
ucomisd %xmm3, %xmm1
jb 0x51994
ucomiss -0x4(%rbp), %xmm0
jbe 0x51994
ucomiss -0xc(%rbp), %xmm0
jbe 0x51994
ucomiss -0x8(%rbp,%r14), %xmm0
jbe 0x51994
ucomiss -0x8(%rbp,%rbx), %xmm0
jbe 0x51994
ucomiss -0x8(%rbp,%rdx), %xmm0
jbe 0x51994
ucomiss -0x8(%rbp,%r10), %xmm0
jbe 0x51994
ucomiss -0x4(%rbp,%rdx), %xmm0
jbe 0x51994
ucomiss -0xc(%rbp,%rdx), %xmm0
jbe 0x51994
ucomiss -0x4(%rbp,%r10), %xmm0
jbe 0x51994
ucomiss -0xc(%rbp,%r10), %xmm0
jbe 0x51994
ucomiss -0x4(%rbp,%r14), %xmm0
jbe 0x51994
ucomiss -0xc(%rbp,%r14), %xmm0
jbe 0x51994
ucomiss -0x8(%rbp,%rdi), %xmm0
jbe 0x51994
movq 0x28(%rsp), %r11
ucomiss -0x8(%rbp,%r11), %xmm0
jbe 0x51994
ucomiss -0x4(%rbp,%rdi), %xmm0
jbe 0x51994
ucomiss -0xc(%rbp,%rdi), %xmm0
jbe 0x51994
movq 0x28(%rsp), %r11
ucomiss -0x4(%rbp,%r11), %xmm0
jbe 0x51994
movq 0x28(%rsp), %r11
ucomiss -0xc(%rbp,%r11), %xmm0
jbe 0x51994
ucomiss -0x4(%rbp,%rbx), %xmm0
jbe 0x51994
ucomiss -0xc(%rbp,%rbx), %xmm0
jbe 0x51994
movq 0x10(%rsp), %r11
ucomiss -0x8(%rbp,%r11), %xmm0
jbe 0x51994
movq 0x20(%rsp), %r11
ucomiss -0x8(%rbp,%r11), %xmm0
jbe 0x51994
movq 0x10(%rsp), %r11
ucomiss -0x4(%rbp,%r11), %xmm0
jbe 0x51994
movq 0x10(%rsp), %r11
ucomiss -0xc(%rbp,%r11), %xmm0
jbe 0x51994
movq 0x20(%rsp), %r11
ucomiss -0x4(%rbp,%r11), %xmm0
jbe 0x51994
movq 0x20(%rsp), %r11
ucomiss -0xc(%rbp,%r11), %xmm0
ja 0x51b5e
ucomisd %xmm1, %xmm2
jb 0x51c11
movss -0x4(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0xc(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x8(%rbp,%r14), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x8(%rbp,%rbx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x8(%rbp,%rdx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x8(%rbp,%r10), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x4(%rbp,%rdx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0xc(%rbp,%rdx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x4(%rbp,%r10), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0xc(%rbp,%r10), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x4(%rbp,%r14), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0xc(%rbp,%r14), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x8(%rbp,%rdi), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x28(%rsp), %r11
movss -0x8(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x4(%rbp,%rdi), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0xc(%rbp,%rdi), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x28(%rsp), %r11
movss -0x4(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x28(%rsp), %r11
movss -0xc(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0x4(%rbp,%rbx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movss -0xc(%rbp,%rbx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x10(%rsp), %r11
movss -0x8(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x20(%rsp), %r11
movss -0x8(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x10(%rsp), %r11
movss -0x4(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x10(%rsp), %r11
movss -0xc(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x20(%rsp), %r11
movss -0x4(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movq 0x20(%rsp), %r11
movss -0xc(%rbp,%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x51c11
movl %r15d, 0x84(%rsp)
movl %r12d, 0x88(%rsp)
movl %r9d, 0x8c(%rsp)
movq %rdi, 0x48(%rsp)
movq 0x68(%rsp), %rdi
movl %esi, 0x38(%rsp)
leaq 0x80(%rsp), %rsi
movl %r9d, 0x30(%rsp)
movq %rcx, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %r10, 0xb8(%rsp)
callq 0x533ee
movq 0xb8(%rsp), %r10
movq 0xc0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
movl 0x30(%rsp), %r9d
movq 0x48(%rsp), %rdi
movl 0x38(%rsp), %esi
movss 0x278f3(%rip), %xmm15   # 0x794d0
movss 0x264a(%rip), %xmm14    # 0x54230
movss 0x278e9(%rip), %xmm13   # 0x794d8
xorps %xmm12, %xmm12
pushq $0x1
popq %rax
movss 0x34(%rsp), %xmm10
movsd 0xa8(%rsp), %xmm3
movsd 0x70(%rsp), %xmm2
movq 0x40(%rsp), %r8
incl %r15d
addq $0x4, %rbp
jmp 0x51848
incl %r12d
jmp 0x51838
leaq (%rbp,%rcx,4), %rbp
movl 0x1c(%r8), %eax
jmp 0x51823
movslq 0x78(%rsp), %rcx
shlq $0x5, %rcx
movq 0x68(%rsp), %rax
addq (%rax), %rcx
movl 0x3c(%rsp), %eax
negl %eax
cltq
movq %rax, 0x28(%rsp)
movl 0xc(%rsp), %eax
negl %eax
movslq %eax, %r14
movq 0x60(%rsp), %rax
addl $-0x2, %eax
movq %rax, 0x60(%rsp)
cvtsi2ss %r13d, %xmm0
movss %xmm0, 0x20(%rsp)
movq 0x58(%rsp), %rax
addl $-0x2, %eax
movq %rax, 0x58(%rsp)
cvtsi2ss %esi, %xmm0
movss %xmm0, 0x38(%rsp)
cvtsi2ssl 0x1c(%rsp), %xmm0
movss %xmm0, 0x30(%rsp)
movq %rcx, 0x48(%rsp)
movq %rcx, %rax
cmpq 0x68(%r8), %rax
je 0x522c4
movl 0x4(%rax), %ecx
movl 0x8(%rax), %edx
movq %rax, 0x78(%rsp)
movl 0xc(%rax), %eax
movl 0x18(%r8), %edi
movl %eax, %esi
movl %edi, 0x10(%rsp)
subl %edi, %esi
imull 0xc(%rsp), %esi
movslq %esi, %rdi
xorps %xmm4, %xmm4
xorl %r9d, %r9d
xorps %xmm3, %xmm3
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
xorps %xmm1, %xmm1
xorl %r10d, %r10d
xorl %r8d, %r8d
movaps 0x2437(%rip), %xmm11    # 0x54120
cmpl $0x5, %r8d
je 0x52100
addl %r9d, %ecx
addl %r10d, %edx
movslq %ecx, %rsi
movq 0xb0(%rsp), %r9
leaq (%r9,%rsi,4), %rsi
movl %edx, %r9d
imull 0x3c(%rsp), %r9d
movslq %r9d, %r9
leaq (%rsi,%r9,4), %rsi
leaq (%rsi,%rdi,4), %rsi
movq 0xd8(%rsp), %r9
leaq (%rsi,%r9,4), %r9
movq 0x28(%rsp), %r10
leaq (%rsi,%r10,4), %r10
movq 0xd0(%rsp), %r11
movss (%rsi,%r11,4), %xmm7
movss (%rsi,%r14,4), %xmm8
movaps %xmm7, %xmm2
subss %xmm8, %xmm2
cvtss2sd (%rsi), %xmm5
movss -0x4(%rsi), %xmm0
movss 0x4(%rsi), %xmm3
movss (%r9), %xmm1
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
movss 0x4(%r9), %xmm4
movss -0x4(%r10), %xmm1
movss (%r10), %xmm6
unpcklps %xmm6, %xmm0            # xmm0 = xmm0[0],xmm6[0],xmm0[1],xmm6[1]
movaps %xmm3, %xmm6
addps %xmm0, %xmm6
cvtps2pd %xmm6, %xmm6
addss %xmm8, %xmm7
movaps %xmm5, %xmm8
addsd %xmm5, %xmm8
cvtss2sd %xmm7, %xmm7
subsd %xmm8, %xmm7
unpcklpd %xmm8, %xmm8            # xmm8 = xmm8[0,0]
subpd %xmm8, %xmm6
movss 0x4(%rsi,%r11,4), %xmm8
unpcklps %xmm8, %xmm4            # xmm4 = xmm4[0],xmm8[0],xmm4[1],xmm8[1]
movss -0x4(%rsi,%r14,4), %xmm8
unpcklps %xmm8, %xmm1            # xmm1 = xmm1[0],xmm8[0],xmm1[1],xmm8[1]
movss -0x4(%r9), %xmm8
addps %xmm4, %xmm1
movss -0x4(%rsi,%r11,4), %xmm4
unpcklps %xmm4, %xmm8            # xmm8 = xmm8[0],xmm4[0],xmm8[1],xmm4[1]
movss 0x4(%r10), %xmm9
cvtpd2ps %xmm6, %xmm4
subps %xmm8, %xmm1
movq %rsi, 0xe0(%rsp)
movss 0x4(%rsi,%r14,4), %xmm6
unpcklps %xmm6, %xmm9            # xmm9 = xmm9[0],xmm6[0],xmm9[1],xmm6[1]
movapd %xmm4, %xmm6
shufps $0x55, %xmm4, %xmm6     # xmm6 = xmm6[1,1],xmm4[1,1]
subps %xmm9, %xmm1
movss (%r9,%r11,4), %xmm8
addss (%r10,%r14,4), %xmm8
subss (%r10,%r11,4), %xmm8
subss (%r9,%r14,4), %xmm8
movss %xmm4, 0x80(%rsp)
movss %xmm6, 0x90(%rsp)
cvtsd2ss %xmm7, %xmm6
movss %xmm6, 0xa0(%rsp)
mulps 0x2771a(%rip), %xmm1    # 0x79550
movss %xmm1, 0x8c(%rsp)
movlps %xmm1, 0x84(%rsp)
movaps %xmm1, %xmm6
shufps $0x55, %xmm1, %xmm6     # xmm6 = xmm6[1,1],xmm1[1,1]
movss %xmm6, 0x98(%rsp)
mulss %xmm15, %xmm8
movss %xmm8, 0x94(%rsp)
movss %xmm8, 0x9c(%rsp)
mulss %xmm14, %xmm2
subps %xmm0, %xmm3
mulps 0x276e1(%rip), %xmm3    # 0x79560
movaps %xmm3, %xmm0
movaps 0x276e7(%rip), %xmm7    # 0x79570
xorps %xmm7, %xmm0
movlps %xmm0, (%rsp)
movaps %xmm2, %xmm0
xorps %xmm7, %xmm0
movss %xmm0, 0x8(%rsp)
leaq 0x84(%rsp), %r9
leaq 0x80(%rsp), %rbx
movq %rbx, %r10
pushq $0x24
popq %r11
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x52015
leaq (%r15,%r15,2), %r12
xorps %xmm0, %xmm0
xorl %r13d, %r13d
xorps %xmm6, %xmm6
pushq $-0x1
popq %rbp
leaq (%r15,%r13), %rsi
cmpq $0x3, %rsi
je 0x51f1b
movss (%rbx,%r13,4), %xmm7
movaps %xmm7, %xmm8
andps %xmm11, %xmm8
leal (%r15,%r13), %esi
ucomiss %xmm6, %xmm8
movaps %xmm6, %xmm9
cmpltss %xmm8, %xmm9
andps %xmm9, %xmm7
andnps %xmm0, %xmm9
orps %xmm7, %xmm9
cmoval %esi, %ebp
maxss %xmm6, %xmm8
incq %r13
movaps %xmm9, %xmm0
movaps %xmm8, %xmm6
jmp 0x51ed0
movss 0x275b1(%rip), %xmm7    # 0x794d4
ucomiss %xmm6, %xmm7
ja 0x52004
movslq %ebp, %r13
leaq (%r10,%r13,4), %rbp
xorl %esi, %esi
cmpq %rsi, %r11
je 0x51f64
movss (%rbx,%rsi), %xmm6
movss (%rbp,%rsi), %xmm7
movss %xmm7, (%rbx,%rsi)
movss %xmm6, (%rbp,%rsi)
movss (%rbx,%rsi), %xmm6
divss %xmm0, %xmm6
movss %xmm6, (%rbx,%rsi)
addq $0xc, %rsi
jmp 0x51f35
movss (%rsp,%r15,4), %xmm6
movss (%rsp,%r13,4), %xmm7
movss %xmm7, (%rsp,%r15,4)
movss %xmm6, (%rsp,%r13,4)
movss (%rsp,%r15,4), %xmm6
divss %xmm0, %xmm6
movss %xmm6, (%rsp,%r15,4)
movq %r9, %r13
movq %r15, %rbp
movaps 0x275d7(%rip), %xmm7    # 0x79570
cmpq $0x2, %rbp
je 0x51fec
incq %rbp
leaq (%r12,%rbp), %rsi
movss 0x80(%rsp,%rsi,4), %xmm0
xorps %xmm7, %xmm0
xorl %esi, %esi
cmpq %rsi, %r11
je 0x51fd6
movss (%rbx,%rsi), %xmm6
mulss %xmm0, %xmm6
addss (%r13,%rsi), %xmm6
movss %xmm6, (%r13,%rsi)
addq $0xc, %rsi
jmp 0x51fb4
mulss (%rsp,%r15,4), %xmm0
addss (%rsp,%rbp,4), %xmm0
movss %xmm0, (%rsp,%rbp,4)
addq $0x4, %r13
jmp 0x51f99
incq %r15
addq $0x10, %rbx
addq $-0xc, %r11
addq $0xc, %r10
addq $0x10, %r9
jmp 0x51eb6
andq $0x0, (%rsp)
andl $0x0, 0x8(%rsp)
movaps 0x2755b(%rip), %xmm7    # 0x79570
pushq $0x2
popq %r10
movq %r10, %r9
subq $0x1, %r9
jb 0x5205c
leaq (%r10,%r10,2), %r11
movss (%rsp,%r10,4), %xmm0
xorps %xmm7, %xmm0
testq %r10, %r10
jle 0x52057
decq %r10
movl %r10d, %esi
leaq (%rsi,%r11), %rbx
movss 0x80(%rsp,%rbx,4), %xmm6
mulss %xmm0, %xmm6
addss (%rsp,%rsi,4), %xmm6
movss %xmm6, (%rsp,%rsi,4)
jmp 0x5202f
movq %r9, %r10
jmp 0x5201c
movss (%rsp), %xmm6
cvtss2sd %xmm6, %xmm0
movsd 0x274a2(%rip), %xmm8    # 0x79510
ucomisd %xmm8, %xmm0
movss 0x4(%rsp), %xmm7
seta %sil
cmpl 0x60(%rsp), %ecx
setl %r9b
andb %sil, %r9b
movsd 0x27487(%rip), %xmm9    # 0x79518
ucomisd %xmm0, %xmm9
seta %sil
cmpl $0x2, %ecx
setge %r11b
andb %sil, %r11b
cvtss2sd %xmm7, %xmm0
ucomisd %xmm8, %xmm0
seta %sil
cmpl 0x58(%rsp), %edx
setl %r10b
andb %sil, %r10b
ucomisd %xmm0, %xmm9
seta %bl
cmpl $0x2, %edx
setge %sil
andb %bl, %sil
movaps %xmm3, %xmm0
shufps $0x55, %xmm3, %xmm0     # xmm0 = xmm0[1,1],xmm3[1,1]
cmpb %r11b, %r9b
jne 0x520e2
movl %r10d, %ebx
xorb %sil, %bl
je 0x52112
movzbl %r10b, %r10d
movzbl %sil, %esi
subl %esi, %r10d
movzbl %r9b, %r9d
movzbl %r11b, %esi
subl %esi, %r9d
incl %r8d
jmp 0x51ce9
movss 0x4(%rsp), %xmm7
movq 0xe0(%rsp), %rsi
cvtss2sd (%rsi), %xmm5
mulss %xmm7, %xmm0
mulss %xmm6, %xmm3
addss %xmm0, %xmm3
movss 0x8(%rsp), %xmm0
mulss %xmm0, %xmm2
addss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
mulsd 0x1f30(%rip), %xmm2     # 0x54068
addsd %xmm5, %xmm2
cvtsd2ss %xmm2, %xmm2
andps %xmm11, %xmm2
ucomiss 0x54(%rsp), %xmm2
movq 0x40(%rsp), %r8
jbe 0x522b6
movaps %xmm4, %xmm3
shufps $0x55, %xmm4, %xmm3     # xmm3 = xmm3[1,1],xmm4[1,1]
movaps %xmm4, %xmm2
addss %xmm3, %xmm2
mulss %xmm2, %xmm2
mulss %xmm1, %xmm1
mulss %xmm4, %xmm3
subss %xmm1, %xmm3
divss %xmm3, %xmm2
ucomiss %xmm2, %xmm10
jbe 0x522b6
ucomiss %xmm12, %xmm2
jb 0x522b6
movaps %xmm6, %xmm1
andps %xmm11, %xmm1
ucomiss %xmm1, %xmm13
jbe 0x522b6
movaps %xmm7, %xmm1
andps %xmm11, %xmm1
ucomiss %xmm1, %xmm13
jbe 0x522b6
movaps %xmm0, %xmm1
andps %xmm11, %xmm1
ucomiss %xmm1, %xmm13
jbe 0x522b6
cvtsi2ss %ecx, %xmm1
addss %xmm1, %xmm6
ucomiss %xmm12, %xmm6
jb 0x522b6
movss 0x20(%rsp), %xmm1
ucomiss %xmm6, %xmm1
jb 0x522b6
cvtsi2ss %edx, %xmm1
addss %xmm1, %xmm7
ucomiss %xmm12, %xmm7
jb 0x522b6
movss 0x38(%rsp), %xmm1
ucomiss %xmm7, %xmm1
jb 0x522b6
cvtsi2ss %eax, %xmm1
cvtsi2ssl 0x10(%rsp), %xmm2
addss %xmm1, %xmm0
ucomiss %xmm2, %xmm0
jb 0x522b6
cvtsi2ssl 0x1c(%r8), %xmm1
ucomiss %xmm0, %xmm1
jb 0x522b6
movl 0x1c(%rsp), %edi
movq 0x48(%rsp), %rbx
movl %edi, (%rbx)
movl %ecx, 0x4(%rbx)
movl %edx, 0x8(%rbx)
movl %eax, 0xc(%rbx)
movss 0x50(%rsp), %xmm1
mulss %xmm1, %xmm6
movss %xmm6, 0x10(%rbx)
mulss %xmm1, %xmm7
movss %xmm7, 0x14(%rbx)
movss %xmm0, 0x18(%rbx)
cvtsi2ssl 0x10(%r8), %xmm1
movss 0x4(%r8), %xmm2
movss %xmm2, 0x10(%rsp)
divss %xmm1, %xmm0
addss 0x30(%rsp), %xmm0
callq 0x4a70
movss 0x27250(%rip), %xmm15   # 0x794d0
movss 0x1fa7(%rip), %xmm14    # 0x54230
movss 0x27246(%rip), %xmm13   # 0x794d8
xorps %xmm12, %xmm12
movss 0x34(%rsp), %xmm10
movq 0x40(%rsp), %r8
mulss 0x10(%rsp), %xmm0
movss %xmm0, 0x1c(%rbx)
addq $0x20, %rbx
movq %rbx, 0x48(%rsp)
movq 0x78(%rsp), %rax
addq $0x20, %rax
jmp 0x51c9d
movq 0x48(%rsp), %rsi
subq 0x60(%r8), %rsi
sarq $0x5, %rsi
movq 0x68(%rsp), %rdi
callq 0x53414
movq 0x40(%rsp), %rbx
movq 0x68(%rbx), %rdx
subq 0x60(%rbx), %rdx
sarq $0x5, %rdx
movl 0x1c(%rsp), %r14d
incl %r14d
movl 0x14(%rbx), %eax
jmp 0x51653
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq