// File: /workspace/github_cpp_makefile_star2_O2/dsharlet[P]array/test/ein_reduce.cpp
// Function: nda::test_ein_reduce_dft_body()
TEST(ein_reduce_dft) {
  constexpr index_t N = 30;
  vector<float, N> x;
  fill_pattern(x);

  // Compute the DFT by multiplying by a function computing the DFT matrix.
  // This isn't fast, but it's a fun test of a reduction with a different
  // type than the operands.
  vector<std::complex<float>, N> X({}, 0.0f);
  ein_reduce(ein<j>(X) += ein<j, k>(W<N>) * ein<k>(x));

  const float tolerance = 1e-3f;
  for (index_t j = 0; j < N; j++) {
    std::complex<float> X_j_ref = 0.0f;
    for (index_t k = 0; k < N; k++) {
      X_j_ref += W<N>(j, k) * x(k);
    }
    ASSERT_LT(abs(X_j_ref - X(j)), tolerance);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
callq 0x46fbe
xorps %xmm0, %xmm0
movq %rbx, %rdi
callq 0x46fe8
leaq 0xd8(%rsp), %rdi
callq 0x4cc30
leaq 0xb8(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x58(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x4700c
movq 0xa0(%rsp), %r15
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x78(%rsp), %r14
leaq 0xd8(%rsp), %rdi
callq 0x4a34a
leaq 0xd8(%rsp), %rdi
pushq $0x1e
popq %rdx
movq 0x10(%rsp), %rsi
xorl %ecx, %ecx
callq 0x4a3a8
leaq 0xd8(%rsp), %rdi
movq (%rdi), %rdx
movq %r14, %rsi
callq 0x4a06b
movq 0xd8(%rsp), %rbx
leaq 0x1e(%rbx), %rax
movq %rax, 0x40(%rsp)
shlq $0x3, %r14
subq %r14, 0x38(%rsp)
cmpq 0x40(%rsp), %rbx
je 0x46822
movq 0xe8(%rsp), %r14
cvtsi2ss %rbx, %xmm0
movss %xmm0, 0x20(%rsp)
movq %rbx, %r13
subq 0x10(%rsp), %r13
movq 0x38(%rsp), %rax
leaq (%rax,%r14,8), %r12
xorl %ebp, %ebp
cmpq $0x1e, %rbp
je 0x4681d
leaq (%r14,%rbp), %rax
cvtsi2ss %rax, %xmm0
movss 0x20(%rsp), %xmm1
callq 0x47055
movss (%r15,%r13,4), %xmm1
unpcklps %xmm1, %xmm1            # xmm1 = xmm1[0,0,1,1]
mulps %xmm1, %xmm0
movsd (%r12,%rbp,8), %xmm1
addps %xmm0, %xmm1
movlps %xmm1, (%r12,%rbp,8)
incq %rbp
jmp 0x467e4
incq %rbx
jmp 0x467b7
leaq 0x1c(%rsp), %rax
movl $0x3a83126f, (%rax)     # imm = 0x3A83126F
xorl %r15d, %r15d
leaq 0xb8(%rsp), %r12
leaq 0xd8(%rsp), %rbp
leaq 0x46e00(%rip), %r14     # 0x8d647
leaq 0x4ada4(%rip), %r13     # 0x915f2
cmpq $0x1e, %r15
je 0x469d6
cvtsi2ss %r15, %xmm0
movss %xmm0, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
xorl %ebx, %ebx
cmpq $0x1e, %rbx
je 0x468b8
cvtsi2ss %rbx, %xmm1
movss 0x10(%rsp), %xmm0
callq 0x47055
movq 0xa0(%rsp), %rax
movq 0xa8(%rsp), %rcx
shlq $0x2, %rcx
subq %rcx, %rax
movss (%rax,%rbx,4), %xmm1
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
mulps %xmm1, %xmm0
movaps 0x20(%rsp), %xmm1
addps %xmm0, %xmm1
movaps %xmm1, 0x20(%rsp)
incq %rbx
jmp 0x4686d
movq 0x70(%rsp), %rax
movq %r15, %rcx
subq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x20(%rsp), %xmm1
subps %xmm0, %xmm1
movlps %xmm1, 0x50(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x470e8
movss %xmm0, 0x10(%rsp)
movq %r12, %rdi
leaq 0x54004(%rip), %rsi     # 0x9a8f5
leaq 0xf(%rsp), %rdx
callq 0x66a0
xorl %esi, %esi
movss 0x53a1b(%rip), %xmm0    # 0x9a320
ucomiss 0x10(%rsp), %xmm0
seta %sil
movq %rbp, %rdi
movq %r12, %rdx
callq 0x6894
movq %rbp, %rdi
movq %r14, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x53fe7(%rip), %rsi     # 0x9a915
callq 0x11036
movq %rax, %rdi
movq %r13, %rsi
callq 0x106fe
movq %rax, %rbx
movq %r15, %rax
subq 0x78(%rsp), %rax
movq 0x70(%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
movaps 0x20(%rsp), %xmm1
subps %xmm0, %xmm1
movlps %xmm1, 0x48(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x470e8
movss %xmm0, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
callq 0x3bfe2
movq %rax, %rdi
movq %r14, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x53f79(%rip), %rsi     # 0x9a90b
callq 0x1079e
movq %rax, %rdi
movq %r13, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x1c(%rsp), %rsi
callq 0x3bfe2
movq %rax, %rdi
leaq 0x5e8e9(%rip), %rsi     # 0xa52a2
callq 0x106fe
movq %rbp, %rdi
callq 0x68d4
movq %r12, %rdi
callq 0x2090
incq %r15
jmp 0x4684e
leaq 0x58(%rsp), %rdi
callq 0x470f2
leaq 0x88(%rsp), %rdi
callq 0x47102
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x46a03
jmp 0x46a03
movq %rax, %rbx
jmp 0x46a4b
jmp 0x46a3e
jmp 0x46a3e
jmp 0x46a3e
movq %rax, %rbx
jmp 0x46a25
jmp 0x46a15
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x68d4
leaq 0xb8(%rsp), %rdi
callq 0x2090
jmp 0x46a41
movq %rax, %rdi
callq 0x6bba
jmp 0x46a3e
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x470f2
leaq 0x88(%rsp), %rdi
callq 0x47102
movq %rbx, %rdi
callq 0x22f0