// File: dsharlet[P]array/test/shape.cpp
// Function: nda::test_for_each_index_2d_of_3d_body()
TEST(for_each_index_2d_of_3d) {
  shape_of_rank<3> s(3, 5, {0, 8, 1});
  s.resolve();
  int expected_flat_offset = 0;
  for_each_index<0, 1>(s, [&](std::tuple<int, int> i) {
    ASSERT_EQ(s(std::get<0>(i), std::get<1>(i), 0), expected_flat_offset);
    expected_flat_offset += s.x().stride();
  });
  // Ensure the for_each_index loop above actually ran.
  ASSERT_EQ(expected_flat_offset, 120);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
leaq -0x60(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
movl $0x3, %esi
callq 0x10c20
leaq -0x78(%rbp), %rdi
movq %rdi, -0x298(%rbp)
movl $0x5, %esi
callq 0x10c20
xorl %eax, %eax
movl %eax, %esi
leaq -0x90(%rbp), %rdi
movq %rdi, -0x290(%rbp)
movl $0x8, %edx
movl $0x1, %ecx
callq 0x10c60
movq -0x2a0(%rbp), %rsi
movq -0x298(%rbp), %rdx
movq -0x290(%rbp), %rcx
leaq -0x48(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x36640
movq -0x288(%rbp), %rdi
callq 0x378e0
movq -0x288(%rbp), %rdi
movl $0x0, -0x94(%rbp)
movq %rdi, -0xa8(%rbp)
leaq -0x94(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x181840
movl -0x94(%rbp), %eax
subl $0x78, %eax
sete %al
movb %al, -0x279(%rbp)
leaq -0x259(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x33b0
movq -0x278(%rbp), %rdx
leaq 0x7a1f7(%rip), %rsi     # 0x1fb863
leaq -0x258(%rbp), %rdi
callq 0x10a90
jmp 0x18167a
movb -0x279(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x238(%rbp), %rdi
leaq -0x258(%rbp), %rdx
callq 0x10f80
jmp 0x18169b
leaq 0x5b143(%rip), %rsi     # 0x1dc7e5
leaq -0x238(%rbp), %rdi
callq 0x34320
movq %rax, -0x2a8(%rbp)
jmp 0x1816b7
movq -0x2a8(%rbp), %rdi
leaq 0x7b550(%rip), %rsi     # 0x1fcc15
callq 0x96ac0
movq %rax, -0x2b0(%rbp)
jmp 0x1816d3
movq -0x2b0(%rbp), %rdi
leaq 0x5f0cb(%rip), %rsi     # 0x1e07ac
callq 0x34320
movq %rax, -0x2b8(%rbp)
jmp 0x1816ef
movq -0x2b8(%rbp), %rdi
leaq -0x94(%rbp), %rsi
callq 0x343a0
movq %rax, -0x2c0(%rbp)
jmp 0x18170b
movq -0x2c0(%rbp), %rdi
leaq 0x5b0cc(%rip), %rsi     # 0x1dc7e5
callq 0x34320
movq %rax, -0x2c8(%rbp)
jmp 0x181727
movq -0x2c8(%rbp), %rdi
leaq 0x7a146(%rip), %rsi     # 0x1fb87b
callq 0x356d0
movq %rax, -0x2d0(%rbp)
jmp 0x181743
movq -0x2d0(%rbp), %rdi
leaq 0x5f05b(%rip), %rsi     # 0x1e07ac
callq 0x34320
movq %rax, -0x2d8(%rbp)
jmp 0x18175f
movq -0x2d8(%rbp), %rdi
movl $0x78, -0x270(%rbp)
leaq -0x270(%rbp), %rsi
callq 0x343a0
movq %rax, -0x2e0(%rbp)
jmp 0x181785
movq -0x2e0(%rbp), %rdi
leaq 0x74ce8(%rip), %rsi     # 0x1f647b
callq 0x34320
jmp 0x18179a
leaq -0x238(%rbp), %rdi
callq 0x10ff0
jmp 0x1817a8
leaq -0x258(%rbp), %rdi
callq 0x3100
leaq -0x259(%rbp), %rdi
callq 0x3290
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x18181f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x181813
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x10ff0
jmp 0x181811
jmp 0x181813
leaq -0x258(%rbp), %rdi
callq 0x3100
leaq -0x259(%rbp), %rdi
callq 0x3290
movq -0x268(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nop