// File: /workspace/github_cpp_makefile_star2_O1/dsharlet[P]array/test/shape.cpp
// Function: nda::test_shape_optimize_body()
TEST(shape_optimize) {
  dim<> dummy_dim(0, 1, 0);

  shape_of_rank<3> a({0, 5, 21}, {0, 7, 3}, {5, 3, 1});
  shape_of_rank<3> a_optimized({5, 105, 1}, dummy_dim, dummy_dim);
  assert_shapes_eq(internal::dynamic_optimize_shape(a), a_optimized);

  shape_of_rank<3> b({0, 5, 42}, {3, 7, 6}, {0, 3, 2});
  shape_of_rank<3> b_optimized({9, 105, 2}, dummy_dim, dummy_dim);
  assert_shapes_eq(internal::dynamic_optimize_shape(b), b_optimized);

  shape_of_rank<3> c({0, 5, 40}, {0, 7, 3}, {0, 2, 1});
  shape_of_rank<3> c_optimized({0, 2, 1}, {0, 7, 3}, {0, 5, 40});
  assert_shapes_eq(internal::dynamic_optimize_shape(c), c_optimized);

  shape_of_rank<3> d({0, 5, 28}, {0, 7, 4}, {0, 3, 1});
  shape_of_rank<3> d_optimized({0, 3, 1}, {0, 35, 4}, dummy_dim);
  assert_shapes_eq(internal::dynamic_optimize_shape(d), d_optimized);

  shape_of_rank<10> e(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  e.resolve();
  shape_of_rank<10> e2 = reorder<9, 5, 3, 7, 2, 8, 4, 6, 0, 1>(e);
  shape_of_rank<10> e_optimized({0, 3628800, 1}, dummy_dim, dummy_dim, dummy_dim, dummy_dim,
      dummy_dim, dummy_dim, dummy_dim, dummy_dim, dummy_dim);
  assert_shapes_eq(internal::dynamic_optimize_shape(e), e_optimized);
  assert_shapes_eq(internal::dynamic_optimize_shape(e2), e_optimized);

  shape_of_rank<2> f({0, 2}, {1, 2});
  shape_of_rank<2> f_optimized({2, 4, 1}, dummy_dim);
  f.resolve();
  assert_shapes_eq(internal::dynamic_optimize_shape(f), f_optimized);

  shape_of_rank<2> g({1, 2}, {1, 2});
  shape_of_rank<2> g_optimized({3, 4, 1}, dummy_dim);
  g.resolve();
  assert_shapes_eq(internal::dynamic_optimize_shape(g), g_optimized);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6c8, %rsp            # imm = 0x6C8
movl $0x5, %r15d
leaq 0x590(%rsp), %rsi
movq %r15, (%rsi)
movl $0x3, %eax
movq %rax, 0x8(%rsi)
movl $0x1, %r13d
movq %r13, 0x10(%rsi)
xorl %ebp, %ebp
movq %rbp, 0x18(%rsi)
movl $0x7, %ecx
movq %rcx, 0x20(%rsi)
movq %rax, 0x28(%rsi)
movq %rbp, 0x30(%rsi)
movq %r15, 0x38(%rsi)
movq $0x15, 0x40(%rsi)
leaq 0x548(%rsp), %rbx
movq %rbp, (%rbx)
movq %r13, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movq %r13, 0x20(%rbx)
movq %rbp, 0x28(%rbx)
movq %r15, 0x30(%rbx)
movl $0x69, %eax
movq %rax, 0x38(%rbx)
movq %r13, 0x40(%rbx)
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
callq 0x1a813
movq %r14, %rdi
movq %rbx, %rsi
callq 0x967f9
leaq 0x500(%rsp), %rsi
movq %rbp, (%rsi)
movl $0x3, %eax
movq %rax, 0x8(%rsi)
movl $0x2, %r12d
movq %r12, 0x10(%rsi)
movq %rax, 0x18(%rsi)
movl $0x7, %eax
movq %rax, 0x20(%rsi)
movq $0x6, 0x28(%rsi)
movq %rbp, 0x30(%rsi)
movq %r15, 0x38(%rsi)
movq $0x2a, 0x40(%rsi)
leaq 0x4b8(%rsp), %rbx
movq %rbp, (%rbx)
movq %r13, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movq %r13, 0x20(%rbx)
movq %rbp, 0x28(%rbx)
movq $0x9, 0x30(%rbx)
movl $0x69, %eax
movq %rax, 0x38(%rbx)
movq %r12, 0x40(%rbx)
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
callq 0x1a813
movq %r14, %rdi
movq %rbx, %rsi
callq 0x967f9
leaq 0x470(%rsp), %rsi
movq %rbp, (%rsi)
movq %r12, 0x8(%rsi)
movq %r13, 0x10(%rsi)
movq %rbp, 0x18(%rsi)
movl $0x7, %edx
movq %rdx, 0x20(%rsi)
movl $0x3, %ecx
movq %rcx, 0x28(%rsi)
movq %rbp, 0x30(%rsi)
movq %r15, 0x38(%rsi)
movl $0x28, %eax
movq %rax, 0x40(%rsi)
leaq 0x428(%rsp), %rbx
movq %rbp, (%rbx)
movq %r15, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movq %rbp, 0x18(%rbx)
movq %rdx, 0x20(%rbx)
movq %rcx, 0x28(%rbx)
movq %rbp, 0x30(%rbx)
movq %r12, 0x38(%rbx)
movq %r13, 0x40(%rbx)
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
callq 0x1a813
movq %r14, %rdi
movq %rbx, %rsi
callq 0x967f9
leaq 0x3e0(%rsp), %rsi
movq %rbp, (%rsi)
movl $0x3, %eax
movq %rax, 0x8(%rsi)
movq %r13, 0x10(%rsi)
movq %rbp, 0x18(%rsi)
movl $0x7, %ecx
movq %rcx, 0x20(%rsi)
movl $0x4, %ecx
movq %rcx, 0x28(%rsi)
movq %rbp, 0x30(%rsi)
movq %r15, 0x38(%rsi)
movq $0x1c, 0x40(%rsi)
leaq 0x398(%rsp), %rbx
movq %rbp, (%rbx)
movq %r13, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movq $0x23, 0x20(%rbx)
movq %rcx, 0x28(%rbx)
movq %rbp, 0x30(%rbx)
movq %rax, 0x38(%rbx)
movq %r13, 0x40(%rbx)
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
callq 0x1a813
movq %r14, %rdi
movq %rbx, %rsi
callq 0x967f9
movaps 0x33cfd(%rip), %xmm0    # 0xbcd50
movups %xmm0, (%r14)
movaps 0x33d02(%rip), %xmm0    # 0xbcd60
movups %xmm0, 0x10(%r14)
movabsq $0x100000002, %rax      # imm = 0x100000002
movq %rax, 0x20(%r14)
leaq 0x30(%rsp), %r15
leaq 0x1b0(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x96830
leaq 0x108(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
leaq 0xd8(%rsp), %rcx
leaq 0xc0(%rsp), %r8
leaq 0xa8(%rsp), %r9
leaq 0x90(%rsp), %r10
leaq 0x78(%rsp), %rax
leaq 0x60(%rsp), %r12
leaq 0x48(%rsp), %rbx
subq $0x8, %rsp
movq %r15, %rdi
pushq %r15
pushq %rbx
pushq %r12
pushq %rax
movq %rax, %r15
pushq %r10
callq 0x96929
addq $0x30, %rsp
movq -0x8(%rbx), %rax
movq %rax, 0xe8(%r14)
movups -0x18(%rbx), %xmm0
movups %xmm0, 0xd8(%r14)
movups 0x48(%rbx), %xmm0
movaps %xmm0, 0xc0(%r14)
movq 0x58(%rbx), %rax
movq %rax, 0xd0(%r14)
movups 0x78(%rbx), %xmm0
movups %xmm0, 0xa8(%r14)
movq 0x70(%r12), %rax
movq %rax, 0xb8(%r14)
movups 0x18(%rbx), %xmm0
movaps %xmm0, 0x90(%r14)
movq 0x28(%rbx), %rax
movq %rax, 0xa0(%r14)
movq 0x70(%r15), %rax
movq %rax, 0x88(%r14)
movups 0x78(%r12), %xmm0
movups %xmm0, 0x78(%r14)
movq 0x10(%rbx), %rax
movq %rax, 0x70(%r14)
movups (%rbx), %xmm0
movaps %xmm0, 0x60(%r14)
movq 0x70(%rbx), %rax
movq %rax, 0x58(%r14)
movups 0x60(%rbx), %xmm0
movups %xmm0, 0x48(%r14)
movq 0x40(%rbx), %rax
movq %rax, 0x40(%r14)
movups 0x30(%rbx), %xmm0
movaps %xmm0, 0x30(%r14)
leaq 0xa8(%rsp), %rax
movq 0x70(%rax), %rax
movq %rax, 0x28(%r14)
leaq 0x90(%rsp), %rax
movups 0x78(%rax), %xmm0
movups %xmm0, 0x18(%r14)
movq 0x70(%rax), %rax
movq %rax, 0x10(%r14)
movups 0x78(%r15), %xmm0
movaps %xmm0, (%r14)
leaq 0x5d8(%rsp), %r14
leaq 0x1b0(%rsp), %r15
movl $0xf0, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2180
movq %rbp, (%r15)
movq %r13, 0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
movq %r13, 0x20(%r15)
movups %xmm0, 0x28(%r15)
movq %r13, 0x38(%r15)
movups %xmm0, 0x40(%r15)
movq %r13, 0x50(%r15)
movups %xmm0, 0x58(%r15)
movq %r13, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movq %r13, 0x80(%r15)
movups %xmm0, 0x88(%r15)
movq %r13, 0x98(%r15)
movups %xmm0, 0xa0(%r15)
movq %r13, 0xb0(%r15)
movups %xmm0, 0xb8(%r15)
movq %r13, 0xc8(%r15)
movups %xmm0, 0xd0(%r15)
movq $0x375f00, 0xe0(%r15) # imm = 0x375F00
movq %r13, 0xe8(%r15)
leaq 0x2a8(%rsp), %r15
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x8a09c
leaq 0x1b0(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x97303
leaq 0x2a8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x8a09c
movq %r15, %rdi
movq %rbx, %rsi
callq 0x97303
movq %r13, (%r15)
movl $0x2, %eax
movq %rax, 0x8(%r15)
movabsq $-0x8000000000000000, %r12 # imm = 0x8000000000000000
movq %r12, 0x10(%r15)
leaq 0x2c0(%rsp), %rsi
movq %rbp, (%rsi)
movq %rax, 0x8(%rsi)
movq %r12, 0x10(%rsi)
leaq 0x198(%rsp), %rbx
movq %rbp, -0x18(%rbx)
movq %r13, -0x10(%rbx)
movq %rbp, -0x8(%rbx)
movq %rax, (%rbx)
movl $0x4, %eax
movq %rax, 0x8(%rbx)
movq %r13, 0x10(%rbx)
leaq 0x2a8(%rsp), %r14
movq %r14, %rdi
movq %r14, %rdx
callq 0xe0a6
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xe3b3
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4a3a3
leaq 0x180(%rsp), %rsi
movq %r15, %rdi
callq 0x4a3a3
movq %r13, -0x18(%r14)
movl $0x2, %eax
movq %rax, -0x10(%r14)
movq %r12, -0x8(%r14)
leaq 0x18(%rsp), %rsi
movq %r13, (%rsi)
movq %rax, 0x8(%rsi)
movq %r12, 0x10(%rsi)
leaq 0x168(%rsp), %rbx
movq %rbp, -0x18(%rbx)
movq %r13, -0x10(%rbx)
movq %rbp, -0x8(%rbx)
movl $0x3, %eax
movq %rax, (%rbx)
movl $0x4, %eax
movq %rax, 0x8(%rbx)
movq %r13, 0x10(%rbx)
movq %rsp, %r14
movq %r14, %rdi
movq %r14, %rdx
callq 0xe0a6
leaq 0x120(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xe3b3
leaq 0x138(%rsp), %rdi
movq %rbx, %rsi
callq 0x4a3a3
leaq 0x150(%rsp), %rsi
movq %r15, %rdi
callq 0x4a3a3
addq $0x6c8, %rsp            # imm = 0x6C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq