// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/vl/imopv.c
// Function: vl_imconvcoltri_d
VL_EXPORT void
VL_XCAT(vl_imconvcoltri_, SFX)
(T * dest, vl_size destStride,
 T const * image,
 vl_size imageWidth, vl_size imageHeight, vl_size imageStride,
 vl_size filterSize,
 vl_size step, unsigned int flags)
{
  vl_index x, y, dheight ;
  vl_bool transp = flags & VL_TRANSPOSE ;
  vl_bool zeropad = (flags & VL_PAD_MASK) == VL_PAD_BY_ZERO ;
  T scale = (T) (1.0 / ((double)filterSize * (double)filterSize)) ;
  T * buffer = vl_malloc (sizeof(T) * (imageHeight + filterSize)) ;
  buffer += filterSize ;

  if (imageHeight == 0) {
    return  ;
  }

  x = 0 ;
  dheight = (imageHeight - 1) / step + 1 ;

  while (x < (signed)imageWidth) {
    T const * imagei ;
    imagei = image + x + imageStride * (imageHeight - 1) ;

    /* We decompose the convolution by a triangluar signal as the convolution
     * by two rectangular signals. The rectangular convolutions are computed
     * quickly by computing the integral signals. Each rectangular convolution
     * introduces a delay, which is compensated by convolving each in opposite
     * directions.
     */

    /* integrate backward the column */
    buffer[imageHeight - 1] = *imagei ;
    for (y = (signed)imageHeight - 2 ; y >=  0 ; --y) {
      imagei -= imageStride ;
      buffer[y] = buffer[y + 1] + *imagei ;
    }
    if (zeropad) {
      for ( ; y >= - (signed)filterSize ; --y) {
        buffer[y] = buffer[y + 1] ;
      }
    } else {
      for ( ; y >= - (signed)filterSize ; --y) {
        buffer[y] = buffer[y + 1] + *imagei ;
      }
    }

    /* compute the filter forward */
    for (y = - (signed)filterSize ;
         y < (signed)imageHeight - (signed)filterSize ; ++y) {
      buffer[y] = buffer[y] - buffer[y + filterSize] ;
    }
    if (! zeropad) {
      for (y = (signed)imageHeight - (signed)filterSize ;
           y < (signed)imageHeight ;
           ++y) {
        buffer[y] = buffer[y] - buffer[imageHeight - 1]  *
        ((signed)imageHeight - (signed)filterSize - y) ;
      }
    }

    /* integrate forward the column */
    for (y = - (signed)filterSize + 1 ;
         y < (signed)imageHeight ; ++y) {
      buffer[y] += buffer[y - 1] ;
    }

    /* compute the filter backward */
    {
      vl_size stride = transp ? 1 : destStride ;
      dest += dheight * stride ;
      for (y = step * (dheight - 1) ; y >= 0 ; y -= step) {
        dest -= stride ;
        *dest = scale * (buffer[y] - buffer[y - (signed)filterSize]) ;
      }
      dest += transp ? destStride : 1 ;
    }
    x += 1 ;
  } /* next x */
  vl_free (buffer - filterSize) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, 0x18(%rsp)
movq %r8, %rbx
movq %rcx, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r13
movl 0xb0(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0xa8(%rsp), %rbp
movq 0xa0(%rsp), %r12
leaq (%r12,%r8), %rdi
shlq $0x3, %rdi
callq 0x95e0
testq %rbx, %rbx
je 0x18a19
movq %rax, %r8
movq %r13, 0x28(%rsp)
movq %r12, %xmm0
punpckldq 0x149b6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x149be(%rip), %xmm0    # 0x2d170
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
movsd 0x14a6e(%rip), %xmm0    # 0x2d238
divsd %xmm1, %xmm0
leaq (%rax,%r12,8), %rsi
leaq -0x1(%rbx), %rcx
movq %rcx, %rax
xorl %edx, %edx
divq %rbp
leaq 0x1(%rax), %rdx
movslq 0x10(%rsp), %r13
movq %r15, %r9
movq 0x18(%rsp), %r15
imulq %r15, %rcx
leaq (%r9,%rcx,8), %rcx
movq %rcx, 0x20(%rsp)
leal -0x2(%rbx), %ecx
movslq %ecx, %rcx
movq %rcx, 0x38(%rsp)
movl %r12d, %ecx
negl %ecx
movslq %ecx, %r11
movl %ebx, %ecx
subl %r12d, %ecx
movslq %ecx, %rdi
pushq $0x1
popq %rcx
subl %r12d, %ecx
movslq %ecx, %rcx
movq %rcx, 0x10(%rsp)
testb $0x4, 0xc(%rsp)
pushq $0x1
popq %rcx
movq %rcx, %r10
cmoveq %r14, %r10
cmoveq %rcx, %r14
movq %r14, 0x50(%rsp)
imulq %r10, %rdx
movq %rdx, 0x40(%rsp)
imulq %rbp, %rax
movq %rax, 0x48(%rsp)
negq %r10
movslq %r12d, %rcx
testq %r13, %r13
movl $0x0, %eax
cmovleq %rax, %r13
movq %r13, 0x60(%rsp)
leaq -0x10(,%rbx,8), %rdx
imulq %r15, %rdx
addq %r9, %rdx
leaq (%r8,%r12,8), %r9
addq $0x8, %r9
leaq (,%r15,8), %rax
shlq $0x4, %r12
movq %r8, 0x30(%rsp)
addq %r8, %r12
xorl %r8d, %r8d
movslq %ebx, %r13
movq 0x20(%rsp), %r14
movq %rbx, 0x58(%rsp)
cmpq 0x60(%rsp), %r8
je 0x18a01
movq %r8, 0x18(%rsp)
movq 0x20(%rsp), %r15
movsd (%r15,%r8,8), %xmm1
movsd %xmm1, -0x8(%rsi,%rbx,8)
xorl %r8d, %r8d
movq 0x38(%rsp), %r15
testq %r15, %r15
js 0x188ea
movsd (%r9,%r15,8), %xmm1
addsd (%rdx,%r8), %xmm1
movsd %xmm1, -0x8(%r9,%r15,8)
decq %r15
subq %rax, %r8
jmp 0x188ca
testb $0x3, 0xc(%rsp)
je 0x1891e
cmpq %r11, %r15
jl 0x18923
movsd (%r9,%r15,8), %xmm1
addsd (%r14,%r8), %xmm1
movsd %xmm1, -0x8(%r9,%r15,8)
decq %r15
jmp 0x188f1
movsd (%r9,%r15,8), %xmm1
movsd %xmm1, -0x8(%r9,%r15,8)
decq %r15
cmpq %r11, %r15
jge 0x1890e
movq %r11, %r8
cmpq %rdi, %r8
jge 0x18942
movsd (%rsi,%r8,8), %xmm1
subsd (%r12,%r8,8), %xmm1
movsd %xmm1, (%rsi,%r8,8)
incq %r8
jmp 0x18926
movq 0x10(%rsp), %r8
testb $0x3, 0xc(%rsp)
je 0x18999
xorl %r8d, %r8d
movq %rdi, %r15
cmpq %r13, %r15
jge 0x1897c
movsd (%rsi,%r15,8), %xmm1
cvtsi2sd %r8, %xmm2
mulsd -0x8(%rsi,%rbx,8), %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, (%rsi,%r15,8)
incq %r15
decq %r8
jmp 0x18954
movq 0x10(%rsp), %r8
jmp 0x18999
movsd -0x8(%rsi,%r8,8), %xmm1
addsd (%rsi,%r8,8), %xmm1
movsd %xmm1, (%rsi,%r8,8)
incq %r8
cmpq %r13, %r8
jl 0x18983
movq 0x28(%rsp), %r8
movq 0x40(%rsp), %rbx
leaq (%r8,%rbx,8), %r8
movq 0x48(%rsp), %rbx
testq %rbx, %rbx
js 0x189d9
movsd (%rsi,%rbx,8), %xmm1
movq %rbx, %r15
subq %rcx, %r15
subsd (%rsi,%r15,8), %xmm1
leaq (%r8,%r10,8), %r8
mulsd %xmm0, %xmm1
movsd %xmm1, (%r8)
subq %rbp, %rbx
jmp 0x189b1
movq 0x50(%rsp), %rbx
leaq (%r8,%rbx,8), %r8
movq %r8, 0x28(%rsp)
movq 0x18(%rsp), %r8
incq %r8
addq $0x8, %r14
addq $0x8, %rdx
movq 0x58(%rsp), %rbx
jmp 0x188a1
movq 0x30(%rsp), %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x95b0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq