// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%rsp)
movq %r8, %r15
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, %r12
movl 0xc0(%rsp), %r14d
movq 0xb0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xa8(%rsp), %rbp
movq 0xa0(%rsp), %rbx
leaq -0x1(%r8), %rax
movslq 0xb8(%rsp), %rcx
xorl %edx, %edx
movq %rcx, 0x28(%rsp)
divq %rcx
movq %rax, %r13
callq 0x9620
testl %eax, %eax
je 0x1877d
callq 0x9210
testl %eax, %eax
je 0x1877d
movq %r12, %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq %r15, %r8
movq 0x20(%rsp), %r9
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9a00
movslq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
jle 0x1897c
incq %r13
movq 0x30(%rsp), %rdi
movq %rdi, %rax
subq %rbp, %rax
leaq (%rbx,%rax,4), %r8
shlq $0x2, %rax
movslq %r15d, %rsi
movq %rax, 0x8(%rsp)
addq %rbx, %rax
movq %rax, 0x58(%rsp)
movq %rdi, %rax
notq %rax
movq 0x18(%rsp), %rdx
movq %rdx, %rcx
subq %r13, %rcx
imulq %rdx, %r13
movl $0x1, %edx
subq %r13, %rdx
testb $0x4, %r14b
cmovneq %rcx, %rdx
movq %rdx, 0x38(%rsp)
movq %r8, 0x60(%rsp)
leaq (%r8,%rax,4), %r9
movq %rdi, %rax
movq 0x20(%rsp), %rcx
imulq %rcx, %rax
shlq $0x2, %rax
movq 0x10(%rsp), %r10
subq %rax, %r10
movq %rcx, %r11
imulq 0x28(%rsp), %r11
shlq $0x2, %r11
leaq (,%rcx,4), %rax
xorl %edx, %edx
testq %rsi, %rsi
movq %r10, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
jle 0x18957
movq 0x10(%rsp), %rcx
leaq (%rcx,%rdx,4), %rdi
xorl %edx, %edx
movq 0x30(%rsp), %rcx
subq %rdx, %rcx
movq %rcx, %r15
imulq 0x20(%rsp), %r15
shlq $0x2, %r15
movq %rdi, %r8
subq %r15, %r8
xorps %xmm0, %xmm0
testq %rcx, %rcx
jle 0x188a5
xorps %xmm1, %xmm1
testb $0x3, %r14b
je 0x18866
movss (%rdi), %xmm1
shlq $0x2, %rcx
movq 0x60(%rsp), %r15
subq %rcx, %r15
cmpq %r15, 0x58(%rsp)
jbe 0x188af
movq %r10, %r8
movq 0x8(%rsp), %rcx
leaq (%rbx,%rcx), %r13
addq $-0x4, %r13
addq $-0x4, %rcx
movss 0x4(%r13), %xmm2
mulss %xmm1, %xmm2
addss %xmm2, %xmm0
addq %rax, %r8
cmpq %r15, %r13
ja 0x18881
jmp 0x188b4
movq 0x8(%rsp), %rcx
xorps %xmm1, %xmm1
jmp 0x188b4
movq 0x8(%rsp), %rcx
movq %rdx, %r15
subq %rsi, %r15
incq %r15
cmpq %rbp, %r15
cmovleq %rbp, %r15
leaq (%r9,%r15,4), %r15
leaq (%rbx,%rcx), %r13
cmpq %r15, %r13
jbe 0x188f5
movss (%r8), %xmm1
leaq (%rbx,%rcx), %r13
addq $-0x4, %r13
addq $-0x4, %rcx
movss 0x4(%r13), %xmm2
mulss %xmm1, %xmm2
addss %xmm2, %xmm0
addq %rax, %r8
jmp 0x188cc
xorps %xmm2, %xmm2
testb $0x3, %r14b
je 0x18901
movaps %xmm1, %xmm2
cmpq $-0x3, %rcx
jl 0x18922
addq $0x4, %rcx
movss -0x4(%rbx,%rcx), %xmm1
mulss %xmm2, %xmm1
addss %xmm1, %xmm0
addq $-0x4, %rcx
testq %rcx, %rcx
jg 0x1890b
movq 0x18(%rsp), %rcx
leaq (,%rcx,4), %rcx
testb $0x4, %r14b
movss %xmm0, (%r12)
movl $0x4, %r8d
cmovneq %r8, %rcx
addq %rcx, %r12
addq 0x28(%rsp), %rdx
addq %r11, %r10
cmpq %rsi, %rdx
jl 0x18836
movq 0x38(%rsp), %rcx
leaq (%r12,%rcx,4), %r12
movq 0x48(%rsp), %rdx
incq %rdx
movq 0x50(%rsp), %r10
addq $0x4, %r10
cmpq 0x40(%rsp), %rdx
jne 0x18818
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq