// File: /workspace/github_cpp_makefile_star2_O3/dsharlet[P]array/test/array.cpp
// Function: nda::test_sparse_array_body()
TEST(sparse_array) {
  auto sparse_shape = make_shape(dim<>(-2, 5, 2), dim<>(4, 10));
  sparse_shape.resolve();
  ASSERT_LT(sparse_shape.size(), sparse_shape.flat_extent());

  array<int, shape<dim<>, dim<>>> sparse(sparse_shape);
  // Fill the storage with a constant.
  for (size_t i = 0; i < sparse_shape.flat_extent(); i++) {
    sparse.data()[i] = 7;
  }
  // Assign a different constant.
  sparse.assign(sparse_shape, 3);

  // Check that we assigned all of the elements of the array.
  for (int y = 4; y < 14; y++) {
    for (int x = -2; x < 3; x++) {
      ASSERT_EQ(sparse(x, y), 3);
    }
  }

  // Check that only the elements of the array were assigned.
  size_t sevens = 0;
  for (size_t i = 0; i < sparse_shape.flat_extent(); i++) {
    if (sparse.data()[i] == 7) { sevens++; }
  }
  ASSERT_EQ(sevens + sparse.size(), sparse_shape.flat_extent());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movabsq $0x7ffffffffffffffc, %r14 # imm = 0x7FFFFFFFFFFFFFFC
leaq 0x40(%rsp), %rsi
movq $0x4, -0x18(%rsi)
movq $0xa, -0x10(%rsi)
leaq 0x4(%r14), %rax
movq %rax, -0x8(%rsi)
movq $-0x2, (%rsi)
movq $0x5, 0x8(%rsi)
movq $0x2, 0x10(%rsi)
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %rbx, %rdx
callq 0xe37c
movq 0x20(%rbx), %r13
movq 0x8(%rbx), %r12
movq 0x10(%rbx), %rbp
movq 0x28(%rbx), %rbx
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x9128c(%rip), %rsi     # 0xa4eb2
leaq 0x912b5(%rip), %rdx     # 0xa4ee2
leaq 0x58(%rsp), %rdi
callq 0xd14c
movq %rbx, %rax
negq %rax
cmovsq %rbx, %rax
leaq -0x1(%r13), %rcx
imulq %rax, %rcx
movq %rbp, %rax
negq %rax
cmovsq %rbp, %rax
leaq -0x1(%r12), %rdx
imulq %rax, %rdx
addq %rcx, %rdx
movq $-0x1, %rax
cmovnsq %rdx, %rax
incq %rax
imulq %r13, %r12
xorl %ecx, %ecx
testq %r12, %r12
cmovgq %r12, %rcx
xorl %esi, %esi
cmpq %rax, %rcx
setb %sil
leaq 0xb0(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0xbf80
leaq 0x8f9e8(%rip), %rsi     # 0xa3684
leaq 0xb0(%rsp), %rdi
callq 0x18fba
leaq 0x91233(%rip), %rsi     # 0xa4ee3
movq %rax, %rdi
callq 0x1990c
leaq 0x93597(%rip), %rsi     # 0xa7256
movq %rax, %rdi
callq 0x18fba
movq %rax, %rbx
cmpb $0x1, 0x188(%rax)
jne 0x13cf3
movq 0x48(%rsp), %rax
imulq 0x30(%rsp), %rax
xorl %esi, %esi
testq %rax, %rax
cmovgq %rax, %rsi
movq %rbx, %rdi
addq $0x10, %rdi
callq 0x2110
leaq 0x8f98a(%rip), %rsi     # 0xa3684
movq %rbx, %rdi
callq 0x18fba
leaq 0x911bf(%rip), %rsi     # 0xa4ec8
movq %rax, %rdi
callq 0x19944
leaq 0x9353e(%rip), %rsi     # 0xa7256
movq %rax, %rdi
callq 0x18fba
movq %rax, %rbx
cmpb $0x1, 0x188(%rax)
jne 0x13d7f
movq 0x50(%rsp), %rax
movq %rax, %rcx
negq %rcx
cmovsq %rax, %rcx
movq 0x48(%rsp), %rax
decq %rax
imulq %rcx, %rax
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq %rdx, %rsi
negq %rsi
cmovsq %rdx, %rsi
decq %rcx
imulq %rsi, %rcx
addq %rax, %rcx
movq $-0x1, %rsi
cmovnsq %rcx, %rsi
incq %rsi
movq %rbx, %rdi
addq $0x10, %rdi
callq 0x2110
leaq 0xa6513(%rip), %rsi     # 0xba299
movq %rbx, %rdi
callq 0x18fba
leaq 0xb0(%rsp), %rdi
callq 0xbfd8
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x13db2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21f0
xorps %xmm0, %xmm0
leaq 0x58(%rsp), %rbx
movups %xmm0, 0x8(%rbx)
movq $0x0, 0x18(%rbx)
movdqu 0x28(%rsp), %xmm0
movdqu 0x38(%rsp), %xmm1
movdqu 0x48(%rsp), %xmm2
movdqu %xmm0, 0x20(%rbx)
movdqu %xmm1, 0x30(%rbx)
movdqu %xmm2, 0x40(%rbx)
movq %rbx, %rdi
callq 0xe236
movq %rbx, %rdi
callq 0xe334
movq 0x48(%rsp), %rax
decq %rax
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rdx
decq %rcx
movq %rdx, %rsi
negq %rsi
cmovsq %rdx, %rsi
movq 0x50(%rsp), %rdx
imulq %rcx, %rsi
movq %rdx, %rcx
negq %rcx
cmovsq %rdx, %rcx
imulq %rax, %rcx
addq %rsi, %rcx
js 0x13f7e
movq 0x98(%rsp), %rax
decq %rax
movq 0xa0(%rsp), %rdx
movq %rdx, %rsi
sarq $0x3f, %rsi
andq %rdx, %rsi
imulq %rax, %rsi
movq 0x70(%rsp), %rdx
movq 0x80(%rsp), %rax
decq %rax
movq 0x88(%rsp), %rdi
movq %rdi, %r8
sarq $0x3f, %r8
andq %rdi, %r8
imulq %rax, %r8
testq %rdx, %rdx
leaq (%rdx,%r8,4), %rax
leaq (%rax,%rsi,4), %rax
cmoveq %rdx, %rax
andq %rcx, %r14
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
addq $0x4, %r14
movdqa 0x8f17b(%rip), %xmm1    # 0xa3020
movdqa 0x8f183(%rip), %xmm2    # 0xa3030
xorl %ecx, %ecx
movdqa 0x8f189(%rip), %xmm3    # 0xa3040
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x90ca9(%rip), %xmm5    # 0xa4b70
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x13f02
movl $0x7, (%rax,%rcx,4)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x13f18
movl $0x7, 0x4(%rax,%rcx,4)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x13f57
movl $0x7, 0x8(%rax,%rcx,4)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x13f69
movl $0x7, 0xc(%rax,%rcx,4)
addq $0x4, %rcx
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
cmpq %rcx, %r14
jne 0x13ec7
movups 0x28(%rsp), %xmm0
movups 0x38(%rsp), %xmm1
movups 0x48(%rsp), %xmm2
leaq 0x240(%rsp), %rsi
movaps %xmm2, 0x20(%rsi)
movaps %xmm1, 0x10(%rsi)
movaps %xmm0, (%rsi)
leaq 0xb0(%rsp), %rdx
movl $0x3, (%rdx)
leaq 0x58(%rsp), %rdi
callq 0x1997c
movl $0x4, %eax
movq %rax, (%rsp)
leaq 0x8(%rsp), %rbx
leaq 0xb0(%rsp), %r12
leaq 0x8f6af(%rip), %r13     # 0xa3684
leaq 0x9327a(%rip), %r15     # 0xa7256
movq $-0x2, %rax
movq %r13, %rbp
movq %rax, 0xa8(%rsp)
subq 0x90(%rsp), %rax
imulq 0xa0(%rsp), %rax
movq (%rsp), %rcx
subq 0x78(%rsp), %rcx
imulq 0x88(%rsp), %rcx
shlq $0x2, %rcx
addq 0x70(%rsp), %rcx
movl (%rcx,%rax,4), %r14d
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbx, %r13
movq %rbx, %rdi
leaq 0x90f51(%rip), %rsi     # 0xa4f86
leaq 0x90f5b(%rip), %rdx     # 0xa4f97
callq 0xd14c
xorl %esi, %esi
cmpl $0x3, %r14d
sete %sil
movq %r12, %rdi
movq %r13, %rbx
movq %r13, %rdx
callq 0xbf80
movq %rbp, %r13
movq %r12, %rdi
movq %rbp, %rsi
callq 0x18fba
movq %rax, %rdi
leaq 0x90c4a(%rip), %rsi     # 0xa4cbb
callq 0x190d2
movq %rax, %rdi
movq %r15, %rsi
callq 0x18fba
movq %rax, %r14
cmpb $0x1, 0x188(%rax)
jne 0x140d0
movq (%rsp), %rax
subq 0x78(%rsp), %rax
imulq 0x88(%rsp), %rax
shlq $0x2, %rax
addq 0x70(%rsp), %rax
movq 0xa8(%rsp), %rcx
subq 0x90(%rsp), %rcx
imulq 0xa0(%rsp), %rcx
movq %r14, %rdi
addq $0x10, %rdi
movl (%rax,%rcx,4), %esi
callq 0x22f0
movq %r14, %rdi
movq %r13, %rsi
callq 0x18fba
movq %rax, %rdi
leaq 0x99874(%rip), %rsi     # 0xad959
callq 0x18fba
movq %rax, %rdi
movq %r15, %rsi
callq 0x18fba
movq %rax, %r14
cmpb $0x1, 0x188(%rax)
jne 0x14112
movq %r14, %rdi
addq $0x10, %rdi
movl $0x3, %esi
callq 0x22f0
movq %r14, %rdi
leaq 0xa617d(%rip), %rsi     # 0xba299
callq 0x18fba
movq %r12, %rdi
callq 0xbfd8
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x14145
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0xa8(%rsp), %rax
incq %rax
cmpq $0x3, %rax
jne 0x13fe3
movq (%rsp), %rax
incq %rax
movq %rax, (%rsp)
cmpq $0xe, %rax
jne 0x13fdc
movq 0x48(%rsp), %rax
decq %rax
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rdx
decq %rcx
movq %rdx, %rsi
negq %rsi
cmovsq %rdx, %rsi
movq 0x50(%rsp), %rdx
imulq %rcx, %rsi
movq %rdx, %rcx
negq %rcx
cmovsq %rdx, %rcx
imulq %rax, %rcx
addq %rsi, %rcx
movq $-0x1, %rbx
cmovnsq %rcx, %rbx
incq %rbx
jne 0x141cd
movq 0x80(%rsp), %r12
movq 0x98(%rsp), %r15
xorl %r14d, %r14d
jmp 0x1423f
movq 0x98(%rsp), %r15
leaq -0x1(%r15), %rax
movq 0xa0(%rsp), %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
imulq %rax, %rdx
movq 0x70(%rsp), %rcx
movq 0x80(%rsp), %r12
leaq -0x1(%r12), %rax
movq 0x88(%rsp), %rsi
movq %rsi, %rdi
sarq $0x3f, %rdi
andq %rsi, %rdi
imulq %rax, %rdi
testq %rcx, %rcx
leaq (%rcx,%rdi,4), %rax
leaq (%rax,%rdx,4), %rax
cmoveq %rcx, %rax
xorl %ecx, %ecx
xorl %r14d, %r14d
xorl %edx, %edx
cmpl $0x7, (%rax,%rcx,4)
sete %dl
addq %rdx, %r14
incq %rcx
cmpq %rcx, %rbx
jne 0x1422b
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
leaq 0x90d45(%rip), %rsi     # 0xa4f98
leaq 0x90d72(%rip), %rdx     # 0xa4fcc
callq 0xd14c
imulq %r15, %r12
xorl %eax, %eax
testq %r12, %r12
cmovgq %r12, %rax
addq %r14, %rax
xorl %esi, %esi
cmpq %rbx, %rax
sete %sil
leaq 0xb0(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xbf80
leaq 0x8f3f3(%rip), %rsi     # 0xa3684
leaq 0xb0(%rsp), %rdi
callq 0x18fba
leaq 0x90d28(%rip), %rsi     # 0xa4fcd
movq %rax, %rdi
callq 0x19aca
leaq 0x92fa2(%rip), %rsi     # 0xa7256
movq %rax, %rdi
callq 0x18fba
movq %rax, %rbx
cmpb $0x1, 0x188(%rax)
jne 0x142f1
movq 0x98(%rsp), %rax
imulq 0x80(%rsp), %rax
xorl %esi, %esi
testq %rax, %rax
cmovgq %rax, %rsi
addq %r14, %rsi
movq %rbx, %rdi
addq $0x10, %rdi
callq 0x2110
leaq 0x8f38c(%rip), %rsi     # 0xa3684
movq %rbx, %rdi
callq 0x18fba
leaq 0x90bc1(%rip), %rsi     # 0xa4ec8
movq %rax, %rdi
callq 0x19944
leaq 0x92f40(%rip), %rsi     # 0xa7256
movq %rax, %rdi
callq 0x18fba
movq %rax, %rbx
cmpb $0x1, 0x188(%rax)
jne 0x1437d
movq 0x50(%rsp), %rax
movq %rax, %rcx
negq %rcx
cmovsq %rax, %rcx
movq 0x48(%rsp), %rax
decq %rax
imulq %rcx, %rax
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq %rdx, %rsi
negq %rsi
cmovsq %rdx, %rsi
decq %rcx
imulq %rsi, %rcx
addq %rax, %rcx
movq $-0x1, %rsi
cmovnsq %rcx, %rsi
incq %rsi
movq %rbx, %rdi
addq $0x10, %rdi
callq 0x2110
leaq 0xa5f15(%rip), %rsi     # 0xba299
movq %rbx, %rdi
callq 0x18fba
leaq 0xb0(%rsp), %rdi
callq 0xbfd8
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x143b5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x58(%rsp), %rdi
callq 0xe84a
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14478
jmp 0x1442c
jmp 0x1442c
movq %rax, %rbx
jmp 0x1446e
jmp 0x143f1
jmp 0x14403
jmp 0x14433
movq %rax, %rbx
jmp 0x14413
jmp 0x143f1
jmp 0x14403
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xbfd8
jmp 0x14448
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xbfd8
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x1446e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x1446e
movq %rax, %rbx
jmp 0x14464
jmp 0x14438
movq %rax, %rbx
jmp 0x14448
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xbfd8
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x14464
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x58(%rsp), %rdi
callq 0xe84a
movq %rbx, %rdi
callq 0x2300
jmp 0x14478
movq %rax, %rdi
callq 0xc0a9