// File: 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
movq %rsp, %rbp
subq $0x480, %rsp            # imm = 0x480
movq $0x40, -0x120(%rbp)
leaq -0x168(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0xc6b50
movq -0x3c0(%rbp), %rdi
xorl %esi, %esi
callq 0xc6b80
jmp 0xabe99
leaq -0x1d0(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0xc6bb0
jmp 0xabeae
movl $0x0, -0x1d4(%rbp)
leaq -0x1d5(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x10e30
movq -0x3c8(%rbp), %rax
leaq -0x1a0(%rbp), %rcx
movq %rcx, -0x40(%rbp)
leaq -0x1d0(%rbp), %rcx
movq %rcx, -0x48(%rbp)
leaq -0x1d4(%rbp), %rcx
movq %rcx, -0x50(%rbp)
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rdi
callq 0xb58b0
jmp 0xabf02
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
leaq -0x88(%rbp), %rdi
leaq -0x59(%rbp), %rsi
callq 0xcbfb0
jmp 0xabf1c
movq -0x48(%rbp), %rax
movq %rax, -0x3d8(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xcbff0
movq %rax, -0x3d0(%rbp)
jmp 0xabf3c
movq -0x3d8(%rbp), %rdx
movq -0x3d0(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xcc020
jmp 0xabf66
leaq -0xc8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq $0x1, -0x20(%rbp)
movq -0x18(%rbp), %rdx
movq %rdx, %r8
addq $0x10, %r8
leaq -0x30(%rbp), %rdi
leaq -0x31(%rbp), %rsi
leaq -0x32(%rbp), %rcx
callq 0xb5b40
jmp 0xabf97
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb5d70
jmp 0xabfa6
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x10(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x3e0(%rbp)
movq -0x3e0(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x99b30
jmp 0xac024
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x11610
movq -0xe0(%rbp), %rcx
movl -0xe4(%rbp), %eax
movq %rcx, -0x3f0(%rbp)
movl %eax, -0x3e4(%rbp)
jmp 0xac1e3
leaq -0x88(%rbp), %rdi
callq 0x11610
leaq -0x1a0(%rbp), %rdi
callq 0xc6e80
movq %rax, -0x3f8(%rbp)
jmp 0xac045
movq -0x3f8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x404(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x11610
leaq -0x1d5(%rbp), %rdi
callq 0x10e50
movl -0x404(%rbp), %eax
movl %eax, -0x178(%rbp)
movl $0x0, -0x1dc(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xc6c20
movq %rax, -0x400(%rbp)
jmp 0xac097
movq -0x400(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rdi
callq 0xc6c40
movq %rax, -0x410(%rbp)
jmp 0xac0ba
movq -0x410(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x1e8(%rbp), %rdi
callq 0xc6c70
movq %rax, -0x418(%rbp)
jmp 0xac0dd
movq -0x418(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x1f0(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x1f8(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x110(%rbp), %rax
movq (%rax), %rax
movq -0x118(%rbp), %rcx
cmpq (%rcx), %rax
setne %al
movb %al, -0x419(%rbp)
movb -0x419(%rbp), %al
testb $0x1, %al
jne 0xac133
jmp 0xac22e
leaq -0x1f0(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x428(%rbp)
movq -0x428(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x200(%rbp), %rdx
leaq -0x168(%rbp), %rdi
movq %rdx, %rsi
callq 0xc6d00
movq %rax, -0x430(%rbp)
jmp 0xac17f
movq -0x430(%rbp), %rax
movl (%rax), %eax
addl -0x1dc(%rbp), %eax
movl %eax, -0x1dc(%rbp)
leaq -0x1f0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xac0eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xac427
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x3f0(%rbp)
movl %eax, -0x3e4(%rbp)
jmp 0xac1e3
movq -0x3f0(%rbp), %rcx
movl -0x3e4(%rbp), %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xac21d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x11610
leaq -0x1d5(%rbp), %rdi
callq 0x10e50
jmp 0xac427
movl -0x178(%rbp), %eax
movl -0x1dc(%rbp), %ecx
subl %ecx, %eax
sete %al
movb %al, -0x439(%rbp)
leaq -0x3b1(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x33b0
movq -0x438(%rbp), %rdx
leaq 0x13d6f8(%rip), %rsi    # 0x1e995e
leaq -0x3b0(%rbp), %rdi
callq 0x10a90
jmp 0xac274
movb -0x439(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x390(%rbp), %rdi
leaq -0x3b0(%rbp), %rdx
callq 0x10f80
jmp 0xac295
leaq 0x130549(%rip), %rsi    # 0x1dc7e5
leaq -0x390(%rbp), %rdi
callq 0x34320
movq %rax, -0x448(%rbp)
jmp 0xac2b1
movq -0x448(%rbp), %rdi
leaq 0x13d6ac(%rip), %rsi    # 0x1e996b
callq 0x34840
movq %rax, -0x450(%rbp)
jmp 0xac2cd
movq -0x450(%rbp), %rdi
leaq 0x1344d1(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x458(%rbp)
jmp 0xac2e9
movq -0x458(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x343a0
movq %rax, -0x460(%rbp)
jmp 0xac305
movq -0x460(%rbp), %rdi
leaq 0x1304d2(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0x468(%rbp)
jmp 0xac321
movq -0x468(%rbp), %rdi
leaq 0x13d635(%rip), %rsi    # 0x1e9964
callq 0xc6ea0
movq %rax, -0x470(%rbp)
jmp 0xac33d
movq -0x470(%rbp), %rdi
leaq 0x134461(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x478(%rbp)
jmp 0xac359
movq -0x478(%rbp), %rdi
leaq -0x1dc(%rbp), %rsi
callq 0x343a0
movq %rax, -0x480(%rbp)
jmp 0xac375
movq -0x480(%rbp), %rdi
leaq 0x14a0f8(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0xac38a
leaq -0x390(%rbp), %rdi
callq 0x10ff0
jmp 0xac398
leaq -0x3b0(%rbp), %rdi
callq 0x3100
leaq -0x3b1(%rbp), %rdi
callq 0x3290
leaq -0x168(%rbp), %rdi
callq 0xc6d90
addq $0x480, %rsp            # imm = 0x480
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xac41b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xac40f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x10ff0
jmp 0xac40d
jmp 0xac40f
leaq -0x3b0(%rbp), %rdi
callq 0x3100
leaq -0x3b1(%rbp), %rdi
callq 0x3290
leaq -0x168(%rbp), %rdi
callq 0xc6d90
movq -0x170(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nopw (%rax,%rax)