// File: dsharlet[P]array/test/shape.cpp
// Function: nda::test_for_all_indices_3d_reordered_body()
TEST(for_all_indices_3d_reordered) {
  shape_of_rank<3> s(3, 5, {0, 8, 1});
  s.resolve();
  int expected_flat_offset = 0;
  move_only token;
  for_all_indices<2, 0, 1>(s, [&, token = std::move(token)](int x, int y, int z) {
    ASSERT_EQ(s(x, y, z), expected_flat_offset);
    expected_flat_offset++;
    assert_used(token);
  });
  // Ensure the for_all_indices loop above actually ran.
  ASSERT_EQ(expected_flat_offset, 120);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
leaq -0x60(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
movl $0x3, %esi
callq 0x10c20
leaq -0x78(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
movl $0x5, %esi
callq 0x10c20
xorl %eax, %eax
movl %eax, %esi
leaq -0x90(%rbp), %rdi
movq %rdi, -0x298(%rbp)
movl $0x8, %edx
movl $0x1, %ecx
callq 0x10c60
movq -0x2a8(%rbp), %rsi
movq -0x2a0(%rbp), %rdx
movq -0x298(%rbp), %rcx
leaq -0x48(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x36640
movq -0x290(%rbp), %rdi
callq 0x378e0
movq -0x290(%rbp), %rdi
movl $0x0, -0x94(%rbp)
movq %rdi, -0xa8(%rbp)
leaq -0x94(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0xb0(%rbp), %rsi
callq 0x180500
movl -0x94(%rbp), %eax
subl $0x78, %eax
sete %al
movb %al, -0x281(%rbp)
leaq -0x261(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x33b0
movq -0x280(%rbp), %rdx
leaq 0x7b537(%rip), %rsi     # 0x1fb863
leaq -0x260(%rbp), %rdi
callq 0x10a90
jmp 0x18033a
movb -0x281(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rdx
callq 0x10f80
jmp 0x18035b
leaq 0x5c483(%rip), %rsi     # 0x1dc7e5
leaq -0x240(%rbp), %rdi
callq 0x34320
movq %rax, -0x2b0(%rbp)
jmp 0x180377
movq -0x2b0(%rbp), %rdi
leaq 0x7c890(%rip), %rsi     # 0x1fcc15
callq 0x96ac0
movq %rax, -0x2b8(%rbp)
jmp 0x180393
movq -0x2b8(%rbp), %rdi
leaq 0x6040b(%rip), %rsi     # 0x1e07ac
callq 0x34320
movq %rax, -0x2c0(%rbp)
jmp 0x1803af
movq -0x2c0(%rbp), %rdi
leaq -0x94(%rbp), %rsi
callq 0x343a0
movq %rax, -0x2c8(%rbp)
jmp 0x1803cb
movq -0x2c8(%rbp), %rdi
leaq 0x5c40c(%rip), %rsi     # 0x1dc7e5
callq 0x34320
movq %rax, -0x2d0(%rbp)
jmp 0x1803e7
movq -0x2d0(%rbp), %rdi
leaq 0x7b486(%rip), %rsi     # 0x1fb87b
callq 0x356d0
movq %rax, -0x2d8(%rbp)
jmp 0x180403
movq -0x2d8(%rbp), %rdi
leaq 0x6039b(%rip), %rsi     # 0x1e07ac
callq 0x34320
movq %rax, -0x2e0(%rbp)
jmp 0x18041f
movq -0x2e0(%rbp), %rdi
movl $0x78, -0x278(%rbp)
leaq -0x278(%rbp), %rsi
callq 0x343a0
movq %rax, -0x2e8(%rbp)
jmp 0x180445
movq -0x2e8(%rbp), %rdi
leaq 0x76028(%rip), %rsi     # 0x1f647b
callq 0x34320
jmp 0x18045a
leaq -0x240(%rbp), %rdi
callq 0x10ff0
jmp 0x180468
leaq -0x260(%rbp), %rdi
callq 0x3100
leaq -0x261(%rbp), %rdi
callq 0x3290
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x270(%rbp)
movl %eax, -0x274(%rbp)
jmp 0x1804df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x270(%rbp)
movl %eax, -0x274(%rbp)
jmp 0x1804d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x270(%rbp)
movl %eax, -0x274(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x10ff0
jmp 0x1804d1
jmp 0x1804d3
leaq -0x260(%rbp), %rdi
callq 0x3100
leaq -0x261(%rbp), %rdi
callq 0x3290
movq -0x270(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nop