// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/vl/sift.c
// Function: update_gradient
static void
update_gradient (VlSiftFilt *f)
{
  int       s_min = f->s_min ;
  int       s_max = f->s_max ;
  int       w     = vl_sift_get_octave_width  (f) ;
  int       h     = vl_sift_get_octave_height (f) ;
  int const xo    = 1 ;
  int const yo    = w ;
  int const so    = h * w ;
  int y, s ;

  if (f->grad_o == f->o_cur) return ;

  for (s  = s_min + 1 ;
       s <= s_max - 2 ; ++ s) {

    vl_sift_pix *src, *end, *grad, gx, gy ;

#define SAVE_BACK                                                       \
    *grad++ = vl_fast_sqrt_f (gx*gx + gy*gy) ;                          \
    *grad++ = vl_mod_2pi_f   (vl_fast_atan2_f (gy, gx) + 2*VL_PI) ;     \
    ++src ;                                                             \

    src  = vl_sift_get_octave (f,s) ;
    grad = f->grad + 2 * so * (s - s_min -1) ;

    /* first pixel of the first row */
    gx = src[+xo] - src[0] ;
    gy = src[+yo] - src[0] ;
    SAVE_BACK ;

    /* middle pixels of the  first row */
    end = (src - 1) + w - 1 ;
    while (src < end) {
      gx = 0.5 * (src[+xo] - src[-xo]) ;
      gy =        src[+yo] - src[0] ;
      SAVE_BACK ;
    }

    /* last pixel of the first row */
    gx = src[0]   - src[-xo] ;
    gy = src[+yo] - src[0] ;
    SAVE_BACK ;

    for (y = 1 ; y < h -1 ; ++y) {

      /* first pixel of the middle rows */
      gx =        src[+xo] - src[0] ;
      gy = 0.5 * (src[+yo] - src[-yo]) ;
      SAVE_BACK ;

      /* middle pixels of the middle rows */
      end = (src - 1) + w - 1 ;
      while (src < end) {
        gx = 0.5 * (src[+xo] - src[-xo]) ;
        gy = 0.5 * (src[+yo] - src[-yo]) ;
        SAVE_BACK ;
      }

      /* last pixel of the middle row */
      gx =        src[0]   - src[-xo] ;
      gy = 0.5 * (src[+yo] - src[-yo]) ;
      SAVE_BACK ;
    }

    /* first pixel of the last row */
    gx = src[+xo] - src[0] ;
    gy = src[  0] - src[-yo] ;
    SAVE_BACK ;

    /* middle pixels of the last row */
    end = (src - 1) + w - 1 ;
    while (src < end) {
      gx = 0.5 * (src[+xo] - src[-xo]) ;
      gy =        src[0]   - src[-yo] ;
      SAVE_BACK ;
    }

    /* last pixel of the last row */
    gx = src[0]   - src[-xo] ;
    gy = src[0]   - src[-yo] ;
    SAVE_BACK ;
  }
  f->grad_o = f->o_cur ;
}

