// File: dsharlet[P]array/test/matrix.cpp
// Function: nda::test_small_matrix_body()
TEST(small_matrix) {
  using matrix4x3i = small_matrix<int, 4, 3>;

  matrix4x3i auto_array;
  for_all_indices(auto_array.shape(), [&](int x, int y) { auto_array(x, y) = x; });

  matrix4x3i copy_array(auto_array);
  for_all_indices(copy_array.shape(), [&](int x, int y) { ASSERT_EQ(copy_array(x, y), x); });

  matrix4x3i assign_array;
  assign_array = auto_array;
  for_all_indices(assign_array.shape(), [&](int x, int y) { ASSERT_EQ(assign_array(x, y), x); });

  matrix4x3i move_array(std::move(auto_array));
  for_all_indices(move_array.shape(), [&](int x, int y) { ASSERT_EQ(move_array(x, y), x); });

  matrix4x3i move_assign;
  move_assign = std::move(assign_array);
  for_all_indices(move_assign.shape(), [&](int x, int y) { ASSERT_EQ(move_assign(x, y), x); });
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
leaq -0x78(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x149f00
movq -0x2a0(%rbp), %rdi
callq 0x149f30
movq %rax, -0x298(%rbp)
jmp 0x147230
movq -0x298(%rbp), %rdi
leaq -0x78(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x147470
jmp 0x147250
leaq -0x108(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x149f50
jmp 0x147262
leaq -0x108(%rbp), %rdi
callq 0x149f30
movq %rax, -0x2a8(%rbp)
jmp 0x147277
movq -0x2a8(%rbp), %rdi
leaq -0x108(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x110(%rbp), %rsi
callq 0x1474a0
jmp 0x14729a
leaq -0x188(%rbp), %rdi
callq 0x149f00
jmp 0x1472a8
leaq -0x188(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x149fe0
jmp 0x1472ba
leaq -0x188(%rbp), %rdi
callq 0x149f30
movq %rax, -0x2b0(%rbp)
jmp 0x1472cf
movq -0x2b0(%rbp), %rdi
leaq -0x188(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0x190(%rbp), %rsi
callq 0x1474d0
jmp 0x1472f2
leaq -0x208(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x14a0d0
jmp 0x147304
leaq -0x208(%rbp), %rdi
callq 0x149f30
movq %rax, -0x2b8(%rbp)
jmp 0x147319
movq -0x2b8(%rbp), %rdi
leaq -0x208(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x210(%rbp), %rsi
callq 0x147500
jmp 0x14733c
leaq -0x288(%rbp), %rdi
callq 0x149f00
jmp 0x14734a
leaq -0x288(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x14a1b0
jmp 0x14735f
leaq -0x288(%rbp), %rdi
callq 0x149f30
movq %rax, -0x2c0(%rbp)
jmp 0x147374
movq -0x2c0(%rbp), %rdi
leaq -0x288(%rbp), %rax
movq %rax, -0x290(%rbp)
leaq -0x290(%rbp), %rsi
callq 0x147530
jmp 0x147397
leaq -0x288(%rbp), %rdi
callq 0x14a2d0
leaq -0x208(%rbp), %rdi
callq 0x14a2d0
leaq -0x188(%rbp), %rdi
callq 0x14a2d0
leaq -0x108(%rbp), %rdi
callq 0x14a2d0
leaq -0x78(%rbp), %rdi
callq 0x14a2d0
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x14745c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x147450
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x147444
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x147438
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x14a2d0
leaq -0x208(%rbp), %rdi
callq 0x14a2d0
leaq -0x188(%rbp), %rdi
callq 0x14a2d0
leaq -0x108(%rbp), %rdi
callq 0x14a2d0
leaq -0x78(%rbp), %rdi
callq 0x14a2d0
movq -0x80(%rbp), %rdi
callq 0x33a0
nop