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

  // Fully reduce T.
  int sum_ijk = 0;
  ein_reduce(ein(sum_ijk) -= ein<i, j, k>(T));

  int sum_ijk_ref = 0;
  T.for_each_value([&](int i) { sum_ijk_ref -= i; });
  ASSERT_EQ(sum_ijk, sum_ijk_ref);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x440, %rsp            # imm = 0x440
leaq -0x120(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
movl $0x4, %esi
movl $0x5, %edx
movl $0x8, %ecx
callq 0x34ec0
movq -0x3d8(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x34f10
movq -0x3d0(%rbp), %rdi
xorl %esi, %esi
callq 0x34fb0
jmp 0xb28c7
movl $0x0, -0x130(%rbp)
leaq -0x1e0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xc85a0
jmp 0xb28e6
leaq -0x130(%rbp), %rdi
callq 0xc75f0
movq %rax, -0x3e0(%rbp)
jmp 0xb28fb
movq -0x3e0(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x190(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
callq 0xc85e0
jmp 0xb2925
leaq -0x190(%rbp), %rax
movq %rax, -0x18(%rbp)
movq $0x3, -0x20(%rbp)
movq -0x18(%rbp), %rdx
movq %rdx, %r8
addq $0x10, %r8
leaq -0x68(%rbp), %rdi
leaq -0x69(%rbp), %rsi
leaq -0x6a(%rbp), %rcx
callq 0xbf0b0
jmp 0xb2956
movq -0x18(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xbf730
jmp 0xb2965
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, -0x3e8(%rbp)
movq -0x3e8(%rbp), %rax
movq %rax, -0x200(%rbp)
movl $0x0, -0x204(%rbp)
leaq -0x204(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0xb2bf0
jmp 0xb29be
movl -0x130(%rbp), %eax
movl -0x204(%rbp), %ecx
subl %ecx, %eax
sete %al
movb %al, -0x3f1(%rbp)
leaq -0x3c1(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x33b0
movq -0x3f0(%rbp), %rdx
leaq 0x13734d(%rip), %rsi    # 0x1e9d43
leaq -0x3c0(%rbp), %rdi
callq 0x10a90
jmp 0xb2a04
movb -0x3f1(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x3a0(%rbp), %rdi
leaq -0x3c0(%rbp), %rdx
callq 0x10f80
jmp 0xb2a25
leaq 0x129db9(%rip), %rsi    # 0x1dc7e5
leaq -0x3a0(%rbp), %rdi
callq 0x34320
movq %rax, -0x400(%rbp)
jmp 0xb2a41
movq -0x400(%rbp), %rdi
leaq 0x13730b(%rip), %rsi    # 0x1e9d5a
callq 0x34600
movq %rax, -0x408(%rbp)
jmp 0xb2a5d
movq -0x408(%rbp), %rdi
leaq 0x12dd41(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x410(%rbp)
jmp 0xb2a79
movq -0x410(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x343a0
movq %rax, -0x418(%rbp)
jmp 0xb2a95
movq -0x418(%rbp), %rdi
leaq 0x129d42(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0x420(%rbp)
jmp 0xb2ab1
movq -0x420(%rbp), %rdi
leaq 0x13728f(%rip), %rsi    # 0x1e9d4e
callq 0xc7360
movq %rax, -0x428(%rbp)
jmp 0xb2acd
movq -0x428(%rbp), %rdi
leaq 0x12dcd1(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x430(%rbp)
jmp 0xb2ae9
movq -0x430(%rbp), %rdi
leaq -0x204(%rbp), %rsi
callq 0x343a0
movq %rax, -0x438(%rbp)
jmp 0xb2b05
movq -0x438(%rbp), %rdi
leaq 0x143968(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0xb2b1a
leaq -0x3a0(%rbp), %rdi
callq 0x10ff0
jmp 0xb2b28
leaq -0x3c0(%rbp), %rdi
callq 0x3100
leaq -0x3c1(%rbp), %rdi
callq 0x3290
leaq -0xd8(%rbp), %rdi
callq 0x35160
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0xb2bcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0xb2bbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0xb2bb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x3a0(%rbp), %rdi
callq 0x10ff0
jmp 0xb2bb1
jmp 0xb2bb3
leaq -0x3c0(%rbp), %rdi
callq 0x3100
leaq -0x3c1(%rbp), %rdi
callq 0x3290
leaq -0xd8(%rbp), %rdi
callq 0x35160
movq -0x128(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nopl (%rax,%rax)