// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1d8, %rsp            # imm = 0x1D8
movl $0x3, %eax
leaq 0xc0(%rsp), %rbx
movq %rax, (%rbx)
movl $0x5, %eax
movq %rax, 0x8(%rbx)
movl $0x1, %r13d
movq %r13, 0x10(%rbx)
xorl %edi, %edi
movq %rbx, %rsi
callq 0xd133
leaq 0x1c0(%rsp), %r14
movl $0x3, %ecx
movq %rcx, (%r14)
movl $0x5, %eax
movq %rax, 0x8(%r14)
movq %rcx, (%rbx)
movl $0x3, %r15d
movq %rax, 0x8(%rbx)
movl $0x5, %r12d
movq %r13, 0x10(%rbx)
leaq 0xc0(%rsp), %rbx
xorl %edi, %edi
movq %rbx, %rsi
callq 0xd133
movq %r15, (%rbx)
movq %r12, 0x8(%rbx)
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4b40b
movq %r13, (%r15)
movl $0x4, %ebp
movq %rbp, 0x8(%r15)
movq %r13, 0x10(%r15)
movl $0x3, %eax
movq %rax, 0x18(%r15)
movq %r12, 0x20(%r15)
movl $0x8, %ebx
movq %rbx, 0x28(%r15)
leaq 0x120(%rsp), %r14
movq %rax, (%r14)
movl $0x3, %r15d
movq %r12, 0x8(%r14)
movq %r13, 0x10(%r14)
xorl %edi, %edi
movq %r14, %rsi
callq 0xd133
movq %r13, (%r14)
movq %rbp, 0x8(%r14)
movl $0x5, %eax
movq %rax, 0x10(%r14)
leaq 0x138(%rsp), %r14
movq %r15, (%r14)
movq %rax, 0x8(%r14)
leaq 0x90(%rsp), %r15
leaq 0xc0(%rsp), %rsi
movq %r15, %rdi
callq 0x1c630
leaq 0xa8(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4b40b
leaq 0x120(%rsp), %rsi
movq %r15, %rdi
callq 0x4ae75
movq %r13, -0x18(%r12)
movq %rbp, -0x10(%r12)
movq %r13, -0x8(%r12)
leaq 0x90(%rsp), %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0xd133
movl $0x1, %eax
movq %rax, (%r14)
movq %rbp, 0x8(%r14)
movl $0x3, %r13d
movq %r13, 0x18(%r14)
movl $0x5, %r15d
movq %r15, 0x20(%r14)
movq %rbx, 0x28(%r14)
leaq 0xf0(%rsp), %r14
movq %rax, (%r14)
movq %rbp, 0x8(%r14)
movq %rax, 0x10(%r14)
movl $0x1, %r12d
movl $0x1, %edi
movq %r14, %rsi
callq 0xd133
movq %r12, (%r14)
movl $0x4, %eax
movq %rax, 0x8(%r14)
leaq 0x108(%rsp), %r14
movq %r13, (%r14)
movq %r15, 0x8(%r14)
movq %rax, 0x10(%r14)
movl $0x4, %ebp
leaq 0x30(%rsp), %r15
leaq 0x90(%rsp), %rsi
movq %r15, %rdi
callq 0x8c325
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4ae75
leaq 0xf0(%rsp), %rsi
movq %r15, %rdi
callq 0x4b40b
movl $0x2, %r13d
movq %r13, -0x18(%r12)
movq %rbp, -0x10(%r12)
movl $0x1, %eax
movq %rax, -0x8(%r12)
leaq 0x30(%rsp), %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0x8cef4
movq %r13, (%r14)
movl $0x5, %eax
movq %rax, 0x10(%r14)
movl $0x3, %eax
movq %rax, 0x18(%r14)
movl $0x3, %ebp
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x8cea6
movq 0x20(%r14), %rax
leaq 0x160(%rsp), %r15
movq %rax, 0x10(%r15)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movaps %xmm1, (%r15)
movaps %xmm0, -0x10(%r15)
movq %rsp, %r12
movq %r13, (%r12)
movl $0x5, %eax
movq %rax, 0x10(%r12)
movq %rbp, 0x18(%r12)
movq %r12, %rdi
callq 0x8cea6
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movaps %xmm0, (%r14)
movq 0x20(%r12), %rax
movaps %xmm0, (%r12)
leaq 0x10(%rsp), %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
movq %r15, %rsi
callq 0x98f77
movq %rsp, %r15
leaq 0x150(%rsp), %rsi
movq %r15, %rdi
callq 0x990e0
movq %r13, (%r14)
movl $0x4, %eax
movq %rax, 0x8(%r14)
movq %rbx, 0x10(%r14)
leaq 0x30(%rsp), %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0x8cf8b
movq %r13, (%r14)
movl $0x4, %eax
movq %rax, 0x8(%r14)
movl $0x5, %r12d
movq %r12, 0x18(%r14)
movq %rbx, 0x20(%r14)
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq %rcx, 0x28(%r14)
movq %r13, (%r15)
movq %rax, 0x8(%r15)
movl $0x4, %ebp
movq %rbx, 0x10(%r15)
movq %rsp, %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0x8cf8b
movq %r13, (%r14)
movq %rbp, 0x8(%r14)
leaq 0x18(%rsp), %r14
movq %r12, (%r14)
movq %rbx, 0x8(%r14)
movl $0x1, %r13d
movq %r13, 0x10(%r14)
leaq 0x60(%rsp), %r15
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0x8c3c9
leaq 0x78(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4ae75
movq %rsp, %rsi
movq %r15, %rdi
callq 0x99337
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, -0x8(%r12)
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x8d135
movq 0x10(%r14), %rax
leaq 0x1a0(%rsp), %r15
movq %rax, 0x10(%r15)
movups (%r14), %xmm0
movaps %xmm0, (%r15)
movq %r13, 0x10(%r14)
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x8d135
movq 0x10(%r14), %rax
leaq 0x180(%rsp), %r12
movq %rax, 0x10(%r12)
movups (%r14), %xmm0
movaps %xmm0, (%r12)
movq %r14, %rdi
movq %r15, %rsi
callq 0x8c46d
leaq (%r14,%rbx), %rdi
orq %r12, %rbx
movq %rbx, %rsi
callq 0x9951d
movq %r14, %rdi
movq %r12, %rsi
callq 0x9967d
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq