// File: /workspace/github_cpp_makefile_star2_O2/dsharlet[P]array/test/array_ref.cpp
// Function: nda::test_array_ref_crop_slice_body()
TEST(array_ref_crop_slice) {
  array<int, shape<dense_dim<0>, dim<>>> a({8, 9});
  fill_pattern(a);

  auto a_slice1 = a(3, _);
  static_assert(a_slice1.rank() == 1, "");
  assert_dim_eq(a_slice1.x(), a.y());
  // TODO: This doesn't pass because check_pattern doesn't understand
  // that there is a second dimension to the pattern.
  // check_pattern(a_slice1);

  auto a_slice2 = a(_, 2);
  static_assert(a_slice2.rank() == 1, "");
  assert_dim_eq(a_slice2.x(), a.x());
  // check_pattern(a_slice2);

  auto a_crop1_slice2 = a(interval<4, 3>(), 5);
  static_assert(a_crop1_slice2.rank() == 1, "");
  assert_dim_eq(a_crop1_slice2.x(), dense_dim<4, 3>());
  // check_pattern(a_crop1_slice2);

  auto a_slice1_crop2 = a(6, interval<4, 3>());
  static_assert(a_slice1_crop2.rank() == 1, "");
  assert_dim_eq(a_slice1_crop2.x(), dim<4, 3>(4, 3, a.y().stride()));
  // check_pattern(a_slice1_crop2);

  auto a_crop1_crop2 = a(interval<>(2, 6), interval<3, 4>());
  static_assert(a_crop1_crop2.rank() == 2, "");
  assert_dim_eq(a_crop1_crop2.x(), dense_dim<>(2, 6));
  assert_dim_eq(a_crop1_crop2.y(), dim<3, 4>(3, 4, a.y().stride()));
  check_pattern(a_crop1_crop2);

  auto a_all1_crop2 = a(_, interval<3, 4>());
  static_assert(a_all1_crop2.rank() == 2, "");
  assert_dim_eq(a_all1_crop2.x(), a.x());
  assert_dim_eq(a_all1_crop2.y(), dim<3, 4>(3, 4, a.y().stride()));
  check_pattern(a_all1_crop2);

  auto a_temp_names = a(range(2, 6), fixed_interval<5>(3));
  static_assert(a_temp_names.rank() == 2, "");
  assert_dim_eq(a_temp_names.x(), dense_dim<>(2, 4));
  assert_dim_eq(a_temp_names.y(), fixed_dim<5>(3, 5, a.y().stride()));
  check_pattern(a_temp_names);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
leaq 0x10(%rsp), %rbx
pushq $0x8
popq %rsi
pushq $0x9
popq %rdx
movq %rbx, %rdi
callq 0x3c20c
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c220
movq %r14, %rdi
xorl %esi, %esi
callq 0x3c255
leaq 0x168(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $0x3
popq %rdx
callq 0x3c288
leaq 0x170(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3c2b4
leaq 0x148(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $0x2
popq %rdx
callq 0x3c3ca
leaq 0x150(%rsp), %rdi
leaq 0x88(%rsp), %rbx
movq %rbx, %rsi
callq 0x3c3f5
leaq 0xe(%rsp), %rdi
callq 0x3c53c
leaq 0xc0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $0x5
popq %rdx
callq 0x3c510
leaq 0x10(%rsp), %rdi
callq 0x3c650
leaq 0xc8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x3c544
leaq 0xc(%rsp), %rdi
callq 0x3c53c
leaq 0x130(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $0x6
popq %rdx
callq 0x3c658
movq 0x80(%rsp), %r14
leaq 0x10(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x3
popq %rdx
callq 0x3d358
leaq 0x138(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, 0x8(%rsi)
callq 0x3c684
leaq 0xa(%rsp), %rdi
callq 0x3c7d2
leaq 0x100(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x6
popq %rcx
callq 0x3c79e
leaq 0x118(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq $0x2, (%rsi)
movq $0x6, 0x8(%rsi)
callq 0x3c7da
movq 0x80(%rsp), %r14
leaq 0x10(%rsp), %rdi
pushq $0x3
popq %rsi
pushq $0x4
popq %rdx
callq 0x3e9de
leaq 0x108(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, 0x8(%rsi)
callq 0x3c8fd
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
leaq 0x100(%rsp), %rdi
callq 0x3ca17
leaq 0x8(%rsp), %rdi
callq 0x3c7d2
leaq 0xd0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3ca38
leaq 0xe8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3c3f5
movq 0x80(%rsp), %rbx
leaq 0x10(%rsp), %rdi
pushq $0x3
popq %rsi
pushq $0x4
popq %rdx
callq 0x3e9de
leaq 0xd8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, 0x8(%rsi)
callq 0x3c8fd
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
leaq 0xd0(%rsp), %rdi
callq 0x3ca5e
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %rcx
pushq $0x3
popq %r8
callq 0x3ca80
leaq 0x30(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movq $0x2, (%rsi)
movq $0x4, 0x8(%rsi)
callq 0x3c7da
leaq 0x18(%rsp), %rdi
movq 0x80(%rsp), %rax
leaq 0xa0(%rsp), %rsi
movq $0x3, (%rsi)
movq %rax, 0x10(%rsi)
callq 0x3cab5
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rsi
movaps %xmm0, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3cbd8
leaq 0x50(%rsp), %rdi
callq 0x3cbfa
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
retq
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
jmp 0x3bf95
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3cbfa
movq %rbx, %rdi
callq 0x22f0