// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/vl/imopv.c
// Function: vl_imgradient_polar_f
VL_EXPORT void
VL_XCAT(vl_imgradient_polar_, SFX)
(T * gradientModulus, T * gradientAngle,
 vl_size gradientHorizontalStride, vl_size gradHeightStride,
 T const* image,
 vl_size imageWidth, vl_size imageHeight, vl_size imageStride)
{
  /* Shortcuts */
  vl_index const xo = 1 ;
  vl_index const yo = imageStride ;
  vl_size const w = imageWidth;
  vl_size const h = imageHeight;

  T const *src, *end;
  T *pgrad_angl, *pgrad_ampl;
  T gx, gy ;
  vl_size y;

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

  src  = image ;
  pgrad_angl = gradientAngle ;
  pgrad_ampl = gradientModulus ;

  /* 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 ;

  gradientModulus += gradHeightStride;
  pgrad_ampl = gradientModulus;
  gradientAngle += gradHeightStride;
  pgrad_angl = gradientAngle;
  image += imageStride;
  src = image;

  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 ;

    gradientModulus += gradHeightStride;
    pgrad_ampl = gradientModulus;
    gradientAngle += gradHeightStride;
    pgrad_angl = gradientAngle;
    image += imageStride;
    src = image;
  }

  /* 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 ;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, 0x28(%rsp)
movq %r8, %rbp
movq %rcx, 0x38(%rsp)
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq 0xb8(%rsp), %r12
movq 0xb0(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x4(%r8), %r13
movss (%r8), %xmm0
movss 0x4(%r8), %xmm2
subss %xmm0, %xmm2
movss %xmm2, (%rsp)
leaq (%r8,%r12,4), %rax
movq %rax, 0x18(%rsp)
movss (%rax), %xmm1
subss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
movaps %xmm2, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0x17fcb
movq %r15, 0x8(%rsp)
movss %xmm0, (%r15)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x158a6(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movq %rbx, %r15
movss %xmm0, (%rbx)
movq %rbp, 0x30(%rsp)
movq 0x28(%rsp), %rax
leaq -0x4(%rbp,%rax,4), %rbx
movq %r14, 0x20(%rsp)
leaq (,%r14,4), %r14
movq %r14, %rbp
movq %r13, 0x10(%rsp)
movq %r13, %rax
cmpq %rbx, %r13
jae 0x17b8c
leaq 0x4(%rax), %r13
movss 0x4(%rax), %xmm0
subss -0x4(%rax), %xmm0
mulss 0x157fc(%rip), %xmm0    # 0x2d328
movss %xmm0, (%rsp)
movss (%rax,%r12,4), %xmm1
subss (%rax), %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x17fcb
movq 0x8(%rsp), %rax
movss %xmm0, (%rax,%rbp)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x15808(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movss %xmm0, (%r15,%rbp)
addq %r14, %rbp
jmp 0x17b0e
movss (%rax), %xmm0
movss (%rax,%r12,4), %xmm1
subss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
subss -0x4(%rax), %xmm0
movss %xmm0, (%rsp)
leaq (,%r12,4), %r13
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x17fcb
movq 0x8(%rsp), %rbx
movss %xmm0, (%rbx,%rbp)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x15797(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movss %xmm0, (%r15,%rbp)
movq %r15, %rsi
decq 0x48(%rsp)
movq %r12, %rax
negq %rax
movq %rax, 0x40(%rsp)
movq 0x38(%rsp), %rcx
leaq (,%rcx,4), %rax
movq %rax, 0x58(%rsp)
movq 0x20(%rsp), %rax
shlq $0x2, %rax
movq %rax, 0x20(%rsp)
leaq (%rax,%rcx,4), %rax
movq %rax, 0x50(%rsp)
pushq $0x1
popq %rdx
movq 0x10(%rsp), %r15
movq 0x30(%rsp), %r14
movq 0x18(%rsp), %rax
movq %rbx, 0x8(%rsp)
movq 0x58(%rsp), %rcx
leaq (%rbx,%rcx), %rbp
addq %rsi, %rcx
movq %rcx, 0x18(%rsp)
movss (%rax), %xmm1
movss 0x4(%rax), %xmm0
subss %xmm1, %xmm0
cmpq 0x48(%rsp), %rdx
movss %xmm0, 0x4(%rsp)
jae 0x17e4a
movq %rdx, 0x70(%rsp)
movq %r15, 0x10(%rsp)
movq %rsi, %r15
leaq (%rax,%r12,4), %rcx
movq %rcx, 0x60(%rsp)
movss (%rcx), %xmm1
movq 0x40(%rsp), %rcx
subss (%rax,%rcx,4), %xmm1
mulss 0x15682(%rip), %xmm1    # 0x2d328
movss %xmm1, (%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
movq %rax, %rbx
callq 0x17fcb
movq %rbp, 0x68(%rsp)
movss %xmm0, (%rbp)
movss (%rsp), %xmm0
movss 0x4(%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x1569b(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movq 0x18(%rsp), %rax
movss %xmm0, (%rax)
movq 0x28(%rsp), %rax
leaq (%rbx,%rax,4), %rbx
addq $-0x4, %rbx
movq 0x50(%rsp), %rbp
movq %r14, 0x30(%rsp)
leaq (%r14,%r13), %rax
addq $0x4, %rax
cmpq %rbx, %rax
jae 0x17dab
movss 0x8(%r14,%r12,4), %xmm2
subss (%r14,%r12,4), %xmm2
movss 0x4(%r14,%r12,8), %xmm1
subss 0x4(%r14), %xmm1
movss 0x155e7(%rip), %xmm0    # 0x2d328
mulss %xmm0, %xmm2
movss %xmm2, (%rsp)
addq $0x4, %r14
mulss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
movaps %xmm2, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0x17fcb
movq 0x8(%rsp), %rax
movss %xmm0, (%rax,%rbp)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x155ee(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movss %xmm0, (%r15,%rbp)
addq 0x20(%rsp), %rbp
jmp 0x17d0e
movss 0x4(%r14,%r12,4), %xmm0
subss (%r14,%r12,4), %xmm0
movss %xmm0, (%rsp)
movss 0x4(%r14,%r12,8), %xmm1
subss 0x4(%r14), %xmm1
mulss 0x15556(%rip), %xmm1    # 0x2d328
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x17fcb
movq 0x8(%rsp), %rax
movss %xmm0, (%rax,%rbp)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x15571(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movss %xmm0, (%r15,%rbp)
movq 0x70(%rsp), %rdx
incq %rdx
movq 0x10(%rsp), %r15
addq %r13, %r15
movq 0x30(%rsp), %r14
addq %r13, %r14
movq 0x68(%rsp), %rbx
movq 0x18(%rsp), %rsi
movq 0x60(%rsp), %rax
jmp 0x17c46
movq %rsi, 0x10(%rsp)
leaq 0x4(%rax), %rbx
movq 0x40(%rsp), %rcx
subss (%rax,%rcx,4), %xmm1
movss %xmm1, (%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
movq %rax, %r14
callq 0x17fcb
movss %xmm0, (%rbp)
movss (%rsp), %xmm0
movss 0x4(%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x154e9(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movq 0x18(%rsp), %rax
movss %xmm0, (%rax)
movq 0x28(%rsp), %rax
leaq (%r14,%rax,4), %r14
addq $-0x4, %r14
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rcx
leaq (%rax,%rcx,4), %r12
cmpq %r14, %rbx
jae 0x17f54
leaq 0x4(%rbx), %r13
movss (%rbx), %xmm1
movss 0x4(%rbx), %xmm0
subss -0x4(%rbx), %xmm0
mulss 0x15441(%rip), %xmm0    # 0x2d328
movss %xmm0, (%rsp)
subss (%r15), %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x17fcb
movq 0x8(%rsp), %rax
movss %xmm0, (%rax,%r12)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x15451(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movq 0x10(%rsp), %rax
movss %xmm0, (%rax,%r12)
addq $0x4, %r15
addq 0x20(%rsp), %r12
movq %r13, %rbx
jmp 0x17ec4
movss (%rbx), %xmm1
movaps %xmm1, %xmm0
subss -0x4(%rbx), %xmm0
movss %xmm0, (%rsp)
subss (%r15), %xmm1
movss %xmm1, 0x4(%rsp)
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
callq 0x17fcb
movq 0x8(%rsp), %rax
movss %xmm0, (%rax,%r12)
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x1805a
cvtss2sd %xmm0, %xmm0
addsd 0x153d8(%rip), %xmm0    # 0x2d380
cvtsd2ss %xmm0, %xmm0
callq 0x18030
movq 0x10(%rsp), %rax
movss %xmm0, (%rax,%r12)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq