// File: /workspace/github_cpp_makefile_star2_O3/matteotiziano[P]simple-wavelet/wavelet.cpp
// Function: Wavelet<double>::Wavedec(Matrix<double> const&, unsigned long) const
Decomposition2D<T> Wavelet<T>::Wavedec(const Matrix<T>& x, size_t num_levels) const {
  if (x.GetNumRows() < (1 << num_levels) || x.GetNumColumns() < (1 << num_levels)) {
    throw std::invalid_argument("Wavelet::Wavedec");
  }
  Decomposition2D<T> decomposition(num_levels);
  Matrix<T> a = x;
  for (size_t k = 0; k < num_levels; k++) {
    Matrix<T> ak, hk, vk, dk;
    Dwt(a, ak, hk, vk, dk);
    // Save approximation coefficients for next iteration
    a = ak;
    // Store subbands obtained at current level k to Decomposition object
    decomposition.SetDetcoef(dk, kDiagonalSubband, k);
    decomposition.SetDetcoef(vk, kVerticalSubband, k);
    decomposition.SetDetcoef(hk, kHorizontalSubband, k);
  }
  // Store final approximation
  decomposition.SetAppcoef(a);
  return decomposition;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, 0x8(%rsp)
movq %rdx, %rdi
callq 0x6390
movl $0x1, %edx
movl %r13d, %ecx
shll %cl, %edx
movslq %edx, %r12
cmpq %r12, %rax
jb 0x448d
movq %r14, %rdi
callq 0x6394
cmpq %r12, %rax
jb 0x448d
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x3640
movups (%r14), %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, -0x10(%rdi)
addq $0x10, %r14
movq %r14, %rsi
callq 0x3034
movq %r13, 0x18(%rsp)
testq %r13, %r13
je 0x444e
leaq 0x18(%r15), %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
leaq 0x48(%rsp), %rdi
leaq 0xc0(%rsp), %r14
leaq 0x98(%rsp), %r13
leaq 0x70(%rsp), %rbp
movq %rdi, %rbx
callq 0x6366
movq %r14, %rdi
callq 0x6366
movq %r13, %rdi
callq 0x6366
movq %rbp, %rdi
callq 0x6366
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
movq %r15, %rdx
movq %rbx, %rcx
movq %r14, %r8
callq 0x470c
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r13, %rcx
movq %rbp, %r8
callq 0x470c
movups 0x48(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x354e
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r12, %rcx
callq 0x3856
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movl $0x1, %edx
movq %r12, %rcx
callq 0x3856
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl $0x2, %edx
movq %r12, %rcx
callq 0x3856
movq %rbp, %rdi
callq 0x6376
movq %r13, %rdi
callq 0x6376
movq %r14, %rdi
callq 0x6376
movq %rbx, %rdi
callq 0x6376
movq %rbx, %rdi
incq %r12
cmpq %r12, 0x18(%rsp)
jne 0x437a
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdi
movaps 0x20(%rsp), %xmm0
movups %xmm0, -0x28(%rdi)
addq $-0x18, %rdi
leaq 0x30(%rsp), %rsi
callq 0x354e
leaq 0x20(%rsp), %rdi
callq 0x6376
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20c0
movq %rax, %rbx
leaq 0x4da9(%rip), %rsi      # 0x924a
movq %rax, %rdi
callq 0x22f0
movq 0x9b30(%rip), %rsi      # 0xdfe0
movq 0x9b09(%rip), %rdx      # 0xdfc0
movq %rbx, %rdi
callq 0x22b0
jmp 0x44d3
movq %rax, %r14
jmp 0x4522
movq %rax, %r14
movq %rbx, %rdi
callq 0x2140
jmp 0x452c
movq %rax, %r14
jmp 0x4518
movq %rax, %r14
jmp 0x450e
movq %rax, %r14
jmp 0x4501
movq %rax, %r14
jmp 0x44f4
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x6376
leaq 0x98(%rsp), %rdi
callq 0x6376
leaq 0xc0(%rsp), %rdi
callq 0x6376
leaq 0x48(%rsp), %rdi
callq 0x6376
leaq 0x20(%rsp), %rdi
callq 0x6376
movq 0x8(%rsp), %rdi
callq 0x3740
movq %r14, %rdi
callq 0x22d0