// File: dsharlet[P]array/test/algorithm.cpp
// Function: nda::test_algorithm_copy_body()
TEST(algorithm_copy) {
  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);

      copy(a, b);
      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 0x287430(%rip), %rsi    # 0x291fa0
callq 0x11220
jmp 0xab77
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 0xb0b0
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 0xb097
movq -0x140(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x112b0
movq %rax, -0x450(%rbp)
jmp 0xac94
movq -0x450(%rbp), %rdi
callq 0x112d0
movq %rax, -0x458(%rbp)
jmp 0xaca9
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 0xacf4
movq -0x468(%rbp), %rdi
callq 0x112d0
movq %rax, -0x470(%rbp)
jmp 0xad09
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 0xad67
movq -0x480(%rbp), %rdi
callq 0x112f0
movq %rax, -0x488(%rbp)
jmp 0xad7c
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 0xadc7
movq -0x498(%rbp), %rdi
callq 0x112f0
movq %rax, -0x4a0(%rbp)
jmp 0xaddc
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 0xae53
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 0xae81
leaq -0x190(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
callq 0x11310
jmp 0xae9d
leaq -0x210(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x11190
jmp 0xaeb2
leaq -0xa0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x11360
jmp 0xaec7
leaq -0x210(%rbp), %rdi
callq 0x11460
movq %rax, -0x4b0(%rbp)
jmp 0xaedc
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 0xaf0d
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 0xaf6c
leaq -0x3d8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x113b0
movb %al, -0x4b9(%rbp)
jmp 0xaf87
leaq -0x431(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
callq 0x33b0
movq -0x4c8(%rbp), %rdx
leaq 0x1d10b0(%rip), %rsi    # 0x1dc058
leaq -0x430(%rbp), %rdi
callq 0x10a90
jmp 0xafb6
movb -0x4b9(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x3a0(%rbp), %rdi
leaq -0x430(%rbp), %rdx
callq 0x10f80
jmp 0xafd7
leaq -0x3a0(%rbp), %rdi
callq 0x10ff0
jmp 0xafe5
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 0xac5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0xb0c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0xb089
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0xb07d
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 0xb0c5
jmp 0xb099
movq -0x108(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x108(%rbp)
jmp 0xabd8
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)