// File: schaefed[P]Ndarray/test/test_ndarray.cpp
// Function: testIterator()
void testIterator(){
	array<size_t, 2> shape = {4, 4};
	vector<int64_t> basevec  = range(product<size_t>(shape));
	auto array = ndarray<int64_t, 2>(basevec.data(), shape);
	Ndarray<int64_t,2> test;

	auto tester = [](auto array, vector<int64_t> check){
		int64_t i = 0;
		for (auto e: array){
			assert (e == check[i++]); // Wrong iteration element
		}
	};

	tester(array, range(16));
	tester(array[3], range(12, 16));
	tester(array[Slice<>(0, 2)], range(8));
	tester(array[Slice<>(0, 4, 2)],
		   concat<int64_t>({range(4), range(8, 12)})
		   );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movups 0x8a6e(%rip), %xmm0     # 0xd040
movaps %xmm0, -0x10(%rbp)
movaps -0x10(%rbp), %xmm0
movaps %xmm0, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x52f0
movq %rax, %rsi
leaq -0x28(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x2400
movq -0x2f8(%rbp), %rdi
callq 0x54b0
movq %rax, -0x2f0(%rbp)
movaps -0x10(%rbp), %xmm0
movaps %xmm0, -0x90(%rbp)
leaq 0xead(%rip), %rsi       # 0x54d0
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x54e0
movq -0x2f0(%rbp), %rsi
movq -0x2e8(%rbp), %r8
movq -0x90(%rbp), %rdx
movq -0x88(%rbp), %rcx
leaq -0x80(%rbp), %rdi
callq 0x5330
jmp 0x465d
leaq -0xb0(%rbp), %rdi
callq 0x5570
leaq -0x100(%rbp), %rdi
callq 0x6690
jmp 0x4677
leaq -0x148(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x66b0
jmp 0x4689
leaq -0x160(%rbp), %rdi
movl $0x10, %esi
callq 0x2400
jmp 0x469c
leaq -0x101(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x160(%rbp), %rdx
callq 0x4b50
jmp 0x46b8
leaq -0x160(%rbp), %rdi
callq 0x5290
leaq -0x148(%rbp), %rdi
callq 0x5880
leaq -0x190(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x3, %edx
callq 0x5590
jmp 0x46e7
leaq -0x1a8(%rbp), %rdi
movl $0xc, %esi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x24e0
jmp 0x4704
leaq -0x101(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x1a8(%rbp), %rdx
callq 0x4c30
jmp 0x4720
leaq -0x1a8(%rbp), %rdi
callq 0x5290
leaq -0x190(%rbp), %rdi
callq 0x6010
xorl %eax, %eax
movl %eax, %esi
leaq -0x208(%rbp), %rdi
movl $0x2, %edx
movl $0x1, %ecx
callq 0x6360
jmp 0x4754
movups -0x208(%rbp), %xmm0
movups -0x1f8(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x1e8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x63d0
jmp 0x477e
leaq -0x220(%rbp), %rdi
movl $0x8, %esi
callq 0x2400
jmp 0x4791
leaq -0x101(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
leaq -0x220(%rbp), %rdx
callq 0x4b50
jmp 0x47ad
leaq -0x220(%rbp), %rdi
callq 0x5290
leaq -0x1e8(%rbp), %rdi
callq 0x5880
xorl %eax, %eax
movl %eax, %esi
leaq -0x280(%rbp), %rdi
movl $0x4, %edx
movl $0x2, %ecx
callq 0x6360
jmp 0x47e1
movups -0x280(%rbp), %xmm0
movups -0x270(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x260(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x63d0
jmp 0x480b
leaq -0x2d8(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
movl $0x4, %esi
callq 0x2400
jmp 0x4825
leaq -0x2c0(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
movl $0x8, %esi
movl $0xc, %edx
movl $0x1, %ecx
callq 0x24e0
jmp 0x4849
leaq -0x2d8(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq $0x2, -0x2a0(%rbp)
movq -0x2a8(%rbp), %rsi
movq -0x2a0(%rbp), %rdx
leaq -0x298(%rbp), %rdi
callq 0x66e0
jmp 0x487e
leaq -0x101(%rbp), %rdi
leaq -0x260(%rbp), %rsi
leaq -0x298(%rbp), %rdx
callq 0x4b50
jmp 0x489a
leaq -0x298(%rbp), %rdi
callq 0x5290
leaq -0x2d8(%rbp), %rax
movq %rax, -0x308(%rbp)
addq $0x30, %rax
movq %rax, -0x300(%rbp)
movq -0x300(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x310(%rbp)
callq 0x5290
movq -0x308(%rbp), %rcx
movq -0x310(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x300(%rbp)
jne 0x48bf
leaq -0x260(%rbp), %rdi
callq 0x5880
leaq -0x100(%rbp), %rdi
callq 0x5880
leaq -0x80(%rbp), %rdi
callq 0x5880
leaq -0x28(%rbp), %rdi
callq 0x5290
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x5570
jmp 0x4b3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x4b32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x4b26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x49a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x5290
leaq -0x148(%rbp), %rdi
callq 0x5880
jmp 0x4b26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x49e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x5290
leaq -0x190(%rbp), %rdi
callq 0x6010
jmp 0x4b26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x4a2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x5290
leaq -0x1e8(%rbp), %rdi
callq 0x5880
jmp 0x4b26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
movq -0x2e0(%rbp), %rax
leaq -0x2d8(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x318(%rbp)
je 0x4a9a
movq -0x318(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x320(%rbp)
callq 0x5290
movq -0x320(%rbp), %rax
leaq -0x2d8(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x318(%rbp)
jne 0x4a69
jmp 0x4b1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x4ace
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x5290
leaq -0x2d8(%rbp), %rax
movq %rax, -0x330(%rbp)
addq $0x30, %rax
movq %rax, -0x328(%rbp)
movq -0x328(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x338(%rbp)
callq 0x5290
movq -0x330(%rbp), %rcx
movq -0x338(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x328(%rbp)
jne 0x4ae7
jmp 0x4b1a
leaq -0x260(%rbp), %rdi
callq 0x5880
leaq -0x100(%rbp), %rdi
callq 0x5880
leaq -0x80(%rbp), %rdi
callq 0x5880
leaq -0x28(%rbp), %rdi
callq 0x5290
movq -0xb8(%rbp), %rdi
callq 0x2270