// File: 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
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movq 0x2b33a(%rip), %rax     # 0x1fda2c
movq %rax, -0x38(%rbp)
movq 0x2b337(%rip), %rax     # 0x1fda34
movq %rax, -0x30(%rbp)
movq 0x2b334(%rip), %rax     # 0x1fda3c
movq %rax, -0x28(%rbp)
movq 0x2b331(%rip), %rax     # 0x1fda44
movq %rax, -0x20(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x18(%rbp)
movq $0x8, -0x10(%rbp)
leaq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x11250
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x11270
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x1d2b3c
movq -0x40(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x50(%rbp)
movq 0x2b2e3(%rip), %rax     # 0x1fda4c
movq %rax, -0x88(%rbp)
movq 0x2b2dd(%rip), %rax     # 0x1fda54
movq %rax, -0x80(%rbp)
movq 0x2b2da(%rip), %rax     # 0x1fda5c
movq %rax, -0x78(%rbp)
movq 0x2b2d7(%rip), %rax     # 0x1fda64
movq %rax, -0x70(%rbp)
leaq -0x88(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x8, -0x60(%rbp)
leaq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x11250
movq %rax, -0x90(%rbp)
movq -0x58(%rbp), %rdi
callq 0x11270
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x98(%rbp), %rax
je 0x1d2b29
movq -0x90(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x50(%rbp), %rsi
movq -0xa0(%rbp), %rdx
leaq -0x120(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x1d75e0
movq -0x340(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x34420
movq -0x338(%rbp), %rdi
movq $0x0, -0x128(%rbp)
callq 0x1d7620
movq %rax, -0x330(%rbp)
jmp 0x1d2849
movq -0x330(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0x3d4d0
jmp 0x1d285e
leaq -0x128(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0xf0(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x1d2b60
jmp 0x1d288f
movq -0x128(%rbp), %rax
movq %rax, -0x350(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x1d7640
movq %rax, -0x348(%rbp)
jmp 0x1d28b2
movq -0x348(%rbp), %rcx
movq -0x350(%rbp), %rax
subq %rcx, %rax
sete %al
movb %al, -0x359(%rbp)
leaq -0x309(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0x33b0
movq -0x358(%rbp), %rdx
leaq 0x2ab75(%rip), %rsi     # 0x1fd462
leaq -0x308(%rbp), %rdi
callq 0x10a90
jmp 0x1d28fb
movb -0x359(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x2e8(%rbp), %rdi
leaq -0x308(%rbp), %rdx
callq 0x10f80
jmp 0x1d291c
leaq 0x9ec2(%rip), %rsi      # 0x1dc7e5
leaq -0x2e8(%rbp), %rdi
callq 0x34320
movq %rax, -0x368(%rbp)
jmp 0x1d2938
movq -0x368(%rbp), %rdi
leaq 0x2af7b(%rip), %rsi     # 0x1fd8c1
callq 0x34570
movq %rax, -0x370(%rbp)
jmp 0x1d2954
movq -0x370(%rbp), %rdi
leaq 0xde4a(%rip), %rsi      # 0x1e07ac
callq 0x34320
movq %rax, -0x378(%rbp)
jmp 0x1d2970
movq -0x378(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x355c0
movq %rax, -0x380(%rbp)
jmp 0x1d298c
movq -0x380(%rbp), %rdi
leaq 0x9e4b(%rip), %rsi      # 0x1dc7e5
callq 0x34320
movq %rax, -0x388(%rbp)
jmp 0x1d29a8
movq -0x388(%rbp), %rdi
leaq 0x2aaba(%rip), %rsi     # 0x1fd470
callq 0x36600
movq %rax, -0x390(%rbp)
jmp 0x1d29c4
movq -0x390(%rbp), %rdi
leaq 0xddda(%rip), %rsi      # 0x1e07ac
callq 0x34320
movq %rax, -0x398(%rbp)
jmp 0x1d29e0
leaq -0xf0(%rbp), %rdi
callq 0x1d7640
movq %rax, -0x3a0(%rbp)
jmp 0x1d29f5
movq -0x398(%rbp), %rdi
movq -0x3a0(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x318(%rbp), %rsi
callq 0x355c0
movq %rax, -0x3a8(%rbp)
jmp 0x1d2a1f
movq -0x3a8(%rbp), %rdi
leaq 0x23a4e(%rip), %rsi     # 0x1f647b
callq 0x34320
jmp 0x1d2a34
leaq -0x2e8(%rbp), %rdi
callq 0x10ff0
jmp 0x1d2a42
leaq -0x308(%rbp), %rdi
callq 0x3100
leaq -0x309(%rbp), %rdi
callq 0x3290
leaq -0x328(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0x365d0
movq -0x3b0(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x37060
jmp 0x1d2a82
leaq -0xf0(%rbp), %rdi
callq 0x34950
movq -0x90(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x90(%rbp)
jmp 0x1d27cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x140(%rbp)
movl %eax, -0x144(%rbp)
jmp 0x1d2b1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x140(%rbp)
movl %eax, -0x144(%rbp)
jmp 0x1d2b0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x140(%rbp)
movl %eax, -0x144(%rbp)
jmp 0x1d2b03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x140(%rbp)
movl %eax, -0x144(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x10ff0
jmp 0x1d2b01
jmp 0x1d2b03
leaq -0x308(%rbp), %rdi
callq 0x3100
leaq -0x309(%rbp), %rdi
callq 0x3290
leaq -0xf0(%rbp), %rdi
callq 0x34950
jmp 0x1d2b45
jmp 0x1d2b2b
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
jmp 0x1d2749
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
movq -0x140(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nopl (%rax)