// File: /workspace/github_cpp_makefile_star2_O2/manikandan5[P]Image-Matching-Stitching-Warping/siftpp/sift.cpp
// Function: VL::Sift::prepareGrad(int)
void
Sift::prepareGrad(int o)
{ 
  int const ow = getOctaveWidth(o) ;
  int const oh = getOctaveHeight(o) ;
  int const xo = 1 ;
  int const yo = ow ;
  int const so = oh*ow ;

  if( ! tempIsGrad || tempOctave != o ) {

    // compute dx/dy
    for(int s = smin+1 ; s <= smax-2 ; ++s) {
      for(int y = 1 ; y < oh-1 ; ++y ) {
        pixel_t* src  = getLevel(o, s) + xo + yo*y ;        
        pixel_t* end  = src + ow - 1 ;
        pixel_t* grad = 2 * (xo + yo*y + (s - smin -1)*so) + temp ;
        while(src != end) {
          VL::float_t Gx = 0.5 * ( *(src+xo) - *(src-xo) ) ;
          VL::float_t Gy = 0.5 * ( *(src+yo) - *(src-yo) ) ;
          VL::float_t m = fast_sqrt( Gx*Gx + Gy*Gy ) ;
          VL::float_t t = fast_mod_2pi( fast_atan2(Gy, Gx) + VL::float_t(2*M_PI) );
          *grad++ = pixel_t( m ) ;
          *grad++ = pixel_t( t ) ;
          ++src ;
        }
      }
    }
  }
  
  tempIsGrad = true ;
  tempOctave = o ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebx
movq %rdi, %r14
callq 0x532d0
movl %eax, %ebp
movq %r14, %rdi
movl %ebx, 0xc(%rsp)
movl %ebx, %esi
callq 0x53310
movq %r14, 0x10(%rsp)
cmpb $0x1, 0x3c(%r14)
jne 0x5236f
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %rdx
cmpl %ecx, 0x40(%rdx)
jne 0x5236f
movq 0x10(%rsp), %rcx
movb $0x1, 0x3c(%rcx)
movl 0xc(%rsp), %eax
movl %eax, 0x40(%rcx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rcx
movl 0x18(%rcx), %r14d
leal -0x1(%rax), %ecx
movslq %ebp, %rdx
movslq %ecx, %rcx
movq %rcx, 0x60(%rsp)
leal (%rdx,%rdx), %ecx
movl %ecx, 0x24(%rsp)
leal 0x2(%rdx,%rdx), %ecx
movl %ecx, 0x1c(%rsp)
leaq (,%rdx,4), %rcx
movq %rcx, 0x50(%rsp)
leaq 0x8(,%rdx,4), %rcx
movq %rcx, 0x48(%rsp)
leaq 0x4(,%rdx,8), %rcx
movq %rcx, 0x40(%rsp)
leaq -0x4(,%rdx,4), %r13
movl %edx, %ecx
imull %eax, %ecx
addl %ecx, %ecx
movl %ecx, 0x20(%rsp)
movq 0x10(%rsp), %rax
movl 0x1c(%rax), %eax
addl $-0x2, %eax
cmpl %eax, %r14d
jge 0x52350
leal 0x1(%r14), %eax
movl %eax, 0x18(%rsp)
xorl %r12d, %r12d
movq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x1c(%rsp), %ebp
pushq $0x1
popq %rcx
movq %r14, 0x58(%rsp)
cmpq 0x60(%rsp), %rcx
jge 0x52517
movq %rcx, 0x68(%rsp)
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl 0x18(%rsp), %edx
callq 0x53350
movq %rax, %r15
movl %r14d, %eax
subl 0x18(%rbx), %eax
imull 0x20(%rsp), %eax
movl %ebp, 0x28(%rsp)
addl %ebp, %eax
movslq %eax, %rbp
shlq $0x2, %rbp
addq 0x30(%rbx), %rbp
movq 0x30(%rsp), %rax
leaq (%r15,%rax), %r14
movq 0x38(%rsp), %rax
leaq (%r15,%rax), %rbx
movq %r12, 0x70(%rsp)
addq %r12, %r15
xorl %r12d, %r12d
cmpq %r12, %r13
je 0x524e6
movss (%r14,%r12), %xmm1
subss -0x8(%r14,%r12), %xmm1
movss (%rbx,%r12), %xmm0
subss 0x4(%r15,%r12), %xmm0
movss 0x1d9a(%rip), %xmm2     # 0x54230
mulss %xmm2, %xmm1
mulss %xmm2, %xmm0
movaps %xmm0, %xmm2
mulss %xmm0, %xmm2
movaps %xmm1, %xmm3
mulss %xmm1, %xmm3
addss %xmm2, %xmm3
sqrtss %xmm3, %xmm2
movss %xmm2, 0x2c(%rsp)
callq 0x46f0
addss 0x27015(%rip), %xmm0    # 0x794dc
callq 0x53448
movss 0x2c(%rsp), %xmm1
movss %xmm1, (%rbp,%r12,2)
movss %xmm0, 0x4(%rbp,%r12,2)
addq $0x4, %r12
jmp 0x5246f
movq 0x68(%rsp), %rcx
incq %rcx
movl 0x28(%rsp), %ebp
addl 0x24(%rsp), %ebp
movq 0x50(%rsp), %rax
addq %rax, 0x30(%rsp)
addq %rax, 0x38(%rsp)
movq 0x70(%rsp), %r12
addq %rax, %r12
movq 0x58(%rsp), %r14
jmp 0x5240e
movl 0x18(%rsp), %eax
movl %eax, %r14d
jmp 0x523cf
nop