// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
leaq 0x60(%rsp), %rbx
andq $0x0, (%rbx)
movq $0x8, 0x8(%rbx)
movq $0x1, 0x10(%rbx)
andq $0x0, 0x18(%rbx)
movq $0x5, 0x20(%rbx)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, 0x28(%rbx)
andq $0x0, 0x30(%rbx)
movq $0x3, 0x38(%rbx)
movq %rax, 0x40(%rbx)
movq %rbx, %rdi
callq 0x11e95
leaq 0xc(%rsp), %rax
andl $0x0, (%rax)
movl 0x30(%rbx), %eax
movl %eax, 0x14(%rsp)
movq 0x38(%rbx), %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rbx), %rdx
movq 0x20(%rbx), %rax
addq %rdx, %rax
movq %rax, 0x30(%rsp)
xorl %r12d, %r12d
leaq 0xa8(%rsp), %r15
leaq 0x18fef(%rip), %r14     # 0x8d647
leaq 0x1cf93(%rip), %rbp     # 0x915f2
cmpq 0x30(%rsp), %rdx
je 0x747a3
movq 0x28(%rsp), %rax
movl 0x14(%rsp), %esi
movq %rdx, 0x18(%rsp)
subq $0x1, %rax
jb 0x7479b
movq %rax, 0x38(%rsp)
leaq 0x60(%rsp), %rdi
movl %esi, 0x10(%rsp)
xorl %ecx, %ecx
callq 0x160c0
movq %rax, %r12
movslq 0xc(%rsp), %r13
movq %r14, %rbx
leaq 0x40(%rsp), %r14
movq %r14, %rdi
leaq 0x37212(%rip), %rsi     # 0xab8c3
leaq 0xb(%rsp), %rdx
callq 0x66a0
xorl %esi, %esi
cmpq %r13, %r12
sete %sil
movq %r15, %rdi
movq %r14, %rdx
movq %rbx, %r14
callq 0x6894
movq %r15, %rdi
movq %r14, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x37219(%rip), %rsi     # 0xab900
callq 0x3167c
movq %rax, %rdi
movq %rbp, %rsi
callq 0x106fe
movq %rax, %r12
leaq 0x60(%rsp), %rdi
movl 0x10(%rsp), %esi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x160c0
movq %rax, 0x20(%rsp)
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x107ba
movq %rax, %rdi
movq %r14, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x371b5(%rip), %rsi     # 0xab8eb
callq 0x3bfc6
movq %rax, %rdi
movq %rbp, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0xc(%rsp), %rsi
callq 0x10736
movq %rax, %rdi
leaq 0x30b45(%rip), %rsi     # 0xa52a2
callq 0x106fe
movq %r15, %rdi
callq 0x68d4
leaq 0x40(%rsp), %rdi
callq 0x2090
movl 0xc(%rsp), %r12d
addl 0xa0(%rsp), %r12d
movl %r12d, 0xc(%rsp)
movl 0x10(%rsp), %esi
incl %esi
movq 0x18(%rsp), %rdx
movq 0x38(%rsp), %rax
jmp 0x74678
incq %rdx
jmp 0x7465f
leaq 0x35e88(%rip), %rsi     # 0xaa632
leaq 0x40(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x66a0
xorl %esi, %esi
cmpl $0x78, %r12d
sete %sil
leaq 0xa8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x6894
leaq 0x18e6b(%rip), %rsi     # 0x8d647
leaq 0xa8(%rsp), %rdi
callq 0x106fe
leaq 0x370fb(%rip), %rsi     # 0xab8eb
movq %rax, %rdi
callq 0x3bfc6
leaq 0x1cdf3(%rip), %rsi     # 0x915f2
movq %rax, %rdi
callq 0x106fe
leaq 0xc(%rsp), %rsi
movq %rax, %rdi
callq 0x10736
leaq 0x18e2c(%rip), %rsi     # 0x8d647
movq %rax, %rdi
callq 0x106fe
leaq 0x35e20(%rip), %rsi     # 0xaa64a
movq %rax, %rdi
callq 0x1110a
leaq 0x1cdb9(%rip), %rsi     # 0x915f2
movq %rax, %rdi
callq 0x106fe
leaq 0x20(%rsp), %rsi
movl $0x78, (%rsi)
movq %rax, %rdi
callq 0x10736
leaq 0x30a47(%rip), %rsi     # 0xa52a2
movq %rax, %rdi
callq 0x106fe
leaq 0xa8(%rsp), %rdi
callq 0x68d4
leaq 0x40(%rsp), %rdi
callq 0x2090
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x748ca
jmp 0x74895
jmp 0x748a9
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x68d4
jmp 0x748c0
jmp 0x748d2
movq %rax, %rbx
jmp 0x748c0
jmp 0x748b0
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x68d4
leaq 0x40(%rsp), %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x22f0
movq %rax, %rdi
callq 0x6bba