// File: /workspace/github_cpp_makefile_star2_O1/dsharlet[P]array/test/z_order.cpp
// Function: nda::test_for_each_in_z_order_2d_body()
TEST(for_each_in_z_order_2d) {
  for (index_t w : {1, 2, 3, 4, 5, 12, 16, 20}) {
    for (index_t h : {1, 2, 3, 4, 5, 12, 16, 20}) {
      dense_array<int, 2> a({w, h});
      size_t total_size = 0;
      for_all_indices_in_z_order(a.shape().extent(), [&](index_t x, index_t y) {
        total_size++;
        a(x, y) = pattern<int>(std::make_tuple(x, y));
      });
      // The total number of items in the inner splits should be equal to the size
      // of the array (no overlap among inner splits).
      ASSERT_EQ(total_size, a.size());
      check_pattern(a);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
leaq 0x48(%rsp), %r13
leaq 0xa8(%rsp), %r14
xorl %ecx, %ecx
leaq 0x20c72(%rip), %rax     # 0xbf3d4
movq %rcx, 0x28(%rsp)
movslq (%rcx,%rax), %rax
movq %rax, 0x30(%rsp)
xorl %ecx, %ecx
leaq 0x20c5b(%rip), %rax     # 0xbf3d4
movq %rcx, 0x38(%rsp)
movslq (%rcx,%rax), %rbx
xorl %ebp, %ebp
movq %rbp, 0xa8(%rsp)
movq 0x30(%rsp), %r12
movq %r12, 0xb0(%rsp)
movabsq $-0x8000000000000000, %r15 # imm = 0x8000000000000000
movq %r15, 0xb8(%rsp)
xorl %edi, %edi
movq %r14, %rsi
callq 0xd09f
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r13)
movups %xmm0, (%r13)
movq %rbx, 0x68(%rsp)
movq %r15, 0x70(%rsp)
movq %rbp, 0x78(%rsp)
movq %r12, 0x80(%rsp)
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x1c19e
movq %rbx, %rdi
callq 0x1c258
movq %rbp, (%rsp)
movq 0x68(%rsp), %rax
movq 0x80(%rsp), %rcx
movq %rsp, %rdx
movq %rdx, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
leaq 0x8(%rsp), %rdx
movq %rdx, 0x90(%rsp)
movq %rcx, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
cmpq %rax, %rcx
cmovgq %rcx, %rax
movl $0x1, %ecx
movq %rcx, %r8
addq %rcx, %rcx
cmpq %rax, %r8
jl 0x9e835
sarq %r8
cmpq $0x2, %r8
movl $0x1, %eax
cmovlq %rax, %r8
movl $0x1, %ecx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x90(%rsp), %r12
movq %r12, %r9
callq 0x9f937
movq (%rsp), %rbp
movq 0x68(%rsp), %r15
movq 0x80(%rsp), %rbx
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %r13
movq %r13, %rdi
leaq 0x20497(%rip), %rsi     # 0xbed35
leaq 0x204a6(%rip), %rdx     # 0xbed4b
callq 0xd0b8
imulq %rbx, %r15
testq %r15, %r15
movl $0x0, %eax
cmovleq %rax, %r15
xorl %esi, %esi
cmpq %r15, %rbp
sete %sil
movq %r14, %rdi
movq %r13, %rdx
callq 0xbf0a
movq %r13, %rbx
leaq 0x48(%rsp), %r13
leaq 0x2d77(%rip), %r15      # 0xa1654
movq %r14, %rdi
movq %r15, %rsi
callq 0x18a16
movq %rax, %rdi
leaq 0x207d8(%rip), %rsi     # 0xbf0ca
callq 0x18abe
movq %rax, %rdi
leaq 0x6a29(%rip), %rsi      # 0xa532a
callq 0x18a16
movq %rax, %rbp
cmpb $0x1, 0x188(%rax)
jne 0x9e922
movq %rbp, %rdi
addq $0x10, %rdi
movq (%rsp), %rsi
callq 0x2110
movq %rbp, %rdi
movq %r15, %rsi
callq 0x18a16
movq %rax, %rdi
leaq 0x2040c(%rip), %rsi     # 0xbed43
callq 0x19c24
movq %rax, %rdi
leaq 0x69e4(%rip), %rsi      # 0xa532a
callq 0x18a16
movq %rax, %rbp
cmpb $0x1, 0x188(%rax)
jne 0x9e97d
movq 0x80(%rsp), %rsi
imulq 0x68(%rsp), %rsi
testq %rsi, %rsi
movl $0x0, %eax
cmovleq %rax, %rsi
movq %rbp, %rdi
addq $0x10, %rdi
callq 0x2110
movq %rbp, %rdi
leaq 0x199e2(%rip), %rsi     # 0xb8369
callq 0x18a16
movq %r14, %rdi
callq 0xbf62
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9e9b0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0xa8(%rsp)
movups 0x18(%r13), %xmm0
movups 0x28(%r13), %xmm1
movups 0x38(%r13), %xmm2
leaq 0xb0(%rsp), %rdi
movups %xmm2, 0x20(%rdi)
movups %xmm1, 0x10(%rdi)
movups %xmm0, (%rdi)
movq %r14, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %rbx, %rsi
callq 0x2051c
leaq 0x40(%rsp), %rdi
callq 0x1cd2c
movq 0x38(%rsp), %rcx
addq $0x4, %rcx
cmpq $0x20, %rcx
jne 0x9e772
movq 0x28(%rsp), %rcx
addq $0x4, %rcx
cmpq $0x20, %rcx
jne 0x9e75b
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9ea42
jmp 0x9ea8e
movq %rax, %rbx
jmp 0x9ea7a
jmp 0x9ea4e
movq %rax, %rbx
jmp 0x9ea5e
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xbf62
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9ea7a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x40(%rsp), %rdi
callq 0x1cd2c
movq %rbx, %rdi
callq 0x2300
jmp 0x9ea8e
movq %rax, %rdi
callq 0xc036