// File: dsharlet[P]array/test/z_order.cpp
// Function: nda::test_split_z_order_2d_body()
TEST(split_z_order_2d) {
  for (index_t w : {3, 4, 5, 6, 12, 20}) {
    for (index_t h : {1, 2, 3, 4, 5, 6, 12, 20}) {
      dense_array<int, 2> a({w, h});
      size_t total_size = 0;
      auto xs = split<3>(a.x());
      auto ys = split(a.y(), 3);
      for_all_in_z_order(std::make_tuple(xs, ys), [&](const auto& xo, const auto& yo) {
        auto a_inner = a(xo, yo);
        total_size += a_inner.size();
        fill_pattern(a_inner);
      });
      // The total number of items in the inner splits should be equal to the size
      // of the array (no overlap among inner splits).
      ASSERT_LE(a.size(), total_size);
      check_pattern(a);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq 0x2a9aa(%rip), %rax     # 0x1fdacc
movq %rax, -0x30(%rbp)
movq 0x2a9a7(%rip), %rax     # 0x1fdad4
movq %rax, -0x28(%rbp)
movq 0x2a9a4(%rip), %rax     # 0x1fdadc
movq %rax, -0x20(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x18(%rbp)
movq $0x6, -0x10(%rbp)
leaq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x11250
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x11270
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x1d3598
movq -0x38(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x48(%rbp)
movq 0x2a956(%rip), %rax     # 0x1fdae4
movq %rax, -0x80(%rbp)
movq 0x2a953(%rip), %rax     # 0x1fdaec
movq %rax, -0x78(%rbp)
movq 0x2a950(%rip), %rax     # 0x1fdaf4
movq %rax, -0x70(%rbp)
movq 0x2a94d(%rip), %rax     # 0x1fdafc
movq %rax, -0x68(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $0x8, -0x58(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x11250
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rdi
callq 0x11270
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
je 0x1d3585
movq -0x88(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x48(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x118(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0x1d75e0
movq -0x3e8(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x34420
movq -0x3e0(%rbp), %rdi
movq $0x0, -0x120(%rbp)
callq 0x37090
movq %rax, -0x3d8(%rbp)
jmp 0x1d3268
movq -0x3d8(%rbp), %rsi
leaq -0x150(%rbp), %rdi
callq 0x1d7660
jmp 0x1d327d
leaq -0xe8(%rbp), %rdi
callq 0x37040
movq %rax, -0x3f0(%rbp)
jmp 0x1d3292
movq -0x3f0(%rbp), %rsi
leaq -0x190(%rbp), %rdi
movl $0x3, %edx
callq 0x162910
jmp 0x1d32ac
leaq -0x1f0(%rbp), %rdi
leaq -0x150(%rbp), %rsi
leaq -0x190(%rbp), %rdx
callq 0x1d76d0
jmp 0x1d32c8
leaq -0xe8(%rbp), %rax
movq %rax, -0x200(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x1d35c0
jmp 0x1d32f9
leaq -0xe8(%rbp), %rdi
callq 0x1d7640
movq %rax, -0x3f8(%rbp)
jmp 0x1d330e
movq -0x3f8(%rbp), %rax
movq -0x120(%rbp), %rcx
subq %rcx, %rax
setbe %al
movb %al, -0x401(%rbp)
leaq -0x3b1(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x33b0
movq -0x400(%rbp), %rdx
leaq 0x2a56c(%rip), %rsi     # 0x1fd8b5
leaq -0x3b0(%rbp), %rdi
callq 0x10a90
jmp 0x1d3357
movb -0x401(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x390(%rbp), %rdi
leaq -0x3b0(%rbp), %rdx
callq 0x10f80
jmp 0x1d3378
leaq 0x9466(%rip), %rsi      # 0x1dc7e5
leaq -0x390(%rbp), %rdi
callq 0x34320
movq %rax, -0x410(%rbp)
jmp 0x1d3394
movq -0x410(%rbp), %rdi
leaq 0x2a0ce(%rip), %rsi     # 0x1fd470
callq 0x36600
movq %rax, -0x418(%rbp)
jmp 0x1d33b0
movq -0x418(%rbp), %rdi
leaq 0xd3ee(%rip), %rsi      # 0x1e07ac
callq 0x34320
movq %rax, -0x420(%rbp)
jmp 0x1d33cc
leaq -0xe8(%rbp), %rdi
callq 0x1d7640
movq %rax, -0x428(%rbp)
jmp 0x1d33e1
movq -0x420(%rbp), %rdi
movq -0x428(%rbp), %rax
movq %rax, -0x3c0(%rbp)
leaq -0x3c0(%rbp), %rsi
callq 0x355c0
movq %rax, -0x430(%rbp)
jmp 0x1d340b
movq -0x430(%rbp), %rdi
leaq 0x93cc(%rip), %rsi      # 0x1dc7e5
callq 0x34320
movq %rax, -0x438(%rbp)
jmp 0x1d3427
movq -0x438(%rbp), %rdi
leaq 0x2a48c(%rip), %rsi     # 0x1fd8c1
callq 0x34570
movq %rax, -0x440(%rbp)
jmp 0x1d3443
movq -0x440(%rbp), %rdi
leaq 0xd35b(%rip), %rsi      # 0x1e07ac
callq 0x34320
movq %rax, -0x448(%rbp)
jmp 0x1d345f
movq -0x448(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x355c0
movq %rax, -0x450(%rbp)
jmp 0x1d347b
movq -0x450(%rbp), %rdi
leaq 0x22ff2(%rip), %rsi     # 0x1f647b
callq 0x34320
jmp 0x1d3490
leaq -0x390(%rbp), %rdi
callq 0x10ff0
jmp 0x1d349e
leaq -0x3b0(%rbp), %rdi
callq 0x3100
leaq -0x3b1(%rbp), %rdi
callq 0x3290
leaq -0x3d0(%rbp), %rdi
movq %rdi, -0x458(%rbp)
callq 0x365d0
movq -0x458(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x37060
jmp 0x1d34de
leaq -0xe8(%rbp), %rdi
callq 0x34950
movq -0x88(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x88(%rbp)
jmp 0x1d31eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0x1d3577
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0x1d356b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0x1d355f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x10ff0
jmp 0x1d355d
jmp 0x1d355f
leaq -0x3b0(%rbp), %rdi
callq 0x3100
leaq -0x3b1(%rbp), %rdi
callq 0x3290
leaq -0xe8(%rbp), %rdi
callq 0x34950
jmp 0x1d35a1
jmp 0x1d3587
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
jmp 0x1d316e
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
movq -0x158(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nopw %cs:(%rax,%rax)