// File: matteotiziano[P]simple-wavelet/./vector.h
// Function: std::vector<double, std::allocator<double>> Vector::Conv<double>(std::vector<double, std::allocator<double>> const&, std::vector<double, std::allocator<double>> const&, Vector::ConvolutionType)
std::vector<T> Conv(const std::vector<T>& vector, const std::vector<T>& filter, ConvolutionType convolutionType = kFullConvolution) {
    const size_t vector_size = vector.size();
    const size_t filter_size = filter.size();
    if (filter_size > vector_size) {
      throw std::invalid_argument("Conv");
    }
    // Compute convolution
    size_t minI = 0;
    size_t maxI = vector_size + filter_size - 1;
    if (convolutionType == kSameConvolution) {
      minI = filter_size / 2;
      maxI = minI + vector_size;
    }
    else if (convolutionType == kValidConvolution) {
      minI = filter_size - 1;
      maxI = vector_size;
    }
    std::vector<T> output;
    output.reserve(maxI - minI);
    for (size_t i = minI; i < maxI; i++) {
      const size_t minJ = (i < filter_size - 1) ? 0 : i - filter_size + 1;
      const size_t maxJ = (i >= vector_size - 1) ? vector_size : i + 1;
      T value = static_cast<T>(0);
      for (size_t j = minJ; j < maxJ; j++) {
        value += vector[j] * filter[i - j];
      }
      output.push_back(value);
    }
    return output;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x90(%rbp)
movq %rdi, %rax
movq %rax, -0x88(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x31e0
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x31e0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0x7eeb
movl $0x10, %edi
callq 0x20e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x98(%rbp)
leaq 0xa43f(%rip), %rsi      # 0x122ec
callq 0x2380
jmp 0x7eb4
movq -0x98(%rbp), %rdi
movq 0x1211e(%rip), %rsi     # 0x19fe0
movq 0x120f7(%rip), %rdx     # 0x19fc0
callq 0x2330
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2170
jmp 0x80c4
movq $0x0, -0x48(%rbp)
movq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x7f22
movq -0x30(%rbp), %rax
shrq %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x7f3e
cmpl $0x2, -0x1c(%rbp)
jne 0x7f3c
movq -0x30(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x7f3e
movq -0x90(%rbp), %rdi
movb $0x0, -0x51(%rbp)
callq 0x5970
movq -0x90(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rax
subq %rax, %rsi
callq 0x85d0
jmp 0x7f67
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x809e
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x7f99
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
jmp 0x7fac
movq -0x60(%rbp), %rax
subq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jb 0x7fd5
movq -0x28(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x7fe4
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x70(%rbp), %rax
jae 0x8079
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x8740
movsd (%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rsi
subq -0x80(%rbp), %rsi
callq 0x8740
movsd -0xb0(%rbp), %xmm0
movsd (%rax), %xmm2
movsd -0x78(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x7fff
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x3430
jmp 0x80c4
movq -0x90(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x86d0
jmp 0x808b
jmp 0x808d
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x7f6f
movb $0x1, -0x51(%rbp)
testb $0x1, -0x51(%rbp)
jne 0x80b4
movq -0x90(%rbp), %rdi
callq 0x3430
movq -0x88(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x2350
nopl (%rax)