// File: /workspace/github_c_makefile_star2_O3/zpole[P]IICV/vl/imopv.c
// Function: vl_imconvcoltri_f
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 $0x98, %rsp
movq %r9, %r13
movq %r8, %rbx
movq %rcx, %rbp
movq %rdx, 0x48(%rsp)
movq %rsi, %r15
movq %rdi, %r12
movl 0xe0(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0xd8(%rsp), %r14
movq 0xd0(%rsp), %rcx
movq %rcx, 0x18(%rsp)
leaq (%rcx,%r8), %rdi
shlq $0x2, %rdi
callq 0x95b0
movq %rax, 0x8(%rsp)
testq %rbx, %rbx
je 0x1906e
movslq %ebp, %rax
movq %rax, 0x90(%rsp)
testq %rax, %rax
jle 0x19053
movq 0x18(%rsp), %rax
movq %rax, %xmm0
movq %rax, %rcx
punpckldq 0x19484(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1948c(%rip), %xmm0    # 0x32190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
movsd 0x19554(%rip), %xmm0    # 0x32270
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %r13, %rsi
movq %r13, 0x30(%rsp)
movl 0x4(%rsp), %r13d
testb $0x3, %r13b
sete 0x28(%rsp)
leaq -0x1(%rbx), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r14
movq %rax, 0x20(%rsp)
imulq %rsi, %rdi
movq %rdi, 0x10(%rsp)
movq %rbx, %rdx
shlq $0x20, %rdx
movabsq $-0x200000000, %rsi     # imm = 0xFFFFFFFE00000000
addq %rdx, %rsi
movq %rsi, %r8
sarq $0x20, %r8
movq %rcx, %r9
shlq $0x20, %r9
movq %r9, %r10
negq %r10
sarq $0x20, %r10
movslq %ebx, %r11
movl %ebx, %edx
subl %ecx, %edx
movslq %edx, %rbp
movq %rbp, %rdi
subq %r11, %rdi
setge %dl
movabsq $0x100000000, %rcx      # imm = 0x100000000
subq %r9, %rcx
movq %rcx, %r9
sarq $0x20, %r9
movq %r9, 0x50(%rsp)
testb $0x4, %r13b
movl $0x1, %r13d
cmoveq %r15, %r13
movl $0x1, %r9d
cmoveq %r9, %r15
movq %r15, 0x88(%rsp)
leaq 0x1(%rax), %r15
movq 0x48(%rsp), %rax
movq 0x10(%rsp), %r9
leaq (%rax,%r9,4), %rax
movq %rax, 0x70(%rsp)
imulq %r13, %r15
movq %r15, 0x78(%rsp)
movq 0x20(%rsp), %rax
imulq %r14, %rax
movq %rax, 0x20(%rsp)
negq %r13
orb 0x28(%rsp), %dl
movb %dl, 0x3(%rsp)
sarq $0x1e, %rsi
movq %rsi, 0x68(%rsp)
cmpq $-0x1, %r8
movq $-0x1, %rax
movq %r8, 0x80(%rsp)
cmovlq %r8, %rax
sarq $0x1e, %rcx
movq 0x8(%rsp), %r8
addq %r8, %rcx
movq %rcx, 0x60(%rsp)
leaq -0x4(,%rbx,4), %rcx
movq 0x30(%rsp), %rdx
imulq %rdx, %rcx
leaq -0x8(,%rbx,4), %rsi
imulq %rdx, %rsi
leaq (,%rdx,4), %r15
negq %r15
negq %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rsp), %r9
leaq (%rax,%r9), %rcx
movq %rcx, 0x38(%rsp)
incq %rax
movq %rax, 0x40(%rsp)
leaq (,%rbp,4), %rax
leaq (%rax,%r9,4), %rax
addq %r8, %rax
movq %rax, 0x58(%rsp)
leaq (%r8,%r9,4), %rdx
movslq %r9d, %rax
leaq (%r8,%r9,8), %r9
xorl %ecx, %ecx
movq %r12, 0x30(%rsp)
movq 0x70(%rsp), %r12
movss (%r12,%rcx,4), %xmm1
movss %xmm1, -0x4(%rdx,%rbx,4)
movq 0x80(%rsp), %r8
testq %r8, %r8
movq %rcx, 0x28(%rsp)
js 0x18ef8
movq 0x68(%rsp), %rcx
movss 0x4(%rdx,%rcx), %xmm1
movq 0x48(%rsp), %r12
addss (%r12,%rsi), %xmm1
movss %xmm1, (%rdx,%r8,4)
addq %r15, %r12
addq $-0x1, %r8
jb 0x18ed5
subq 0x10(%rsp), %r12
movq $-0x1, %r8
jmp 0x18efc
leaq (%r12,%rcx,4), %r12
testb $0x3, 0x4(%rsp)
je 0x18f35
cmpq %r10, %r8
jl 0x18f5f
movq 0x8(%rsp), %rcx
movq 0x38(%rsp), %r8
movss 0x4(%rcx,%r8,4), %xmm1
movq 0x40(%rsp), %r8
addss (%r12), %xmm1
movss %xmm1, -0x4(%rdx,%r8,4)
decq %r8
cmpq %r10, %r8
jg 0x18f1e
jmp 0x18f5f
cmpq %r10, %r8
jl 0x18f5f
movq 0x8(%rsp), %rcx
movq 0x38(%rsp), %r8
movss 0x4(%rcx,%r8,4), %xmm1
movq 0x40(%rsp), %r8
movss %xmm1, -0x4(%rdx,%r8,4)
decq %r8
cmpq %r10, %r8
jg 0x18f50
cmpq %rbp, %r10
jge 0x18f81
movq %r10, %r8
movss (%rdx,%r8,4), %xmm1
subss (%r9,%r8,4), %xmm1
movss %xmm1, (%rdx,%r8,4)
incq %r8
cmpq %r8, %rbp
jne 0x18f67
cmpb $0x0, 0x3(%rsp)
jne 0x18fba
movq 0x58(%rsp), %r12
xorl %r8d, %r8d
xorps %xmm1, %xmm1
cvtsi2ss %r8, %xmm1
movss (%r12), %xmm2
mulss -0x4(%rdx,%rbx,4), %xmm1
subss %xmm1, %xmm2
movss %xmm2, (%r12)
decq %r8
addq $0x4, %r12
cmpq %r8, %rdi
jne 0x18f90
cmpq %r11, 0x50(%rsp)
jge 0x18feb
movq 0x18(%rsp), %rcx
movq 0x60(%rsp), %r8
movss -0x4(%r8,%rcx,4), %xmm1
movq 0x50(%rsp), %r8
addss (%rdx,%r8,4), %xmm1
movss %xmm1, (%rdx,%r8,4)
incq %r8
cmpq %r8, %r11
jne 0x18fd7
movq 0x30(%rsp), %rcx
movq 0x78(%rsp), %r8
leaq (%rcx,%r8,4), %r12
movq 0x20(%rsp), %rcx
testq %rcx, %rcx
js 0x19027
movss (%rdx,%rcx,4), %xmm1
movq %rcx, %r8
subq %rax, %r8
subss (%rdx,%r8,4), %xmm1
leaq (%r12,%r13,4), %r12
mulss %xmm0, %xmm1
movss %xmm1, (%r12)
subq %r14, %rcx
jns 0x19003
movq 0x88(%rsp), %rcx
leaq (%r12,%rcx,4), %r12
movq 0x28(%rsp), %rcx
incq %rcx
addq $-0x4, 0x10(%rsp)
addq $0x4, %rsi
cmpq 0x90(%rsp), %rcx
jne 0x18e9d
movq 0x8(%rsp), %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9580
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq