// File: /workspace/github_cpp_makefile_star2_O2/matteotiziano[P]simple-wavelet/wavelet.cpp
// Function: Wavelet<double>::Convdown(Matrix<double> const&, std::vector<double, std::allocator<double>> const&, Matrix<double>&, Matrix<double>&) const
void Wavelet<T>::Convdown(const Matrix<T>& x, const std::vector<T>& f, Matrix<T>& xL, Matrix<T>& xH) const {
  // Compute size of subbands
  const size_t num_rows_subband = static_cast<size_t>(std::ceil(static_cast<double>(x.GetNumRows()) / 2.0));
  const size_t num_cols_subband = static_cast<size_t>(std::ceil(static_cast<double>(x.GetNumColumns()) / 2.0));
  // Convolve and decimate each row with the chosen filter
  Matrix<T> tmp(x.GetNumRows(), num_cols_subband);
  for (size_t i = 0; i < x.GetNumRows(); i++) {
    const std::vector<T> row = Convdown(x.GetRow(i), f);
    tmp.SetRow(row, i);
  }
  // Compute high-pass subband of pre-filtered tmp matrix
  xH = Matrix<T>(num_rows_subband, num_cols_subband);
  for (size_t j = 0; j < tmp.GetNumColumns(); j++) {
    const std::vector<T> column = Convdown(tmp.GetColumn(j), Hi_D_);
    xH.SetColumn(column, j);
  }
  // Compute low-pass subband of pre-filtered tmp matrix
  xL = Matrix<T>(num_rows_subband, num_cols_subband);
  for (size_t j = 0; j < tmp.GetNumColumns(); j++) {
    const std::vector<T> column = Convdown(tmp.GetColumn(j), Lo_D_);
    xL.SetColumn(column, j);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %r14
movq %rsi, %rdi
callq 0x5a94
movq %rax, %xmm1
punpckldq 0x4209(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4211(%rip), %xmm1     # 0x8150
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x420d(%rip), %xmm0     # 0x8160
callq 0x2050
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x41fc(%rip), %xmm0     # 0x8168
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x8(%rsp)
movq %r12, %rdi
callq 0x5a98
movq %rax, %xmm1
punpckldq 0x41af(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x41b7(%rip), %xmm1     # 0x8150
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x41b3(%rip), %xmm0     # 0x8160
callq 0x2050
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x41a2(%rip), %xmm0     # 0x8168
cvttsd2si %xmm0, %rbx
andq %rcx, %rbx
orq %rax, %rbx
movq %r12, %rdi
callq 0x5a94
leaq 0x60(%rsp), %rdi
xorpd %xmm0, %xmm0
movq %rax, %rsi
movq %rbx, (%rsp)
movq %rbx, %rdx
callq 0x5968
xorl %ebx, %ebx
leaq 0x48(%rsp), %r15
leaq 0x20(%rsp), %r13
movq %r12, %rdi
callq 0x5a94
cmpq %rax, %rbx
jae 0x404e
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5f36
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x382a
movq %r15, %rdi
callq 0x2d52
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x5d70
movq %r13, %rdi
callq 0x2d52
incq %rbx
jmp 0x3ffd
leaq 0x20(%rsp), %rdi
xorpd %xmm0, %xmm0
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
callq 0x5968
leaq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x3458
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x5a8a
leaq 0x18(%r14), %r13
xorl %ebx, %ebx
leaq 0x60(%rsp), %rbp
leaq 0x48(%rsp), %r15
movq %rbp, %rdi
callq 0x5a98
cmpq %rax, %rbx
jae 0x40e2
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x5fa6
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x382a
movq %r15, %rdi
callq 0x2d52
movq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5e26
movq %r12, %rdi
callq 0x2d52
incq %rbx
jmp 0x4091
leaq 0x20(%rsp), %rdi
xorpd %xmm0, %xmm0
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
callq 0x5968
leaq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x3458
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x5a8a
xorl %ebx, %ebx
leaq 0x60(%rsp), %r12
leaq 0x48(%rsp), %r13
movq %r12, %rdi
callq 0x5a98
cmpq %rax, %rbx
jae 0x4172
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5fa6
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x382a
movq %r13, %rdi
callq 0x2d52
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x5e26
movq %r15, %rdi
callq 0x2d52
incq %rbx
jmp 0x4121
leaq 0x60(%rsp), %rdi
callq 0x5a8a
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4192
jmp 0x41ce
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5a8a
jmp 0x41d1
jmp 0x41ce
jmp 0x41af
jmp 0x41b9
jmp 0x41ce
jmp 0x41af
jmp 0x41b9
jmp 0x41ce
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x41c1
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x2d52
jmp 0x41d1
jmp 0x41ce
jmp 0x41ce
jmp 0x41ce
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x5a8a
movq %rbx, %rdi
callq 0x22c0
nop