// File: /workspace/github_c_makefile_star2_O1/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 $0xa8, %rsp
movq %r9, %r13
movq %r8, %rbx
movq %rcx, %rbp
movq %rdx, 0x20(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movl 0xf0(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0xe8(%rsp), %r12
movq 0xe0(%rsp), %rcx
movq %rcx, 0x38(%rsp)
leaq (%rcx,%r8), %rdi
shlq $0x3, %rdi
callq 0x95b0
movq %rax, 0x8(%rsp)
testq %rbx, %rbx
je 0x1b086
movq %r15, 0x48(%rsp)
movslq %ebp, %rax
movq %rax, 0xa0(%rsp)
testq %rax, %rax
jle 0x1b06b
movl 0x4(%rsp), %esi
testb $0x3, %sil
sete 0x3(%rsp)
leaq -0x1(%rbx), %rcx
movq %rcx, %rax
xorl %edx, %edx
divq %r12
imulq %r13, %rcx
movq %rcx, 0x10(%rsp)
movq %rbx, %rcx
shlq $0x20, %rcx
movabsq $-0x200000000, %r8      # imm = 0xFFFFFFFE00000000
movq %rcx, 0x88(%rsp)
addq %rcx, %r8
movq %r8, %r10
sarq $0x20, %r10
movabsq $-0x100000000, %r11     # imm = 0xFFFFFFFF00000000
movq 0x38(%rsp), %r9
imulq %r9, %r11
sarq $0x20, %r11
movslq %ebx, %rbp
movl %ebx, %ecx
subl %r9d, %ecx
movslq %ecx, %rdi
movq %rdi, %rcx
subq %rbp, %rcx
setge %r15b
movq %r9, %rdx
shlq $0x20, %rdx
movq %r13, 0x18(%rsp)
movabsq $0x100000000, %r13      # imm = 0x100000000
subq %rdx, %r13
movq %r13, %rdx
sarq $0x20, %rdx
movq %rdx, 0x60(%rsp)
testb $0x4, %sil
movl $0x1, %esi
cmoveq %r14, %rsi
movl $0x1, %edx
cmoveq %rdx, %r14
movq %r14, 0x98(%rsp)
movq 0x20(%rsp), %r14
movq 0x10(%rsp), %rdx
leaq (%r14,%rdx,8), %rdx
movq %rdx, 0x78(%rsp)
leaq 0x1(%rax), %rdx
imulq %rsi, %rdx
movq %rdx, 0x70(%rsp)
imulq %r12, %rax
movq %rax, 0x90(%rsp)
negq %rsi
sarq $0x1d, %r8
movq %r8, 0x68(%rsp)
movq %r10, 0x40(%rsp)
cmpq $-0x1, %r10
movq $-0x1, %r8
cmovlq %r10, %r8
leaq -0x8(,%rbx,8), %rax
movq 0x18(%rsp), %r10
imulq %r10, %rax
addq %r14, %rax
movq %rax, 0x10(%rsp)
leaq -0x10(,%rbx,8), %rdx
imulq %r10, %rdx
addq %r14, %rdx
movq %r9, %xmm0
punpckldq 0x1836f(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
orb 0x3(%rsp), %r15b
movb %r15b, 0x3(%rsp)
subpd 0x1836d(%rip), %xmm0    # 0x33190
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
movsd 0x18425(%rip), %xmm0    # 0x33260
divsd %xmm1, %xmm0
movq %r13, 0x80(%rsp)
sarq $0x1d, %r13
movq 0x8(%rsp), %rax
addq %rax, %r13
movq %r13, 0x58(%rsp)
leaq (,%r10,8), %r13
leaq (%r8,%r9), %r10
movq %r10, 0x28(%rsp)
incq %r8
movq %r8, 0x30(%rsp)
movq %r9, %r14
shlq $0x4, %r14
addq %rax, %r14
leaq (,%rdi,8), %r8
leaq (%r8,%r9,8), %r10
xorl %r8d, %r8d
addq %rax, %r10
movq %r10, 0x50(%rsp)
leaq (%rax,%r9,8), %r10
movslq %r9d, %r15
movq 0x40(%rsp), %r9
leaq 0x1(%r9), %rax
movq %rax, 0x18(%rsp)
movq 0x78(%rsp), %rax
movsd (%rax,%r8,8), %xmm1
movsd %xmm1, -0x8(%r10,%rbx,8)
testq %r9, %r9
movq %r8, 0x20(%rsp)
js 0x1aefa
movq 0x68(%rsp), %rax
movsd 0x8(%r10,%rax), %xmm1
movq 0x18(%rsp), %r9
xorl %r8d, %r8d
addsd (%rdx,%r8), %xmm1
movsd %xmm1, -0x8(%r10,%r9,8)
subq %r13, %r8
decq %r9
jg 0x1aed7
addq 0x10(%rsp), %r8
movq $-0x1, %r9
jmp 0x1aefe
leaq (%rax,%r8,8), %r8
testb $0x3, 0x4(%rsp)
je 0x1af36
cmpq %r11, %r9
jl 0x1af60
movq 0x8(%rsp), %rax
movq 0x28(%rsp), %r9
movsd 0x8(%rax,%r9,8), %xmm1
movq 0x30(%rsp), %r9
addsd (%r8), %xmm1
movsd %xmm1, -0x8(%r10,%r9,8)
decq %r9
cmpq %r11, %r9
jg 0x1af20
jmp 0x1af60
cmpq %r11, %r9
jl 0x1af60
movq 0x8(%rsp), %rax
movq 0x28(%rsp), %r8
movsd 0x8(%rax,%r8,8), %xmm1
movq 0x30(%rsp), %r8
movsd %xmm1, -0x8(%r10,%r8,8)
decq %r8
cmpq %r11, %r8
jg 0x1af51
cmpq %rdi, %r11
jge 0x1af82
movq %r11, %r8
movsd (%r10,%r8,8), %xmm1
subsd (%r14,%r8,8), %xmm1
movsd %xmm1, (%r10,%r8,8)
incq %r8
cmpq %r8, %rdi
jne 0x1af68
cmpb $0x0, 0x3(%rsp)
jne 0x1afba
movq 0x50(%rsp), %r8
xorl %r9d, %r9d
xorps %xmm1, %xmm1
cvtsi2sd %r9, %xmm1
movsd (%r8), %xmm2
mulsd -0x8(%r10,%rbx,8), %xmm1
subsd %xmm1, %xmm2
movsd %xmm2, (%r8)
decq %r9
addq $0x8, %r8
cmpq %r9, %rcx
jne 0x1af91
movq 0x80(%rsp), %rax
cmpq 0x88(%rsp), %rax
jge 0x1aff6
movq 0x38(%rsp), %rax
movq 0x58(%rsp), %r8
movsd -0x8(%r8,%rax,8), %xmm1
movq 0x60(%rsp), %r8
addsd (%r10,%r8,8), %xmm1
movsd %xmm1, (%r10,%r8,8)
incq %r8
cmpq %r8, %rbp
jne 0x1afe2
movq 0x48(%rsp), %rax
movq 0x70(%rsp), %r8
leaq (%rax,%r8,8), %r8
movq 0x90(%rsp), %rax
testq %rax, %rax
js 0x1b035
movsd (%r10,%rax,8), %xmm1
movq %rax, %r9
subq %r15, %r9
subsd (%r10,%r9,8), %xmm1
leaq (%r8,%rsi,8), %r8
mulsd %xmm0, %xmm1
movsd %xmm1, (%r8)
subq %r12, %rax
jns 0x1b011
movq 0x98(%rsp), %rax
leaq (%r8,%rax,8), %rax
movq %rax, 0x48(%rsp)
movq 0x20(%rsp), %r8
incq %r8
addq $0x8, 0x10(%rsp)
addq $0x8, %rdx
cmpq 0xa0(%rsp), %r8
movq 0x40(%rsp), %r9
jne 0x1aea7
movq 0x8(%rsp), %rdi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9580
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq