// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0x8(%rsp), %rbx
pushq $0x8
popq %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x231c
leaq 0x90(%rsp), %rcx
andq $0x0, 0x8(%rcx)
movq (%rbx), %rsi
leaq 0x357(%rip), %rax       # 0x41af
movq %rax, (%rcx)
leaq 0x1274(%rip), %rax      # 0x50d6
movq %rax, 0x18(%rcx)
leaq 0x1271(%rip), %rax      # 0x50de
movq %rax, 0x10(%rcx)
leaq 0xb0(%rsp), %rdi
movq %r14, %rdx
callq 0x493d
leaq 0x90(%rsp), %rdi
callq 0x41b0
leaq 0x50(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
pushq $0x8
popq %rcx
movq %rcx, %rdx
callq 0x49ce
leaq 0x38(%rsp), %r14
leaq 0x38(%rsp), %rbx
xorl %r15d, %r15d
leaq 0x20(%rsp), %r12
leaq 0x50(%rsp), %r13
cmpq 0x70(%rsp), %r15
jae 0x3f38
xorl %ebp, %ebp
cmpq 0x78(%rsp), %rbp
jae 0x3f33
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x41cc
movq 0x30(%rsp), %rax
movq (%rax,%rbp,8), %rax
movq 0x8(%rsp), %rcx
cmpq (%rcx,%rbp,8), %rax
jne 0x3feb
movq %r14, %rdi
callq 0x4adc
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x41cc
movq %r12, %rdi
movq %rbp, %rsi
callq 0x4266
movq (%rax), %rax
movq 0x8(%rsp), %rcx
cmpq (%rcx,%rbp,8), %rax
jne 0x400a
movq %rbx, %rdi
callq 0x4adc
incq %rbp
jmp 0x3ec6
incq %r15
jmp 0x3ebd
leaq 0x80(%rsp), %rax
movq -0x20(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
leaq 0x70(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x431e
xorl %r14d, %r14d
leaq 0x20(%rsp), %rbx
movq 0x28(%rsp), %rax
cmpq 0xe8(%rsp), %rax
je 0x3fb8
movq (%rax), %rcx
movq %r14, %rax
xorl %edx, %edx
divq 0x70(%rsp)
movq 0x8(%rsp), %rax
cmpq (%rax,%rdx,8), %rcx
jne 0x4029
movq %rdx, %r14
incq %r14
movq %rbx, %rdi
callq 0x55d8
jmp 0x3f7d
leaq 0x68(%rsp), %rdi
callq 0x4adc
leaq 0xc8(%rsp), %rdi
callq 0x4adc
leaq 0x8(%rsp), %rdi
callq 0x4c0c
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2427(%rip), %rdi      # 0x6419
leaq 0x204f(%rip), %rsi      # 0x6048
leaq 0x243f(%rip), %rcx      # 0x643f
movl $0x90, %edx
callq 0x20c0
leaq 0x2446(%rip), %rdi      # 0x6457
leaq 0x2030(%rip), %rsi      # 0x6048
leaq 0x2420(%rip), %rcx      # 0x643f
movl $0x91, %edx
callq 0x20c0
leaq 0x2442(%rip), %rdi      # 0x6472
leaq 0x2011(%rip), %rsi      # 0x6048
leaq 0x2401(%rip), %rcx      # 0x643f
movl $0x99, %edx
callq 0x20c0
jmp 0x4072
movq %rax, %r14
jmp 0x407f
movq %rax, %r14
leaq 0x90(%rsp), %rdi
callq 0x41b0
jmp 0x408c
jmp 0x4072
movq %rax, %r14
movq %rbx, %rdi
callq 0x4adc
jmp 0x4075
jmp 0x4072
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x4adc
leaq 0xc8(%rsp), %rdi
callq 0x4adc
leaq 0x8(%rsp), %rdi
callq 0x4c0c
movq %r14, %rdi
callq 0x21c0