// File: /workspace/github_cpp_makefile_star2_O1/dsharlet[P]array/include/array/z_order.h
// Function: void nda::internal::for_each_index_in_z_order_impl<2ul, void nda::internal::for_each_in_z_order_impl<nda::internal::split_result<3l>, nda::internal::split_result<-9l>, void nda::for_all_in_z_order<nda::test_split_z_order_2d_body()::$_0, nda::internal::split_result<3l>, nda::internal::split_result<-9l>>(std::tuple<nda::internal::split_result<3l>, nda::internal::split_result<-9l>> const&, nda::test_split_z_order_2d_body()::$_0 const&)::'lambda'(nda::test_split_z_order_2d_body()::$_0 const&), 0ul, 1ul>(std::tuple<nda::internal::split_result<3l>, nda::internal::split_result<-9l>> const&, void nda::for_all_in_z_order<nda::test_split_z_order_2d_body()::$_0, nda::internal::split_result<3l>, nda::internal::split_result<-9l>>(std::tuple<nda::internal::split_result<3l>, nda::internal::split_result<-9l>> const&, nda::test_split_z_order_2d_body()::$_0 const&)::'lambda'(nda::test_split_z_order_2d_body()::$_0 const&) const&, std::integer_sequence<unsigned long, 0ul, 1ul>)::'lambda'(std::array<long, 2ul> const&)>(std::array<long, 2ul> const&, std::array<long, 2ul>, long, long, void nda::for_all_in_z_order<nda::test_split_z_order_2d_body()::$_0, nda::internal::split_result<3l>, nda::internal::split_result<-9l>>(std::tuple<nda::internal::split_result<3l>, nda::internal::split_result<-9l>> const&, nda::test_split_z_order_2d_body()::$_0 const&)::'lambda'(nda::test_split_z_order_2d_body()::$_0 const&) const&)
NDARRAY_UNIQUE void for_each_index_in_z_order_impl(const std::array<index_t, Rank>& end,
    std::array<index_t, Rank> z, index_t dim, index_t step, const Fn& fn) {
  if (dim == 0 && step == 1) {
    // We're at the innermost step of the traversal, call fn for the two neighboring points we have.
    fn(z);
    z[0] += 1;
    if (z[0] < end[0]) {
      fn(z);
    }
  } else if (dim == 0) {
    // We're on the innermost dimension, but not the innermost step.
    // Move to the next step for the outermost dimension.
    for_each_index_in_z_order_impl(end, z, Rank - 1, step >> 1, fn);
    z[0] += step;
    if (z[0] < end[0]) {
      for_each_index_in_z_order_impl(end, z, Rank - 1, step >> 1, fn);
    }
  } else {
    // Move to the next dimension for the same step.
    for_each_index_in_z_order_impl(end, z, dim - 1, step, fn);
    z[dim] += step;
    if (z[dim] < end[dim]) {
      for_each_index_in_z_order_impl(end, z, dim - 1, step, fn);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, 0x8(%rsp)
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
movq %r13, %r14
xorq $0x1, %r14
movq %rbp, %rax
orq %r14, %rax
je 0x9fcd4
testq %rbp, %rbp
je 0x9fc9d
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
movq %r13, %r8
movq 0x8(%rsp), %r9
callq 0x9fc38
addq %r13, %rbx
movl $0x0, %ebp
cmpq 0x8(%r12), %rbx
jl 0x9fc64
jmp 0x9ff46
movq %r13, %r14
sarq %r14
movl $0x1, %ebp
movl $0x1, %ecx
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %r8
movq 0x8(%rsp), %r9
callq 0x9fc38
addq %r13, %r15
movq %r14, %r13
cmpq (%r12), %r15
jl 0x9fc5d
jmp 0x9ff46
movq 0x8(%rsp), %r14
movq (%r14), %rbp
movq 0x8(%r14), %rax
movq 0x40(%rax), %rcx
leaq 0x40(%rsp), %r13
movq %rcx, 0x10(%r13)
movups 0x30(%rax), %xmm0
movaps %xmm0, (%r13)
movq %r13, %rdi
movq %r15, %rsi
callq 0xa0512
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%r14), %rax
movq 0x10(%rax), %rcx
movq %rcx, 0x80(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x70(%rsp)
movq %rcx, 0x10(%r13)
movaps %xmm0, (%r13)
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0xa0568
movq (%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq (%rbp), %rax
movq %rax, 0x18(%rsp)
movq (%rax), %rbp
movq 0x18(%rbp), %r14
movq 0x30(%rbp), %rax
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %r13
leaq 0x40(%rsp), %rax
movq %r13, (%rax)
movq $0x3, 0x8(%rax)
movq $0x1, 0x10(%rax)
leaq 0x40(%rsp), %rsi
xorl %edi, %edi
callq 0xa03fc
movq %r13, %rax
subq 0x38(%rbp), %rax
movq 0x20(%rsp), %rsi
movq %rsi, %rcx
subq 0x20(%rbp), %rcx
imulq 0x30(%rbp), %rcx
testq %r14, %r14
leaq (%r14,%rax,4), %rax
leaq (%rax,%rcx,4), %rax
cmoveq %r14, %rax
leaq 0x40(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x48(%rsp), %rdi
movq %rsi, (%rdi)
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rdi)
movq 0x30(%rsp), %rsi
movq %rsi, 0x10(%rdi)
movq %r13, 0x18(%rdi)
leaq (%rax,%rax,2), %rax
testq %rax, %rax
movl $0x0, %edx
cmovgq %rax, %rdx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq %rdx, (%rax)
leaq 0x14(%rsp), %rax
movl $0x0, (%rax)
leaq 0x88(%rsp), %rsi
movq %rax, (%rsi)
movq %rcx, 0x8(%rsi)
callq 0xa0494
incq %r15
cmpq (%r12), %r15
jge 0x9ff46
movq 0x8(%rsp), %r14
movq (%r14), %rbp
movq 0x8(%r14), %rax
movq 0x40(%rax), %rcx
leaq 0x40(%rsp), %r12
movq %rcx, 0x10(%r12)
movups 0x30(%rax), %xmm0
movaps %xmm0, (%r12)
movq %r12, %rdi
movq %r15, %rsi
callq 0xa0512
movq (%rax), %r15
movq 0x8(%r14), %rax
movq 0x10(%rax), %rcx
movq %rcx, 0x80(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x70(%rsp)
movq %rcx, 0x10(%r12)
movaps %xmm0, (%r12)
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa0568
movq (%rax), %rbx
movq 0x8(%rax), %r13
movq (%rbp), %rax
movq %rax, 0x8(%rsp)
movq (%rax), %rbp
movq 0x18(%rbp), %r12
movq 0x30(%rbp), %rax
movq %rax, 0x18(%rsp)
movq %r15, (%r14)
movq $0x3, 0x8(%r14)
movq $0x1, 0x10(%r14)
xorl %r14d, %r14d
leaq 0x40(%rsp), %rsi
xorl %edi, %edi
callq 0xa03fc
movq %r15, %rax
subq 0x38(%rbp), %rax
movq %rbx, %rcx
subq 0x20(%rbp), %rcx
imulq 0x30(%rbp), %rcx
testq %r12, %r12
leaq (%r12,%rax,4), %rax
leaq (%rax,%rcx,4), %rax
cmoveq %r12, %rax
leaq 0x40(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x48(%rsp), %rdi
movq %rbx, (%rdi)
movq %r13, 0x8(%rdi)
movq 0x18(%rsp), %rax
movq %rax, 0x10(%rdi)
movq %r15, 0x18(%rdi)
leaq (,%r13,2), %rax
addq %r13, %rax
testq %rax, %rax
cmovgq %rax, %r14
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
addq %r14, (%rax)
movl $0x0, 0x14(%rsp)
leaq 0x88(%rsp), %rsi
leaq 0x14(%rsp), %rax
movq %rax, (%rsi)
movq %rcx, 0x8(%rsi)
callq 0xa0494
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq