// File: dsharlet[P]array/test/algorithm.cpp
// Function: nda::test_algorithm_move_body()
TEST(algorithm_move) {
  array_of_rank<int, 2> a({10, 20});
  generate(a, rand);

  for (int crop_min : {0, 1}) {
    for (int crop_max : {0, 1}) {
      int x_min = a.shape().x().min() + crop_min;
      int x_max = a.shape().x().max() - crop_max;
      int y_min = a.shape().y().min() + crop_min;
      int y_max = a.shape().y().max() - crop_max;
      shape_of_rank<2> b_shape({{x_min, x_max - x_min + 1}, {y_min, y_max - y_min + 1}});
      array_of_rank<int, 2> b(b_shape);

      move(a, b);
      // The lifetime of moved elements is tested in array_lifetime.cpp.
      ASSERT(equal(a(b.x(), b.y()), b));
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x500, %rsp            # imm = 0x500
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x448(%rbp)
movl $0xa, %esi
movl $0x14, %edx
callq 0x11150
movq -0x448(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0x11190
movq -0x440(%rbp), %rdi
movq 0x286e70(%rip), %rsi    # 0x291fa0
callq 0x11220
jmp 0xb137
movl $0x0, -0x100(%rbp)
movl $0x1, -0xfc(%rbp)
leaq -0x100(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq $0x2, -0xf0(%rbp)
leaq -0xf8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x11250
movq %rax, -0x108(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x11270
movq %rax, -0x110(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x110(%rbp), %rax
je 0xb670
movq -0x108(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x114(%rbp)
movl $0x0, -0x138(%rbp)
movl $0x1, -0x134(%rbp)
leaq -0x138(%rbp), %rax
movq %rax, -0x130(%rbp)
movq $0x2, -0x128(%rbp)
leaq -0x130(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rdi
callq 0x11250
movq %rax, -0x140(%rbp)
movq -0x120(%rbp), %rdi
callq 0x11270
movq %rax, -0x148(%rbp)
movq -0x140(%rbp), %rax
cmpq -0x148(%rbp), %rax
je 0xb657
movq -0x140(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x112b0
movq %rax, -0x450(%rbp)
jmp 0xb254
movq -0x450(%rbp), %rdi
callq 0x112d0
movq %rax, -0x458(%rbp)
jmp 0xb269
movq -0x458(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x460(%rbp)
movq -0x460(%rbp), %rax
movl -0x114(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x150(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x112b0
movq %rax, -0x468(%rbp)
jmp 0xb2b4
movq -0x468(%rbp), %rdi
callq 0x112d0
movq %rax, -0x470(%rbp)
jmp 0xb2c9
movq -0x470(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
addq $0x8, %rcx
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rcx
addq (%rcx), %rax
subq $0x1, %rax
movq %rax, -0x478(%rbp)
movq -0x478(%rbp), %rax
movl -0x14c(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x154(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x112b0
movq %rax, -0x480(%rbp)
jmp 0xb327
movq -0x480(%rbp), %rdi
callq 0x112f0
movq %rax, -0x488(%rbp)
jmp 0xb33c
movq -0x488(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x490(%rbp)
movq -0x490(%rbp), %rax
movl -0x114(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x158(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x112b0
movq %rax, -0x498(%rbp)
jmp 0xb387
movq -0x498(%rbp), %rdi
callq 0x112f0
movq %rax, -0x4a0(%rbp)
jmp 0xb39c
movq -0x4a0(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq %rcx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
addq $0x8, %rcx
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rcx
addq (%rcx), %rax
subq $0x1, %rax
movq %rax, -0x4a8(%rbp)
movq -0x4a8(%rbp), %rax
movl -0x14c(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x15c(%rbp)
movslq -0x150(%rbp), %rsi
movl %esi, %ecx
movl -0x154(%rbp), %eax
subl %ecx, %eax
incl %eax
movslq %eax, %rdx
leaq -0x1a8(%rbp), %rdi
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
callq 0x10c60
jmp 0xb413
movslq -0x158(%rbp), %rsi
movl %esi, %ecx
movl -0x15c(%rbp), %eax
subl %ecx, %eax
incl %eax
movslq %eax, %rdx
leaq -0x1c0(%rbp), %rdi
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
callq 0x10c60
jmp 0xb441
leaq -0x190(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
callq 0x11310
jmp 0xb45d
leaq -0x210(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x11190
jmp 0xb472
leaq -0xa0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x114e0
jmp 0xb487
leaq -0x210(%rbp), %rdi
callq 0x11460
movq %rax, -0x4b0(%rbp)
jmp 0xb49c
movq -0x4b0(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x3e0(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x3f0(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x11480
movq %rax, -0x4b8(%rbp)
jmp 0xb4cd
movq -0x4b8(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x400(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x410(%rbp)
movq -0x400(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x28(%rax)
movaps -0x410(%rbp), %xmm0
movups %xmm0, 0x18(%rax)
movq -0x3e0(%rbp), %rcx
movq %rcx, 0x10(%rax)
movaps -0x3f0(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x3d8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x113f0
jmp 0xb52c
leaq -0x3d8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x113b0
movb %al, -0x4b9(%rbp)
jmp 0xb547
leaq -0x431(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
callq 0x33b0
movq -0x4c8(%rbp), %rdx
leaq 0x1d0af0(%rip), %rsi    # 0x1dc058
leaq -0x430(%rbp), %rdi
callq 0x10a90
jmp 0xb576
movb -0x4b9(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x3a0(%rbp), %rdi
leaq -0x430(%rbp), %rdx
callq 0x10f80
jmp 0xb597
leaq -0x3a0(%rbp), %rdi
callq 0x10ff0
jmp 0xb5a5
leaq -0x430(%rbp), %rdi
callq 0x3100
leaq -0x431(%rbp), %rdi
callq 0x3290
leaq -0x210(%rbp), %rdi
callq 0x114a0
movq -0x140(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x140(%rbp)
jmp 0xb21c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0xb685
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0xb649
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0xb63d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x3100
leaq -0x431(%rbp), %rdi
callq 0x3290
leaq -0x210(%rbp), %rdi
callq 0x114a0
jmp 0xb685
jmp 0xb659
movq -0x108(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x108(%rbp)
jmp 0xb198
leaq -0xa0(%rbp), %rdi
callq 0x114a0
addq $0x500, %rsp            # imm = 0x500
popq %rbp
retq
leaq -0xa0(%rbp), %rdi
callq 0x114a0
movq -0xd8(%rbp), %rdi
callq 0x33a0
nopl (%rax)