// File: /workspace/github_cpp_makefile_star2_O2/dsharlet[P]array/test/ein_reduce.cpp
// Function: nda::test_make_ein_sum_sum_2d_body()
TEST(make_ein_sum_sum_2d) {
  array_of_rank<int, 3> T({4, 5, 8});
  fill_pattern(T);

  // Reduce T along the i and k dimensions, keeping j.
  dense_array<int, 1> sum_ik = make_ein_sum<int, j>(ein<i, j, k>(T));

  ASSERT_EQ(sum_ik.rank(), 1);
  ASSERT_EQ(sum_ik.i().extent(), T.j().extent());
  for (index_t j : T.i()) {
    int sum_ik_ref = 0;
    T(_, j, _).for_each_value([&](int i) { sum_ik_ref += i; });
    ASSERT_EQ(sum_ik(j), sum_ik_ref);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x378, %rsp            # imm = 0x378
leaq 0x1d0(%rsp), %rbx
pushq $0x4
popq %rsi
pushq $0x5
popq %rdx
pushq $0x8
popq %rcx
movq %rbx, %rdi
callq 0x10b74
leaq 0x138(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x10b92
movq %r14, %rdi
xorl %esi, %esi
callq 0x10bbd
movq 0x150(%rsp), %r14
movups 0x158(%rsp), %xmm0
movaps %xmm0, 0xc0(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x170(%rsp), %rbx
movups 0x178(%rsp), %xmm1
movdqu 0x188(%rsp), %xmm0
movdqa %xmm0, 0xa0(%rsp)
movq 0x198(%rsp), %rax
movq %rax, 0xb0(%rsp)
andl $0x0, 0xc(%rsp)
leaq 0x1d0(%rsp), %rsi
movq %rbx, (%rsi)
movaps %xmm1, 0x10(%rsp)
movlps %xmm1, 0x8(%rsi)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, 0x10(%rsi)
leaq 0x1b8(%rsp), %rdi
callq 0x3cc70
leaq 0x68(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0xb(%rsp), %rcx
callq 0x49ce2
movq 0x80(%rsp), %rax
movq 0x98(%rsp), %rcx
movq %rcx, 0x1e8(%rsp)
movups 0x88(%rsp), %xmm0
movups %xmm0, 0x1d8(%rsp)
movq %rax, 0x1d0(%rsp)
movq %r14, 0x1f0(%rsp)
movaps 0xc0(%rsp), %xmm0
movups %xmm0, 0x1f8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x208(%rsp)
movq %rbx, 0x210(%rsp)
movdqa 0x10(%rsp), %xmm1
movdqu %xmm1, 0x218(%rsp)
movdqa 0xa0(%rsp), %xmm0
movdqu %xmm0, 0x228(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x238(%rsp)
movq 0x1d8(%rsp), %rax
cmpq %rax, %rbx
jg 0x45c7a
movq %xmm1, %rcx
movdqu 0x1e0(%rsp), %xmm0
movq %xmm0, %rdx
addq %rax, %rdx
addq %rbx, %rcx
cmpq %rcx, %rdx
jg 0x45c7a
movups 0x228(%rsp), %xmm1
movups 0x1f8(%rsp), %xmm2
leaq 0xe0(%rsp), %rcx
movaps %xmm2, (%rcx)
leaq 0x1a0(%rsp), %rdx
movq %rax, (%rdx)
movdqu %xmm0, 0x8(%rdx)
leaq 0x360(%rsp), %rsi
movaps %xmm1, (%rsi)
leaq 0x20(%rsp), %rdi
callq 0x49d50
leaq 0x1f0(%rsp), %rbx
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rax
addq %r14, %rax
movq %rax, 0x10(%rsp)
cmpq 0x10(%rsp), %r14
je 0x45840
movq 0x38(%rsp), %r15
movq 0x40(%rsp), %rbp
addq %r15, %rbp
cmpq %rbp, %r15
je 0x4583b
movq 0x50(%rsp), %r12
movq 0x58(%rsp), %r13
subq $0x1, %r13
jb 0x45836
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x49cae
movl (%rax), %eax
movq 0x1d0(%rsp), %rcx
movq %r15, %rdx
subq 0x1d8(%rsp), %rdx
addl %eax, (%rcx,%rdx,4)
incq %r12
jmp 0x45802
incq %r15
jmp 0x457f3
incq %r14
jmp 0x457df
leaq 0x100(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3cd00
leaq 0x68(%rsp), %rdi
callq 0x1090e
leaq 0x54f97(%rip), %rsi     # 0x9a7fa
leaq 0x20(%rsp), %rdi
leaq 0x1a0(%rsp), %rdx
callq 0x66a0
leaq 0x1d0(%rsp), %rdi
pushq $0x1
popq %rsi
leaq 0x20(%rsp), %rdx
callq 0x6894
leaq 0x47db6(%rip), %rsi     # 0x8d647
leaq 0x1d0(%rsp), %rdi
callq 0x106fe
leaq 0x54f68(%rip), %rsi     # 0x9a80d
movq %rax, %rdi
callq 0x1085e
leaq 0x4bd3e(%rip), %rsi     # 0x915f2
movq %rax, %rdi
callq 0x106fe
leaq 0x68(%rsp), %rsi
movq $0x1, (%rsi)
movq %rax, %rdi
callq 0x11052
leaq 0x47d70(%rip), %rsi     # 0x8d647
movq %rax, %rdi
callq 0x106fe
leaq 0x4f416(%rip), %rsi     # 0x94cfc
movq %rax, %rdi
callq 0x106fe
leaq 0x4bcfd(%rip), %rsi     # 0x915f2
movq %rax, %rdi
callq 0x106fe
leaq 0xe0(%rsp), %rsi
movl $0x1, (%rsi)
movq %rax, %rdi
callq 0x10736
leaq 0x5f988(%rip), %rsi     # 0xa52a2
movq %rax, %rdi
callq 0x106fe
leaq 0x1d0(%rsp), %rdi
callq 0x68d4
leaq 0x20(%rsp), %rdi
callq 0x2090
movq 0x128(%rsp), %rbx
movq 0x178(%rsp), %r14
leaq 0x54ecb(%rip), %rsi     # 0x9a81b
leaq 0x20(%rsp), %rdi
leaq 0x1a0(%rsp), %rdx
callq 0x66a0
xorl %esi, %esi
cmpq %r14, %rbx
sete %sil
leaq 0x1d0(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x6894
leaq 0x47cc3(%rip), %rsi     # 0x8d647
leaq 0x1d0(%rsp), %rdi
callq 0x106fe
leaq 0x54ea9(%rip), %rsi     # 0x9a841
movq %rax, %rdi
callq 0x11036
leaq 0x4bc4b(%rip), %rsi     # 0x915f2
movq %rax, %rdi
callq 0x106fe
movq 0x128(%rsp), %rcx
leaq 0x68(%rsp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x107ba
leaq 0x47c79(%rip), %rsi     # 0x8d647
movq %rax, %rdi
callq 0x106fe
leaq 0x54e55(%rip), %rsi     # 0x9a832
movq %rax, %rdi
callq 0x11bb4
leaq 0x4bc06(%rip), %rsi     # 0x915f2
movq %rax, %rdi
callq 0x106fe
movq 0x178(%rsp), %rcx
leaq 0xe0(%rsp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x107ba
leaq 0x5f88c(%rip), %rsi     # 0xa52a2
movq %rax, %rdi
callq 0x106fe
leaq 0x1d0(%rsp), %rdi
callq 0x68d4
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x2090
leaq 0x138(%rsp), %rax
movq 0x50(%rax), %r15
movq 0x58(%rax), %rax
addq %r15, %rax
movq %rax, 0x10(%rsp)
leaq 0x1d0(%rsp), %r13
leaq 0x4bb93(%rip), %r14     # 0x915f2
cmpq 0x10(%rsp), %r15
je 0x45c2f
andl $0x0, 0x68(%rsp)
movq %r13, %rdi
leaq 0x138(%rsp), %rsi
movq %r15, %rdx
callq 0x46f7e
movq 0x1d0(%rsp), %rbp
movq %rbx, %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x9125
testq %rbp, %rbp
je 0x45b31
movq 0x48(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x40(%rsp), %rdx
testq %rdx, %rdx
movl $0x0, %esi
cmovgq %rdx, %rsi
movq 0x30(%rsp), %rdi
testq %rcx, %rcx
movl $0x0, %r8d
cmovleq %r8, %rcx
movl 0x68(%rsp), %r12d
shlq $0x2, %rdi
leaq (,%rax,4), %r8
xorl %r9d, %r9d
cmpq %rcx, %r9
je 0x45b4a
cmpq $0x1, %rax
jne 0x45b10
leaq (,%rdx,4), %r10
addq %rbp, %r10
movq %rbp, %r11
cmpq %r10, %r11
jae 0x45b29
addl (%r11), %r12d
addq $0x4, %r11
movl %r12d, 0x68(%rsp)
jmp 0x45afd
movq %rsi, %r10
movq %rbp, %r11
subq $0x1, %r10
jb 0x45b29
addl (%r11), %r12d
movl %r12d, 0x68(%rsp)
addq %r8, %r11
jmp 0x45b16
addq %rdi, %rbp
incq %r9
jmp 0x45ae4
movq 0x28(%rsp), %rax
imulq 0x40(%rsp), %rax
testq %rax, %rax
jg 0x45c5b
movl 0x68(%rsp), %r12d
movq 0x118(%rsp), %rax
movq %r15, %rcx
subq 0x120(%rsp), %rcx
movl (%rax,%rcx,4), %ebp
movq %rbx, %rdi
leaq 0x54ceb(%rip), %rsi     # 0x9a855
leaq 0xe0(%rsp), %rdx
callq 0x66a0
xorl %esi, %esi
cmpl %r12d, %ebp
sete %sil
movq %r13, %rdi
movq %rbx, %rdx
callq 0x6894
leaq 0x47ab5(%rip), %r12     # 0x8d647
movq %r13, %rdi
movq %r12, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x54cc6(%rip), %rsi     # 0x9a86d
callq 0x1079e
movq %rax, %rdi
movq %r14, %rsi
callq 0x106fe
movq %r15, %rsi
subq 0x120(%rsp), %rsi
shlq $0x2, %rsi
addq 0x118(%rsp), %rsi
movq %rax, %rdi
callq 0x10736
movq %rax, %rdi
movq %r12, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x54c77(%rip), %rsi     # 0x9a862
callq 0x107d8
movq %rax, %rdi
movq %r14, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x68(%rsp), %rsi
callq 0x10736
movq %rax, %rdi
leaq 0x5f690(%rip), %rsi     # 0xa52a2
callq 0x106fe
movq %r13, %rdi
callq 0x68d4
movq %rbx, %rdi
callq 0x2090
incq %r15
jmp 0x45a5f
leaq 0x100(%rsp), %rdi
callq 0x1090e
leaq 0x138(%rsp), %rdi
callq 0x10d02
addq $0x378, %rsp            # imm = 0x378
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4762d(%rip), %rdi     # 0x8d28f
leaq 0x47468(%rip), %rsi     # 0x8d0d1
leaq 0x584c5(%rip), %rcx     # 0x9e135
movl $0x6a1, %edx            # imm = 0x6A1
callq 0x20e0
leaq 0x5521f(%rip), %rdi     # 0x9aea0
leaq 0x55237(%rip), %rsi     # 0x9aebf
leaq 0x56b01(%rip), %rcx     # 0x9c790
movl $0xf2, %edx
callq 0x20e0
jmp 0x45cdc
jmp 0x45cdc
jmp 0x45d12
jmp 0x45d12
jmp 0x45cab
jmp 0x45cb4
jmp 0x45ce1
jmp 0x45cc6
jmp 0x45ce1
movq %rax, %rbx
jmp 0x45d1f
jmp 0x45cb4
jmp 0x45cc6
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x68d4
jmp 0x45cf6
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x68d4
jmp 0x45cf6
jmp 0x45cdc
jmp 0x45cdc
movq %rax, %rbx
jmp 0x45d00
movq %rax, %rbx
jmp 0x45cf6
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x68d4
leaq 0x20(%rsp), %rdi
callq 0x2090
leaq 0x100(%rsp), %rdi
jmp 0x45d1a
movq %rax, %rdi
callq 0x6bba
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x1090e
leaq 0x138(%rsp), %rdi
callq 0x10d02
movq %rbx, %rdi
callq 0x22f0