// Assembly:
movl 0x3c(%rdi), %eax
cmpl %eax, 0xb8(%rdi)
je 0x288a3
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %eax, 0x20(%rsp)
movslq 0x34(%rdi), %rax
movl 0x5c(%rdi), %ecx
movslq 0x58(%rdi), %rdx
movl %edx, %esi
imull %ecx, %esi
movslq 0x38(%rdi), %r8
addq $-0x2, %r8
movq %r8, 0x78(%rsp)
decl %ecx
movl %ecx, 0x28(%rsp)
movq %rdx, %rcx
negq %rcx
movq %rcx, 0x38(%rsp)
movslq %esi, %rcx
addl %esi, %esi
movq %rcx, 0x60(%rsp)
leaq (,%rcx,4), %rcx
leaq (,%rdx,4), %r12
leaq (%rcx,%rdx,4), %r13
addq $0x4, %r13
movq %rdx, 0x10(%rsp)
leaq 0x8(,%rdx,4), %rdx
movq %rdx, 0x48(%rsp)
pushq $0x8
popq %rdx
subq %r12, %rdx
movq %rdx, 0x40(%rsp)
negq %r12
xorl %edx, %edx
movq %rcx, 0x58(%rsp)
movq %rcx, %r14
movq %rax, 0x68(%rsp)
movq %rdi, 0x70(%rsp)
movl %esi, 0x24(%rsp)
movq %r12, 0x50(%rsp)
cmpq 0x78(%rsp), %rax
jge 0x28888
movq %rdx, 0x90(%rsp)
movq %r13, 0x30(%rsp)
movslq %edx, %r13
shlq $0x2, %r13
leaq 0x1(%rax), %rcx
movq 0x48(%rdi), %r15
movq 0xb0(%rdi), %r12
movq %rcx, 0x80(%rsp)
movq 0x68(%rsp), %rdx
subq %rdx, %rcx
imulq 0x60(%rsp), %rcx
leaq (%r15,%rcx,4), %rcx
subl %edx, %eax
imull %esi, %eax
movslq %eax, %rbx
movss (%rcx), %xmm0
movss 0x4(%rcx), %xmm2
subss %xmm0, %xmm2
movss %xmm2, (%rsp)
movq 0x10(%rsp), %rax
leaq -0x4(%rcx,%rax,4), %rbp
movss 0x4(%rbp), %xmm1
subss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
movaps %xmm2, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movss %xmm0, (%r12,%rbx,4)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4fb3(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
movss %xmm0, 0x4(%r12,%rbx,4)
movq %r14, 0x88(%rsp)
addq %r15, %r14
addq 0x30(%rsp), %r15
movq %r12, 0x8(%rsp)
movq %r13, 0x18(%rsp)
addq %r13, %r12
addq $0x8, %r12
xorl %ebx, %ebx
xorl %r13d, %r13d
leaq (%r14,%r13), %rax
addq $0x4, %rax
cmpq %rbp, %rax
jae 0x2848d
movss 0x8(%r14,%r13), %xmm0
subss (%r14,%r13), %xmm0
mulss 0x4f03(%rip), %xmm0     # 0x2d328
movss %xmm0, (%rsp)
movss (%r15,%r13), %xmm1
subss 0x4(%r14,%r13), %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movss %xmm0, (%r12,%r13,2)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4f10(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
movss %xmm0, 0x4(%r12,%r13,2)
addq $0x4, %r13
addq $0x8, %rbx
jmp 0x28403
addq %r13, %r14
addq $0x4, %r14
movss (%r14), %xmm0
movss (%r13,%r15), %xmm1
subss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
subss -0x4(%r14), %xmm0
movss %xmm0, (%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movq 0x8(%rsp), %r15
addq 0x18(%rsp), %r15
movss %xmm0, 0x8(%r15,%r13,2)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4e8d(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
movss %xmm0, 0xc(%r15,%r13,2)
leaq (%rbx,%r15), %r12
addq $0x8, %r12
pushq $0x1
popq %rax
leaq 0x4(%r14), %r15
movss 0x4(%r14), %xmm1
movss 0x8(%r14), %xmm0
subss %xmm1, %xmm0
cmpl 0x28(%rsp), %eax
movss %xmm0, 0x4(%rsp)
jge 0x28704
movl %eax, 0x2c(%rsp)
movq 0x10(%rsp), %rbx
movss 0x4(%r14,%rbx,4), %xmm1
movq 0x38(%rsp), %rax
subss 0x4(%r14,%rax,4), %xmm1
mulss 0x4dd2(%rip), %xmm1     # 0x2d328
movss %xmm1, (%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movq %r12, %rbp
movss %xmm0, 0x8(%r12)
movss (%rsp), %xmm0
movss 0x4(%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4dee(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
movss %xmm0, 0xc(%r12)
addq $0x10, %rbp
leaq (%r15,%rbx,4), %r12
addq $-0x4, %r12
movq 0x48(%rsp), %rax
addq %r14, %rax
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rax
leaq (%r14,%rax), %rbx
xorl %r13d, %r13d
movq %rbp, 0x8(%rsp)
movq %rbp, %r15
leaq (%r14,%r13), %rbp
addq $0x8, %rbp
cmpq %r12, %rbp
jae 0x28673
movss 0xc(%r14,%r13), %xmm2
subss 0x4(%r14,%r13), %xmm2
movss 0x4d32(%rip), %xmm0     # 0x2d328
mulss %xmm0, %xmm2
movss %xmm2, (%rsp)
movq 0x18(%rsp), %rax
movss (%rax,%r13), %xmm1
subss (%rbx,%r13), %xmm1
mulss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
movaps %xmm2, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movq 0x8(%rsp), %rbp
movss %xmm0, (%rbp,%r13,2)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4d2a(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
addq $0x8, %r15
movss %xmm0, 0x4(%rbp,%r13,2)
addq $0x4, %r13
jmp 0x285cf
leaq (%r14,%r13), %rax
movss 0x8(%r14,%r13), %xmm0
subss 0x4(%r14,%r13), %xmm0
movss %xmm0, (%rsp)
movq 0x48(%rsp), %rcx
movss (%rcx,%rax), %xmm1
movq 0x40(%rsp), %rcx
subss (%rcx,%rax), %xmm1
mulss 0x4c82(%rip), %xmm1     # 0x2d328
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movss %xmm0, (%r15)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4ca2(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
movq 0x8(%rsp), %rax
movss %xmm0, 0x4(%rax,%r13,2)
movl 0x2c(%rsp), %eax
incl %eax
movq %rbp, %r14
movq %r15, %r12
jmp 0x2850e
addq $0x8, %r14
movq 0x38(%rsp), %rax
subss (%r15,%rax,4), %xmm1
movss %xmm1, (%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movss %xmm0, 0x8(%r12)
movss (%rsp), %xmm0
movss 0x4(%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4c34(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
movss %xmm0, 0xc(%r12)
movq 0x10(%rsp), %rax
leaq (%r15,%rax,4), %rbx
addq $-0x4, %rbx
addq $0x14, %r12
movq %r12, %rbp
movq 0x50(%rsp), %r12
movq 0x30(%rsp), %r13
cmpq %rbx, %r14
jae 0x287f6
leaq 0x4(%r14), %r15
movss (%r14), %xmm1
movss 0x4(%r14), %xmm0
subss -0x4(%r14), %xmm0
mulss 0x4b8c(%rip), %xmm0     # 0x2d328
movss %xmm0, (%rsp)
subss (%r14,%r12), %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movss %xmm0, -0x4(%rbp)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4ba1(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
movss %xmm0, (%rbp)
addq $0x8, %rbp
movq %r15, %r14
jmp 0x2877a
movss (%r14), %xmm1
movaps %xmm1, %xmm0
subss -0x4(%r14), %xmm0
movss %xmm0, (%rsp)
subss (%r14,%r12), %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x296f8
movss %xmm0, -0x4(%rbp)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x2975d
cvtss2sd %xmm0, %xmm0
addsd 0x4b39(%rip), %xmm0     # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x28f11
movss %xmm0, (%rbp)
movq 0x58(%rsp), %rax
movq 0x88(%rsp), %r14
addq %rax, %r14
addq %rax, %r13
movl 0x24(%rsp), %esi
movq 0x90(%rsp), %rdx
addl %esi, %edx
movq 0x80(%rsp), %rax
movq 0x70(%rsp), %rdi
jmp 0x2831c
movl 0x20(%rsp), %eax
movl %eax, 0xb8(%rdi)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq