// File: schaefed[P]Ndarray/src/ndarray.hpp
// Function: Ndarray<long, 2ul> NdarrayBase<long, 1ul>::broadcastTo<2ul>(std::array<unsigned long, 2ul>) const
Ndarray<T, M> broadcastTo(const array<size_t, M> newshape) const {
		static_assert(N <= M, "Can only broadcast to equal or higher dimensionality!");

	 	auto newstrides = filledArray<size_t, M>(0);
		auto offset = newshape.size() - shape.size();

		for (int64_t i=shape.size()-1; i>=0; --i){
			if (newshape[i+offset] == shape[i]){
				newstrides[i+offset] = strides[i];
			} else if (shape[i] != 1){
				throw DimensionError("Operands could not be braodcast together");
			}
		}
		return Ndarray<T, M>(product(newshape), this->offset, this->data, newshape, newstrides);
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0xe0(%rbp)
movq %rdi, %rax
movq %rax, -0xd8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x10(%rbp)
movq %rsi, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0xc860
movq %rax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x87e0
movq -0xd0(%rbp), %rdi
movq %rax, -0xc8(%rbp)
addq $0x20, %rdi
callq 0xa810
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movq -0xc8(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x38(%rbp)
addq $0x20, %rdi
callq 0xa810
subq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jl 0x6bb3
movq -0x40(%rbp), %rsi
addq -0x38(%rbp), %rsi
leaq -0x18(%rbp), %rdi
callq 0x87f0
movq -0xd0(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
addq $0x20, %rdi
movq -0x40(%rbp), %rsi
callq 0x96d0
movq %rax, %rcx
movq -0xe8(%rbp), %rax
cmpq (%rcx), %rax
jne 0x6ac8
movq -0xd0(%rbp), %rdi
addq $0x28, %rdi
movq -0x40(%rbp), %rsi
callq 0x96d0
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
movq -0x40(%rbp), %rsi
addq -0x38(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x5fe0
movq -0xf0(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x6ba0
movq -0xd0(%rbp), %rdi
addq $0x20, %rdi
movq -0x40(%rbp), %rsi
callq 0x96d0
cmpq $0x1, (%rax)
je 0x6b9e
movb $0x1, -0x75(%rbp)
movl $0x28, %edi
callq 0x20c0
movq %rax, -0x100(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x2280
movq -0xf8(%rbp), %rdx
leaq 0x6b61(%rip), %rsi      # 0xd67a
leaq -0x60(%rbp), %rdi
callq 0x8fb0
jmp 0x6b24
movq -0x100(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xc8b0
jmp 0x6b36
movq -0x100(%rbp), %rdi
movb $0x0, -0x75(%rbp)
leaq 0xd228(%rip), %rsi      # 0x13d70
leaq 0x5dd1(%rip), %rdx      # 0xc920
callq 0x2260
jmp 0x6c92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x6b7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x20f0
leaq -0x61(%rbp), %rdi
callq 0x21c0
testb $0x1, -0x75(%rbp)
jne 0x6b8d
jmp 0x6b99
movq -0x100(%rbp), %rdi
callq 0x2130
jmp 0x6c89
jmp 0x6ba0
jmp 0x6ba2
movq -0x40(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x6a41
movups -0x18(%rbp), %xmm0
movaps %xmm0, -0x90(%rbp)
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x52f0
movq -0xd0(%rbp), %rsi
movq %rax, -0x118(%rbp)
movq 0x8(%rsi), %rax
movq %rax, -0x110(%rbp)
addq $0x10, %rsi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x7120
movq -0xe0(%rbp), %rdi
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdx
movq -0x108(%rbp), %rcx
movups -0x18(%rbp), %xmm0
movaps %xmm0, -0xb0(%rbp)
movups -0x30(%rbp), %xmm0
movaps %xmm0, -0xc0(%rbp)
movq -0xb0(%rbp), %r8
movq -0xa8(%rbp), %r9
movaps -0xc0(%rbp), %xmm0
movq %rsp, %rax
movups %xmm0, (%rax)
callq 0x7cd0
jmp 0x6c55
leaq -0xa0(%rbp), %rdi
callq 0x6d20
movq -0xd8(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x6d20
movq -0x70(%rbp), %rdi
callq 0x2270
nopw %cs:(%rax,%rax)
nopl (%rax)