// File: dsharlet[P]array/test/array.cpp
// Function: nda::test_array_reshape_3d_body()
TEST(array_reshape_3d) {
  shape_of_rank<3> s({{-1, 10}, {-2, 10}, {-3, 10}});
  array_of_rank<int, 3> a(s);
  fill_pattern(a);

  a.reshape({{-2, 12}, {-3, 13}, {-4, 14}});
  check_pattern(a(s.x(), s.y(), s.z()));
  ASSERT_EQ(a.shape().flat_extent(), 12 * 13 * 14);

  a.reshape({5, 5, 5});
  check_pattern(a);
  ASSERT_EQ(a.shape().flat_extent(), 5 * 5 * 5);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7d0, %rsp            # imm = 0x7D0
leaq -0x60(%rbp), %rdi
movq %rdi, -0x670(%rbp)
movq $-0x1, %rsi
movl $0xa, %edx
movq %rdx, -0x680(%rbp)
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq %rcx, -0x678(%rbp)
callq 0x10c60
movq -0x680(%rbp), %rdx
movq -0x678(%rbp), %rcx
leaq -0x78(%rbp), %rdi
movq %rdi, -0x668(%rbp)
movq $-0x2, %rsi
callq 0x10c60
movq -0x680(%rbp), %rdx
movq -0x678(%rbp), %rcx
leaq -0x90(%rbp), %rdi
movq %rdi, -0x660(%rbp)
movq $-0x3, %rsi
callq 0x10c60
movq -0x670(%rbp), %rsi
movq -0x668(%rbp), %rdx
movq -0x660(%rbp), %rcx
leaq -0x48(%rbp), %rdi
movq %rdi, -0x658(%rbp)
callq 0x36640
movq -0x658(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x650(%rbp)
callq 0x34f10
movq -0x650(%rbp), %rdi
xorl %esi, %esi
callq 0x34fb0
jmp 0x294db
leaq -0x168(%rbp), %rdi
movq $-0x2, %rsi
movl $0xc, %edx
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
callq 0x10c60
jmp 0x294ff
leaq -0x180(%rbp), %rdi
movq $-0x3, %rsi
movl $0xd, %edx
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
callq 0x10c60
jmp 0x29523
leaq -0x198(%rbp), %rdi
movq $-0x4, %rsi
movl $0xe, %edx
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
callq 0x10c60
jmp 0x29547
leaq -0x150(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x180(%rbp), %rdx
leaq -0x198(%rbp), %rcx
callq 0x36640
jmp 0x2956a
leaq -0xf8(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x36cb0
jmp 0x2957f
leaq -0x48(%rbp), %rdi
callq 0x36ef0
movq %rax, -0x688(%rbp)
jmp 0x29591
movq -0x688(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x1f0(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x200(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x36f10
movq %rax, -0x690(%rbp)
jmp 0x295bf
movq -0x690(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x210(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x220(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x36f30
movq %rax, -0x698(%rbp)
jmp 0x295ed
movq -0x698(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x230(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x240(%rbp)
movq -0x230(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x40(%rax)
movaps -0x240(%rbp), %xmm0
movups %xmm0, 0x30(%rax)
movq -0x210(%rbp), %rcx
movq %rcx, 0x28(%rax)
movaps -0x220(%rbp), %xmm0
movups %xmm0, 0x18(%rax)
movq -0x1f0(%rbp), %rcx
movq %rcx, 0x10(%rax)
movaps -0x200(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x1e8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x36e80
jmp 0x29662
leaq -0x258(%rbp), %rdi
movq %rdi, -0x6a0(%rbp)
callq 0x35c10
movq -0x6a0(%rbp), %rsi
leaq -0x1e8(%rbp), %rdi
callq 0x36e40
jmp 0x2968a
leaq -0xf8(%rbp), %rdi
callq 0x35d20
movq %rax, -0x6a8(%rbp)
jmp 0x2969f
movq -0x6a8(%rbp), %rdi
callq 0x36f50
movq %rax, -0x6b0(%rbp)
jmp 0x296b4
movq -0x6b0(%rbp), %rax
subq $0x888, %rax            # imm = 0x888
sete %al
movb %al, -0x6b9(%rbp)
leaq -0x409(%rbp), %rdi
movq %rdi, -0x6b8(%rbp)
callq 0x33b0
movq -0x6b8(%rbp), %rdx
leaq 0x1b5027(%rip), %rsi    # 0x1de712
leaq -0x408(%rbp), %rdi
callq 0x10a90
jmp 0x296f9
movb -0x6b9(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x3e8(%rbp), %rdi
leaq -0x408(%rbp), %rdx
callq 0x10f80
jmp 0x2971a
leaq 0x1b30c4(%rip), %rsi    # 0x1dc7e5
leaq -0x3e8(%rbp), %rdi
callq 0x34320
movq %rax, -0x6c8(%rbp)
jmp 0x29736
movq -0x6c8(%rbp), %rdi
leaq 0x1b4f88(%rip), %rsi    # 0x1de6cc
callq 0x36bc0
movq %rax, -0x6d0(%rbp)
jmp 0x29752
movq -0x6d0(%rbp), %rdi
leaq 0x1b704c(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x6d8(%rbp)
jmp 0x2976e
leaq -0xf8(%rbp), %rdi
callq 0x35d20
movq %rax, -0x6e0(%rbp)
jmp 0x29783
movq -0x6e0(%rbp), %rdi
callq 0x36f50
movq %rax, -0x6e8(%rbp)
jmp 0x29798
movq -0x6d8(%rbp), %rdi
movq -0x6e8(%rbp), %rax
movq %rax, -0x418(%rbp)
leaq -0x418(%rbp), %rsi
callq 0x355c0
movq %rax, -0x6f0(%rbp)
jmp 0x297c2
movq -0x6f0(%rbp), %rdi
leaq 0x1b3015(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0x6f8(%rbp)
jmp 0x297de
movq -0x6f8(%rbp), %rdi
leaq 0x1b4f41(%rip), %rsi    # 0x1de72d
callq 0x346f0
movq %rax, -0x700(%rbp)
jmp 0x297fa
movq -0x700(%rbp), %rdi
leaq 0x1b6fa4(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x708(%rbp)
jmp 0x29816
movq -0x708(%rbp), %rdi
movl $0x888, -0x41c(%rbp)    # imm = 0x888
leaq -0x41c(%rbp), %rsi
callq 0x343a0
movq %rax, -0x710(%rbp)
jmp 0x2983c
movq -0x710(%rbp), %rdi
leaq 0x1ccc31(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0x29851
leaq -0x3e8(%rbp), %rdi
callq 0x10ff0
jmp 0x2985f
leaq -0x408(%rbp), %rdi
callq 0x3100
leaq -0x409(%rbp), %rdi
callq 0x3290
leaq -0x468(%rbp), %rdi
movl $0x5, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x34ec0
jmp 0x2988e
leaq -0xf8(%rbp), %rdi
leaq -0x468(%rbp), %rsi
callq 0x36cb0
jmp 0x298a3
leaq -0x480(%rbp), %rdi
movq %rdi, -0x718(%rbp)
callq 0x35c10
movq -0x718(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x35c90
jmp 0x298cb
leaq -0xf8(%rbp), %rdi
callq 0x35d20
movq %rax, -0x720(%rbp)
jmp 0x298e0
movq -0x720(%rbp), %rdi
callq 0x36f50
movq %rax, -0x728(%rbp)
jmp 0x298f5
movq -0x728(%rbp), %rax
subq $0x7d, %rax
sete %al
movb %al, -0x731(%rbp)
leaq -0x631(%rbp), %rdi
movq %rdi, -0x730(%rbp)
callq 0x33b0
movq -0x730(%rbp), %rdx
leaq 0x1b4e10(%rip), %rsi    # 0x1de73a
leaq -0x630(%rbp), %rdi
callq 0x10a90
jmp 0x29938
movb -0x731(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x610(%rbp), %rdi
leaq -0x630(%rbp), %rdx
callq 0x10f80
jmp 0x29959
leaq 0x1b2e85(%rip), %rsi    # 0x1dc7e5
leaq -0x610(%rbp), %rdi
callq 0x34320
movq %rax, -0x740(%rbp)
jmp 0x29975
movq -0x740(%rbp), %rdi
leaq 0x1b4d49(%rip), %rsi    # 0x1de6cc
callq 0x36bc0
movq %rax, -0x748(%rbp)
jmp 0x29991
movq -0x748(%rbp), %rdi
leaq 0x1b6e0d(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x750(%rbp)
jmp 0x299ad
leaq -0xf8(%rbp), %rdi
callq 0x35d20
movq %rax, -0x758(%rbp)
jmp 0x299c2
movq -0x758(%rbp), %rdi
callq 0x36f50
movq %rax, -0x760(%rbp)
jmp 0x299d7
movq -0x750(%rbp), %rdi
movq -0x760(%rbp), %rax
movq %rax, -0x640(%rbp)
leaq -0x640(%rbp), %rsi
callq 0x355c0
movq %rax, -0x768(%rbp)
jmp 0x29a01
movq -0x768(%rbp), %rdi
leaq 0x1b2dd6(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0x770(%rbp)
jmp 0x29a1d
movq -0x770(%rbp), %rdi
leaq 0x1b4d2a(%rip), %rsi    # 0x1de755
callq 0x344d0
movq %rax, -0x778(%rbp)
jmp 0x29a39
movq -0x778(%rbp), %rdi
leaq 0x1b6d65(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x780(%rbp)
jmp 0x29a55
movq -0x780(%rbp), %rdi
movl $0x7d, -0x644(%rbp)
leaq -0x644(%rbp), %rsi
callq 0x343a0
movq %rax, -0x788(%rbp)
jmp 0x29a7b
movq -0x788(%rbp), %rdi
leaq 0x1cc9f2(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0x29a90
leaq -0x610(%rbp), %rdi
callq 0x10ff0
jmp 0x29a9e
leaq -0x630(%rbp), %rdi
callq 0x3100
leaq -0x631(%rbp), %rdi
callq 0x3290
leaq -0xf8(%rbp), %rdi
callq 0x35160
addq $0x7d0, %rsp            # imm = 0x7D0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x29ba8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x29b38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x29b2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x3e8(%rbp), %rdi
callq 0x10ff0
jmp 0x29b2a
jmp 0x29b2c
leaq -0x408(%rbp), %rdi
callq 0x3100
leaq -0x409(%rbp), %rdi
callq 0x3290
jmp 0x29ba8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x29b9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x29b90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x610(%rbp), %rdi
callq 0x10ff0
jmp 0x29b8e
jmp 0x29b90
leaq -0x630(%rbp), %rdi
callq 0x3100
leaq -0x631(%rbp), %rdi
callq 0x3290
leaq -0xf8(%rbp), %rdi
callq 0x35160
movq -0x100(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nopl (%rax,%rax)