// File: /workspace/github_cpp_makefile_star2_O3/dsharlet[P]array/test/ein_reduce.cpp
// Function: nda::test_make_ein_sum_trace_body()
TEST(make_ein_sum_trace) {
  constexpr index_t N = 64;
  matrix<int, N, N> A;
  fill_pattern(A);

  // Compute trace(A) = sum(diag(A))
  int tr = make_ein_sum<int>(ein<i, i>(A));

  int tr_ref = 0;
  for (index_t i : A.i()) {
    tr_ref += A(i, i);
  }
  ASSERT_EQ(tr, tr_ref);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
leaq 0x10(%rsp), %rbx
movq $0x0, 0x30(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movups %xmm0, 0x18(%rbx)
movq %rax, 0x40(%rbx)
movq %rbx, %rdi
callq 0x5a070
movq %rbx, %rdi
callq 0x5a112
movq 0x18(%rbx), %rax
leaq 0x80(%rsp), %rdi
movq %rax, -0x8(%rdi)
movups 0x20(%rbx), %xmm0
movups %xmm0, (%rdi)
movups 0x30(%rbx), %xmm0
movups %xmm0, 0x10(%rdi)
movq 0x40(%rbx), %rax
movq %rax, 0x20(%rdi)
leaq 0xc(%rsp), %rax
movl $0x0, (%rax)
leaq 0x58(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x78(%rsp), %rax
movq %rax, 0x8(%rsi)
callq 0x5a32a
movq 0x28(%rsp), %rbx
movq 0x30(%rsp), %r15
movq 0x40(%rsp), %rbp
movq 0x50(%rsp), %r13
leaq 0xc(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x78(%rsp), %rdi
leaq 0xb(%rsp), %rsi
leaq 0xa(%rsp), %rcx
callq 0x580d4
leaq 0x90(%rsp), %r14
movq (%r14), %r12
leaq 0x58(%rsp), %rsi
movq %rbp, (%rsi)
movq $0x40, 0x8(%rsi)
movq $0x0, 0x10(%rsi)
xorl %edi, %edi
callq 0x5811f
movl (%r12), %eax
shlq $0x2, %rbp
shlq $0x2, %r15
subq %r15, %rbp
addq %rbp, %rbx
leaq 0x4(,%r13,4), %rcx
movl $0x40, %edx
addl (%rbx), %eax
movl %eax, (%r12)
addq %rcx, %rbx
decq %rdx
jne 0x50d5b
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rax
movl (%rax), %ebp
shlq $0x2, %rsi
callq 0x21f0
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rax
shlq $0x2, %rax
shlq $0x2, %rcx
subq %rcx, %rax
addq 0x28(%rsp), %rax
movq 0x50(%rsp), %rcx
leaq 0x4(,%rcx,4), %rcx
xorl %edx, %edx
xorl %ebx, %ebx
addl (%rax), %ebx
incq %rdx
addq %rcx, %rax
cmpq $0x40, %rdx
jne 0x50db7
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x5f03c(%rip), %rsi     # 0xafe12
leaq 0x5f041(%rip), %rdx     # 0xafe1e
leaq 0x58(%rsp), %rdi
callq 0xd14c
xorl %esi, %esi
cmpl %ebx, %ebp
sete %sil
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0xbf80
leaq 0x5287f(%rip), %rsi     # 0xa3684
leaq 0x78(%rsp), %rdi
callq 0x18fba
leaq 0x5f009(%rip), %rsi     # 0xafe1f
movq %rax, %rdi
callq 0x1917a
leaq 0x56431(%rip), %rsi     # 0xa7256
movq %rax, %rdi
callq 0x18fba
movq %rax, %r14
cmpb $0x1, 0x188(%rax)
jne 0x50e47
movq %r14, %rdi
addq $0x10, %rdi
movl %ebp, %esi
callq 0x22f0
leaq 0x52836(%rip), %rsi     # 0xa3684
movq %r14, %rdi
callq 0x18fba
leaq 0x5efbb(%rip), %rsi     # 0xafe18
movq %rax, %rdi
callq 0x57b7a
leaq 0x563ea(%rip), %rsi     # 0xa7256
movq %rax, %rdi
callq 0x18fba
movq %rax, %r14
cmpb $0x1, 0x188(%rax)
jne 0x50e8e
movq %r14, %rdi
addq $0x10, %rdi
movl %ebx, %esi
callq 0x22f0
leaq 0x69404(%rip), %rsi     # 0xba299
movq %r14, %rdi
callq 0x18fba
leaq 0x78(%rsp), %rdi
callq 0xbfd8
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x50ebe
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpq $0x0, 0x28(%rsp)
je 0x50ef9
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq $0x0, 0x40(%rsp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, 0x50(%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
shlq $0x2, %rsi
callq 0x21f0
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x50f2c
movq %rax, %rbx
cmpq $0x0, 0x90(%rsp)
je 0x50f5a
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x2504
jmp 0x50f5a
jmp 0x50f2c
movq %rax, %rbx
jmp 0x50f5a
movq %rax, %rbx
jmp 0x50f43
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0xbfd8
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x50f5a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpq $0x0, 0x28(%rsp)
je 0x50f95
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq $0x0, 0x40(%rsp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, 0x50(%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
shlq $0x2, %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2300
movq %rax, %rdi
callq 0xc0a9