// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/vl/imopv.c
// Function: vl_imconvcol_vf
VL_EXPORT void
VL_XCAT(vl_imconvcol_v, SFX)
(T* dst, vl_size dst_stride,
 T const* src,
 vl_size src_width, vl_size src_height, vl_size src_stride,
 T const* filt, vl_index filt_begin, vl_index filt_end,
 int step, unsigned int flags)
{
  vl_index x = 0 ;
  vl_index y ;
  vl_index dheight = (src_height - 1) / step + 1 ;
  vl_bool transp = flags & VL_TRANSPOSE ;
  vl_bool zeropad = (flags & VL_PAD_MASK) == VL_PAD_BY_ZERO ;

  /* dispatch to accelerated version */
#ifndef VL_DISABLE_SSE2
  if (vl_cpu_has_sse2() && vl_get_simd_enabled()) {
    VL_XCAT3(_vl_imconvcol_v,SFX,_sse2)
    (dst,dst_stride,
     src,src_width,src_height,src_stride,
     filt,filt_begin,filt_end,
     step,flags) ;
    return ;
  }
#endif

  /* let filt point to the last sample of the filter */
  filt += filt_end - filt_begin ;

  while (x < (signed)src_width) {
    /* Calculate dest[x,y] = sum_p image[x,p] filt[y - p]
     * where supp(filt) = [filt_begin, filt_end] = [fb,fe].
     *
     * CHUNK_A: y - fe <= p < 0
     *          completes VL_MAX(fe - y, 0) samples
     * CHUNK_B: VL_MAX(y - fe, 0) <= p < VL_MIN(y - fb, height - 1)
     *          completes fe - VL_MAX(fb, height - y) + 1 samples
     * CHUNK_C: completes all samples
     */
    T const *filti ;
    vl_index stop ;

    for (y = 0 ; y < (signed)src_height ; y += step) {
      T acc = 0 ;
      T v = 0, c ;
      T const* srci ;

      filti = filt ;
      stop = filt_end - y ;
      srci = src + x - stop * src_stride ;

      if (stop > 0) {
        if (zeropad) {
          v = 0 ;
        } else {
          v = *(src + x) ;
        }
        while (filti > filt - stop) {
          c = *filti-- ;
          acc += v * c ;
          srci += src_stride ;
        }
      }

      stop = filt_end - VL_MAX(filt_begin, y - (signed)src_height + 1) + 1 ;
      while (filti > filt - stop) {
        v = *srci ;
        c = *filti-- ;
        acc += v * c ;
        srci += src_stride ;
      }

      if (zeropad) v = 0 ;

      stop = filt_end - filt_begin + 1 ;
      while (filti > filt - stop) {
        c = *filti-- ;
        acc += v * c ;
      }

      if (transp) {
        *dst = acc ; dst += 1 ;
      } else {
        *dst = acc ; dst += dst_stride ;
      }
    } /* next y */
    if (transp) {
      dst += 1 * dst_stride - dheight * 1 ;
    } else {
      dst += 1 * 1 - dheight * dst_stride ;
    }
    x += 1 ;
  } /* next x */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, 0x18(%rsp)
movq %r8, %r14
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r12
movl 0xc0(%rsp), %r13d
movq 0xb0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xa8(%rsp), %rbp
movq 0xa0(%rsp), %rbx
leaq -0x1(%r8), %rax
movslq 0xb8(%rsp), %rcx
xorl %edx, %edx
movq %rcx, 0x30(%rsp)
divq %rcx
movq %rax, %r15
callq 0x9660
testl %eax, %eax
je 0x16ced
callq 0x9210
testl %eax, %eax
je 0x16ced
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq %r14, %r8
movq 0x18(%rsp), %r9
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9a80
incq %r15
movq 0x38(%rsp), %rdx
movq %rdx, %rax
subq %rbp, %rax
leaq (%rbx,%rax,4), %rcx
shlq $0x2, %rax
movq %rax, 0x28(%rsp)
movslq 0x8(%rsp), %rdi
movslq %r14d, %rsi
movq %rdx, %rax
notq %rax
movq %rcx, 0x60(%rsp)
leaq (%rcx,%rax,4), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rcx
movq %rcx, %rax
subq %r15, %rax
imulq %rcx, %r15
pushq $0x1
popq %rcx
subq %r15, %rcx
testb $0x4, %r13b
cmovneq %rax, %rcx
movq %rcx, 0x40(%rsp)
xorl %r8d, %r8d
testq %rdi, %rdi
cmovleq %r8, %rdi
movq %rdi, 0x48(%rsp)
movq %rdx, %rax
movq 0x18(%rsp), %rcx
imulq %rcx, %rax
shlq $0x2, %rax
movq 0x10(%rsp), %r15
subq %rax, %r15
movq %rcx, %r11
imulq 0x30(%rsp), %r11
shlq $0x2, %r11
leaq (,%rcx,4), %rdx
cmpq 0x48(%rsp), %r8
je 0x16ec5
movq 0x10(%rsp), %rax
movq %r8, 0x58(%rsp)
leaq (%rax,%r8,4), %r10
movq %r15, 0x50(%rsp)
xorl %ecx, %ecx
movq %rcx, %r8
subq %rsi, %r8
jge 0x16ea6
movq 0x38(%rsp), %rax
subq %rcx, %rax
testq %rax, %rax
jle 0x16dfe
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
testb $0x3, %r13b
je 0x16dcc
movss (%r10), %xmm1
shlq $0x2, %rax
movq 0x60(%rsp), %r14
subq %rax, %r14
movq %r15, %r9
movq 0x28(%rsp), %rax
leaq (%rbx,%rax), %rdi
cmpq %r14, %rdi
jbe 0x16e19
addq $-0x4, %rax
movss (%rdi), %xmm2
mulss %xmm1, %xmm2
addss %xmm2, %xmm0
addq %rdx, %r9
jmp 0x16de0
imulq 0x18(%rsp), %rax
shlq $0x2, %rax
movq %r10, %r9
subq %rax, %r9
xorps %xmm0, %xmm0
movq 0x28(%rsp), %rax
xorps %xmm1, %xmm1
incq %r8
cmpq %rbp, %r8
cmovleq %rbp, %r8
movq 0x8(%rsp), %rdi
leaq (%rdi,%r8,4), %r8
leaq (%rbx,%rax), %r14
cmpq %r8, %r14
jbe 0x16e50
movss (%r9), %xmm1
addq $-0x4, %rax
movss (%r14), %xmm2
mulss %xmm1, %xmm2
addss %xmm2, %xmm0
addq %rdx, %r9
jmp 0x16e2c
xorps %xmm2, %xmm2
testb $0x3, %r13b
je 0x16e6f
movaps %xmm1, %xmm2
jmp 0x16e6f
movss (%rbx,%rax), %xmm1
mulss %xmm2, %xmm1
addq $-0x4, %rax
addss %xmm1, %xmm0
cmpq $-0x3, %rax
jge 0x16e5e
movq 0x20(%rsp), %rax
leaq (,%rax,4), %rax
testb $0x4, %r13b
pushq $0x4
popq %rdi
cmovneq %rdi, %rax
addq %r12, %rax
movss %xmm0, (%r12)
addq 0x30(%rsp), %rcx
addq %r11, %r15
movq %rax, %r12
jmp 0x16da2
movq 0x40(%rsp), %rax
leaq (%r12,%rax,4), %r12
movq 0x58(%rsp), %r8
incq %r8
movq 0x50(%rsp), %r15
addq $0x4, %r15
jmp 0x16d82
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq