// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rsp, %rbx
leaq 0x48(%rsp), %rdx
movl $0x8, %esi
movq %rbx, %rdi
callq 0x4d92
movdqa 0x25c8(%rip), %xmm0     # 0x7010
xorl %eax, %eax
movq (%rbx), %rsi
movdqa 0x25db(%rip), %xmm1     # 0x7030
movdqu %xmm0, (%rsi,%rax,8)
addq $0x2, %rax
paddq %xmm1, %xmm0
cmpq $0x8, %rax
jne 0x4a55
leaq 0x88(%rsp), %rcx
movq $0x0, 0x8(%rcx)
leaq 0x4bb(%rip), %rax       # 0x4f3a
movq %rax, (%rcx)
leaq 0x14e1(%rip), %rax      # 0x5f6a
movq %rax, 0x18(%rcx)
leaq 0x14de(%rip), %rax      # 0x5f72
movq %rax, 0x10(%rcx)
leaq 0xa8(%rsp), %rdi
movl $0x8, %edx
callq 0x57f4
movq 0x98(%rsp), %rax
testq %rax, %rax
je 0x4ac9
leaq 0x88(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x48(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movl $0x8, %edx
movl $0x8, %ecx
callq 0x58ee
movq 0x68(%rsp), %rax
testq %rax, %rax
je 0x4bc0
leaq 0x48(%rsp), %rbx
movq 0x28(%rbx), %rcx
xorl %r14d, %r14d
leaq 0x18(%rsp), %r15
testq %rcx, %rcx
je 0x4bb2
xorl %r13d, %r13d
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4f3c
movq 0x28(%rsp), %rax
movq (%rax,%r13,8), %rax
movq (%rsp), %rcx
cmpq (%rcx,%r13,8), %rax
jne 0x4ca6
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4b44
callq 0x5a38
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4f3c
movq %r13, %r12
sarq $0x3f, %r12
andq 0x38(%rsp), %r12
addq %r13, %r12
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x6194
imulq 0x40(%rsp), %r12
movq 0x28(%rsp), %rax
movq (%rax,%r12,8), %rax
movq (%rsp), %rcx
cmpq (%rcx,%r13,8), %rax
jne 0x4c87
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4b9a
callq 0x5a38
incq %r13
movq 0x70(%rsp), %rcx
cmpq %rcx, %r13
jb 0x4b10
movq 0x68(%rsp), %rax
jmp 0x4bb4
xorl %ecx, %ecx
incq %r14
cmpq %rax, %r14
jb 0x4b04
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rcx
leaq 0x78(%rsp), %rdx
movq %rcx, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x508c
xorl %r14d, %r14d
leaq 0x18(%rsp), %rbx
movq 0x20(%rsp), %rax
cmpq 0xe0(%rsp), %rax
je 0x4c3f
movq (%rax), %rcx
movq %r14, %rax
xorl %edx, %edx
divq 0x68(%rsp)
movq (%rsp), %rax
cmpq (%rax,%rdx,8), %rcx
jne 0x4cc5
movq %rdx, %r14
incq %r14
movq %rbx, %rdi
callq 0x6476
jmp 0x4c05
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x4c4e
callq 0x5a38
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x4c60
callq 0x5a38
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x4c76
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x2849(%rip), %rdi      # 0x74d7
leaq 0x2433(%rip), %rsi      # 0x70c8
leaq 0x2823(%rip), %rcx      # 0x74bf
movl $0x91, %edx
callq 0x20b0
leaq 0x27ec(%rip), %rdi      # 0x7499
leaq 0x2414(%rip), %rsi      # 0x70c8
leaq 0x2804(%rip), %rcx      # 0x74bf
movl $0x90, %edx
callq 0x20b0
leaq 0x2826(%rip), %rdi      # 0x74f2
leaq 0x23f5(%rip), %rsi      # 0x70c8
leaq 0x27e5(%rip), %rcx      # 0x74bf
movl $0x99, %edx
callq 0x20b0
jmp 0x4d11
jmp 0x4d31
movq %rax, %rbx
jmp 0x4d43
movq %rax, %rbx
movq 0x98(%rsp), %rax
testq %rax, %rax
je 0x4d55
leaq 0x88(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x4d55
movq %rax, %rdi
callq 0x541a
jmp 0x4d31
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4d34
callq 0x5a38
jmp 0x4d34
jmp 0x4d31
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x4d43
callq 0x5a38
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x4d55
callq 0x5a38
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x4d6b
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0