// File: schaefed[P]Ndarray/test/test_ndarray.cpp
// Function: testBroadcasting()
void testBroadcasting(){
	array<size_t, 1> shape = {8};
	vector<int64_t> basevec  = range(shape[0]);
	auto array1 = ndarray<int64_t, 1>(basevec.data(), shape);
	auto array2 = array1.broadcastTo<2>({8,8});

	for (size_t i=0; i<array2.shape[0]; i++){
		for (size_t j=0; j<array2.shape[1]; j++){
			assert (array2[i].data.get()[j] == basevec[j]); // broadcasting incorrect
			assert (array2[i][j] == basevec[j]); // broadcasting incorrect
		}
	}

	// should be moved to testIteration at one point in time...
	size_t idx = 0;
	for (auto e: array2){
		idx %= array2.shape[0];
		assert(e == basevec[idx]);
		idx++;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq $0x8, -0x8(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x8(%rbp), %rdi
callq 0x63a0
movq (%rax), %rsi
leaq -0x20(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x2400
movq -0x1c8(%rbp), %rdi
callq 0x54b0
movq %rax, -0x1c0(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x76b(%rip), %rsi       # 0x54d0
leaq -0x78(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x54e0
movq -0x1c0(%rbp), %rsi
movq -0x1b8(%rbp), %rcx
movq -0x58(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x6880
jmp 0x4d92
leaq -0x78(%rbp), %rdi
callq 0x5570
movq $0x8, -0xd8(%rbp)
movq $0x8, -0xd0(%rbp)
movq -0xd8(%rbp), %rdx
movq -0xd0(%rbp), %rcx
leaq -0xc8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x69b0
jmp 0x4dd1
movq $0x0, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0xc8(%rbp), %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5fe0
movq %rax, %rcx
movq -0x1d0(%rbp), %rax
cmpq (%rcx), %rax
jae 0x5006
movq $0x0, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0xc8(%rbp), %rdi
addq $0x20, %rdi
movl $0x1, %esi
callq 0x5fe0
movq %rax, %rcx
movq -0x1d8(%rbp), %rax
cmpq (%rcx), %rax
jae 0x4fed
movq -0xe0(%rbp), %rdx
leaq -0x118(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x5590
jmp 0x4e6e
leaq -0x118(%rbp), %rdi
addq $0x10, %rdi
callq 0x6ca0
movq -0xe8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1e0(%rbp)
movq -0xe8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5270
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x4eb1
jmp 0x4f15
leaq 0x85ad(%rip), %rdi      # 0xd465
leaq 0x81c1(%rip), %rsi      # 0xd080
movl $0x90, %edx
leaq 0x85c0(%rip), %rcx      # 0xd48b
callq 0x2100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5570
jmp 0x5174
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x516b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x515f
leaq -0x118(%rbp), %rdi
callq 0x6010
movq -0xe0(%rbp), %rdx
leaq -0x148(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x5590
jmp 0x4f3d
movq -0xe8(%rbp), %rsi
leaq -0x148(%rbp), %rdi
callq 0x5750
movq %rax, -0x1e8(%rbp)
jmp 0x4f59
movq -0x1e8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1f0(%rbp)
movq -0xe8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5270
movq %rax, %rcx
movq -0x1f0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x4f8b
jmp 0x4fca
leaq 0x8511(%rip), %rdi      # 0xd4a3
leaq 0x80e7(%rip), %rsi      # 0xd080
movl $0x91, %edx
leaq 0x84e6(%rip), %rcx      # 0xd48b
callq 0x2100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x6010
jmp 0x515f
leaq -0x148(%rbp), %rdi
callq 0x6010
movq -0xe8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe8(%rbp)
jmp 0x4e1c
jmp 0x4fef
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x4ddc
movq $0x0, -0x150(%rbp)
leaq -0xc8(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x58a0
jmp 0x5034
movq -0x158(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
callq 0x58f0
jmp 0x5049
jmp 0x504b
leaq -0x180(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x59a0
movb %al, -0x1f1(%rbp)
jmp 0x5066
movb -0x1f1(%rbp), %al
testb $0x1, %al
jne 0x5075
jmp 0x5138
leaq -0x180(%rbp), %rdi
callq 0x59d0
movq %rax, -0x200(%rbp)
jmp 0x508a
movq -0x200(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1b0(%rbp)
leaq -0xc8(%rbp), %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5fe0
movq (%rax), %rcx
movq -0x150(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, -0x150(%rbp)
movq -0x1b0(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x150(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5270
movq %rax, %rcx
movq -0x208(%rbp), %rax
cmpq (%rcx), %rax
jne 0x50f4
jmp 0x5113
leaq 0x83c3(%rip), %rdi      # 0xd4be
leaq 0x7f7e(%rip), %rsi      # 0xd080
movl $0x99, %edx
leaq 0x837d(%rip), %rcx      # 0xd48b
callq 0x2100
movq -0x150(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x150(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x59f0
jmp 0x5133
jmp 0x504b
leaq -0xc8(%rbp), %rdi
callq 0x5880
leaq -0x50(%rbp), %rdi
callq 0x6010
leaq -0x20(%rbp), %rdi
callq 0x5290
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
leaq -0xc8(%rbp), %rdi
callq 0x5880
leaq -0x50(%rbp), %rdi
callq 0x6010
leaq -0x20(%rbp), %rdi
callq 0x5290
movq -0x80(%rbp), %rdi
callq 0x2270
nopw %cs:(%rax,%rax)