// File: /workspace/github_cpp_makefile_star2_O1/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 0x62ac
movl $0x1, %edx
movl %r13d, %ecx
shll %cl, %edx
movslq %edx, %r12
cmpq %r12, %rax
jb 0x43e9
movq %r14, %rdi
callq 0x62b0
cmpq %r12, %rax
jb 0x43e9
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x3660
movups (%r14), %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, -0x10(%rdi)
addq $0x10, %r14
movq %r14, %rsi
callq 0x3062
movq %r13, 0x18(%rsp)
testq %r13, %r13
je 0x43aa
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 0x6282
movq %r14, %rdi
callq 0x6282
movq %r13, %rdi
callq 0x6282
movq %rbp, %rdi
callq 0x6282
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
movq %r15, %rdx
movq %rbx, %rcx
movq %r14, %r8
callq 0x4668
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r13, %rcx
movq %rbp, %r8
callq 0x4668
movups 0x48(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x357c
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r12, %rcx
callq 0x3870
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movl $0x1, %edx
movq %r12, %rcx
callq 0x3870
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl $0x2, %edx
movq %r12, %rcx
callq 0x3870
movq %rbp, %rdi
callq 0x6292
movq %r13, %rdi
callq 0x6292
movq %r14, %rdi
callq 0x6292
movq %rbx, %rdi
callq 0x6292
movq %rbx, %rdi
incq %r12
cmpq %r12, 0x18(%rsp)
jne 0x42d6
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdi
movaps 0x20(%rsp), %xmm0
movups %xmm0, -0x28(%rdi)
addq $-0x18, %rdi
leaq 0x30(%rsp), %rsi
callq 0x357c
leaq 0x20(%rsp), %rdi
callq 0x6292
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 0x4ded(%rip), %rsi      # 0x91ea
movq %rax, %rdi
callq 0x22f0
movq 0x9bd4(%rip), %rsi      # 0xdfe0
movq 0x9bad(%rip), %rdx      # 0xdfc0
movq %rbx, %rdi
callq 0x22b0
jmp 0x442f
movq %rax, %r14
jmp 0x447e
movq %rax, %r14
movq %rbx, %rdi
callq 0x2140
jmp 0x4488
movq %rax, %r14
jmp 0x4474
movq %rax, %r14
jmp 0x446a
movq %rax, %r14
jmp 0x445d
movq %rax, %r14
jmp 0x4450
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x6292
leaq 0x98(%rsp), %rdi
callq 0x6292
leaq 0xc0(%rsp), %rdi
callq 0x6292
leaq 0x48(%rsp), %rdi
callq 0x6292
leaq 0x20(%rsp), %rdi
callq 0x6292
movq 0x8(%rsp), %rdi
callq 0x375a
movq %r14, %rdi
callq 0x22d0