// File: /workspace/github_cpp_makefile_star2_O2/dsharlet[P]array/test/shape.cpp
// Function: nda::test_shape_make_compact_body()
TEST(shape_make_compact) {
  shape<dim<>> s1({3, 5, 2});
  shape<dense_dim<>> s1_compact({3, 5, 1});
  assert_shapes_eq(make_compact(s1), s1_compact);

  shape<dim<>, dim<>> s2({3, 5, 8}, {1, 4, 1});
  shape<dense_dim<>, dim<>> s2_compact({3, 5, 1}, {1, 4, 5});
  assert_shapes_eq(make_compact(s2), s2_compact);

  shape<dim<>, dense_dim<>> s3({3, 5, 8}, {1, 4});
  shape<dim<>, dense_dim<>> s3_compact({3, 5, 4}, {1, 4});
  assert_shapes_eq(make_compact(s3), s3_compact);

  shape<dim<>, dense_dim<dynamic, 4>> s4({5, 3, 8}, {2, 4});
  shape<strided_dim<4>, dense_dim<dynamic, 4>> s4_compact({5, 3}, {2, 4});
  assert_shapes_eq(make_compact(s4), s4_compact);

  // We can't make the first dimenion static stride 1, because
  // we don't know its extent when assigning the static strides.
  shape<dim<>, strided_dim<8>> s5({5, 8}, {2, 4});
  shape<dim<>, strided_dim<8>> s5_compact({5, 8, 1}, {2, 4});
  assert_shapes_eq(make_compact(s5), s5_compact);

  // TODO: Try to give this first dimension static stride 1.
  shape<dim<0, 8>, dim<0, 4, 8>> s6({}, {});
  shape<dim<0, 8>, dim<0, 4, 8>> s6_compact({0, 8, 1}, {});
  assert_shapes_eq(make_compact(s6), s6_compact);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
pushq $0x3
popq %r15
leaq 0x198(%rsp), %rbx
movq %r15, (%rbx)
pushq $0x5
popq %rbp
movq %rbp, 0x8(%rbx)
pushq $0x2
popq %rax
movq %rax, 0x10(%rbx)
leaq 0x128(%rsp), %rsi
movq %r15, (%rsi)
movq %rbp, 0x8(%rsi)
leaq 0x180(%rsp), %r14
movq %r14, %rdi
callq 0x3c10a
leaq 0x128(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3cc70
movq %r13, %rdi
movq %r14, %rsi
callq 0x3c7da
pushq $0x1
popq %rax
movq %rax, (%r13)
pushq $0x4
popq %r12
movq %r12, 0x8(%r13)
movq %rax, 0x10(%r13)
movq %r15, %rbx
movq %r15, 0x18(%r13)
movq %rbp, %r14
movq %rbp, 0x20(%r13)
pushq $0x8
popq %rcx
movq %rcx, 0x28(%r13)
leaq 0xf8(%rsp), %rsi
movq %r15, (%rsi)
movq %rbp, 0x8(%rsi)
leaq 0xc8(%rsp), %r13
movq %rax, (%r13)
movq %r12, 0x8(%r13)
movq %rbp, 0x10(%r13)
leaq 0x1d8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rdx
callq 0x1091e
leaq 0xf8(%rsp), %r15
leaq 0x128(%rsp), %rsi
movq %r15, %rdi
callq 0x138d5
movq %r15, %rdi
movq %rbp, %rsi
callq 0x839cf
movq %rbx, (%r13)
movq %r14, 0x8(%r13)
movq %r14, %rbp
pushq $0x8
popq %rax
movq %rax, 0x10(%r13)
leaq 0x8(%rsp), %r15
pushq $0x1
popq %r14
movq %r14, (%r15)
movq %r12, 0x8(%r15)
leaq 0xf8(%rsp), %r13
leaq 0xc8(%rsp), %rsi
movq %r13, %rdi
movq %r15, %rdx
callq 0x77550
movq %rbx, (%r15)
movq %rbp, 0x8(%r15)
movq %r12, 0x10(%r15)
leaq 0x68(%rsp), %rdx
movq %r14, (%rdx)
movq %r12, 0x8(%rdx)
leaq 0xc8(%rsp), %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x77550
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x775a5
movq %rbp, %rdi
movq %r15, %rsi
callq 0x839f8
pushq $0x5
popq %r15
movq %r15, (%rbp)
movq %rbx, 0x8(%rbp)
pushq $0x8
popq %rax
movq %rax, 0x10(%rbp)
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
pushq $0x2
popq %r14
movq %r14, %rsi
movq %r12, %rdx
pushq $0x1
popq %r13
movq %r13, %rcx
callq 0x7762c
leaq 0x158(%rsp), %rdi
leaq 0x8(%rsp), %rbp
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x7765c
movq %r15, (%rbp)
movq %r15, %rbx
pushq $0x3
popq %rax
movq %rax, 0x8(%rbp)
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x7762c
leaq 0x1b0(%rsp), %rbp
leaq 0x8(%rsp), %rsi
movq %rbp, %rdi
movq %r15, %rdx
callq 0x776a8
leaq 0x8(%rsp), %r14
movq %r14, %rdi
leaq 0x158(%rsp), %rsi
callq 0x776f4
movq %r14, %rdi
movq %rbp, %rsi
callq 0x83a4b
movq %rbx, (%r15)
pushq $0x8
popq %r13
movq %r13, 0x8(%r15)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, 0x10(%r15)
leaq 0x98(%rsp), %r14
pushq $0x2
popq %rbp
movq %rbp, (%r14)
movq %r12, 0x8(%r14)
leaq 0x8(%rsp), %r15
leaq 0x68(%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x7774e
movq %rbx, (%r14)
movq %r13, 0x8(%r14)
pushq $0x1
popq %rbx
movq %rbx, 0x10(%r14)
leaq 0x50(%rsp), %rdx
movq %rbp, (%rdx)
movq %r12, 0x8(%rdx)
leaq 0x68(%rsp), %r14
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x7774e
leaq 0x98(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x777a3
movq %r12, %rdi
movq %r14, %rsi
callq 0x83dbc
leaq 0x50(%rsp), %r14
movq %r14, %rdi
callq 0x7782a
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x77832
leaq 0x98(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x7783a
leaq 0x38(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x83fa6
movq %rbx, 0x8(%r14)
leaq 0x5(%rsp), %rbx
movq %rbx, %rdi
callq 0x77832
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7783a
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7787c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x83fd7
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq