// File: dsharlet[P]array/test/ein_reduce.cpp
// Function: nda::test_ein_reduce_dot_offset_body()
TEST(ein_reduce_dot_offset) {
  constexpr index_t N = 40;
  vector<int, N> x;
  vector<int, N> y;
  vector<int, N> z;
  fill_pattern(x);
  fill_pattern(y, 2);
  fill_pattern(z, 6);

  // Compute the dot product (x + y).z.
  int dot = 0;
  ein_reduce(ein<>(dot) += (ein<i>(x) + ein<i>(y)) * ein<i>(z));

  int dot_ref = 0;
  for (index_t i : x.i()) {
    dot_ref += (x(i) + y(i)) * z(i);
  }
  ASSERT_EQ(dot, dot_ref);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movq $0x28, -0x60(%rbp)
leaq -0x90(%rbp), %rdi
callq 0xc74b0
leaq -0xc0(%rbp), %rdi
callq 0xc74b0
jmp 0xadedd
leaq -0x100(%rbp), %rdi
callq 0xc74b0
jmp 0xadeeb
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0xc74e0
jmp 0xadefb
leaq -0xc0(%rbp), %rdi
movl $0x2, %esi
callq 0xc74e0
jmp 0xadf0e
leaq -0x100(%rbp), %rdi
movl $0x6, %esi
callq 0xc74e0
jmp 0xadf21
movl $0x0, -0x104(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xc7510
jmp 0xadf40
leaq -0x208(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xc7510
jmp 0xadf55
leaq -0x1d8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
leaq -0x208(%rbp), %rdx
callq 0xc7550
jmp 0xadf71
leaq -0x220(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xc7510
jmp 0xadf86
leaq -0x1a8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
leaq -0x220(%rbp), %rdx
callq 0xc75a0
jmp 0xadfa2
leaq -0x104(%rbp), %rdi
callq 0xc75f0
movq %rax, -0x428(%rbp)
jmp 0xadfb7
movq -0x428(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x230(%rbp), %rsi
leaq -0x1a8(%rbp), %rdx
callq 0xc7640
jmp 0xadfe1
leaq -0x160(%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 0xb88c0
jmp 0xae012
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb8f70
jmp 0xae021
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, -0x430(%rbp)
movq -0x430(%rbp), %rax
movq %rax, -0x240(%rbp)
movl $0x0, -0x244(%rbp)
leaq -0x90(%rbp), %rdi
callq 0xc7680
movq %rax, -0x438(%rbp)
jmp 0xae06c
movq -0x438(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rdi
callq 0xc76a0
movq %rax, -0x440(%rbp)
jmp 0xae08f
movq -0x440(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x250(%rbp), %rdi
callq 0xc76d0
movq %rax, -0x448(%rbp)
jmp 0xae0b2
movq -0x448(%rbp), %rax
movq %rax, -0x260(%rbp)
leaq -0x258(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x260(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq -0x58(%rbp), %rcx
cmpq (%rcx), %rax
setne %al
movb %al, -0x449(%rbp)
movb -0x449(%rbp), %al
testb $0x1, %al
jne 0xae0fc
jmp 0xae21c
leaq -0x258(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x458(%rbp)
movq -0x458(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0xc7720
movq %rax, -0x460(%rbp)
jmp 0xae13f
movq -0x460(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x46c(%rbp)
movq -0x268(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0xc7720
movq %rax, -0x468(%rbp)
jmp 0xae16a
movl -0x46c(%rbp), %eax
movq -0x468(%rbp), %rcx
movl (%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x47c(%rbp)
movq -0x268(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0xc7720
movq %rax, -0x478(%rbp)
jmp 0xae19d
movq -0x478(%rbp), %rcx
movl -0x47c(%rbp), %eax
imull (%rcx), %eax
addl -0x244(%rbp), %eax
movl %eax, -0x244(%rbp)
leaq -0x258(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xae0c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0xae445
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0xae439
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0xae42d
movl -0x104(%rbp), %eax
movl -0x244(%rbp), %ecx
subl %ecx, %eax
sete %al
movb %al, -0x489(%rbp)
leaq -0x419(%rbp), %rdi
movq %rdi, -0x488(%rbp)
callq 0x33b0
movq -0x488(%rbp), %rdx
leaq 0x13b72b(%rip), %rsi    # 0x1e997f
leaq -0x418(%rbp), %rdi
callq 0x10a90
jmp 0xae262
movb -0x489(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x3f8(%rbp), %rdi
leaq -0x418(%rbp), %rdx
callq 0x10f80
jmp 0xae283
leaq 0x12e55b(%rip), %rsi    # 0x1dc7e5
leaq -0x3f8(%rbp), %rdi
callq 0x34320
movq %rax, -0x498(%rbp)
jmp 0xae29f
movq -0x498(%rbp), %rdi
leaq 0x13b6ce(%rip), %rsi    # 0x1e997b
callq 0x356d0
movq %rax, -0x4a0(%rbp)
jmp 0xae2bb
movq -0x4a0(%rbp), %rdi
leaq 0x1324e3(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x4a8(%rbp)
jmp 0xae2d7
movq -0x4a8(%rbp), %rdi
leaq -0x104(%rbp), %rsi
callq 0x343a0
movq %rax, -0x4b0(%rbp)
jmp 0xae2f3
movq -0x4b0(%rbp), %rdi
leaq 0x12e4e4(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0x4b8(%rbp)
jmp 0xae30f
movq -0x4b8(%rbp), %rdi
leaq 0x13b669(%rip), %rsi    # 0x1e9986
callq 0x34600
movq %rax, -0x4c0(%rbp)
jmp 0xae32b
movq -0x4c0(%rbp), %rdi
leaq 0x132473(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x4c8(%rbp)
jmp 0xae347
movq -0x4c8(%rbp), %rdi
leaq -0x244(%rbp), %rsi
callq 0x343a0
movq %rax, -0x4d0(%rbp)
jmp 0xae363
movq -0x4d0(%rbp), %rdi
leaq 0x14810a(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0xae378
leaq -0x3f8(%rbp), %rdi
callq 0x10ff0
jmp 0xae386
leaq -0x418(%rbp), %rdi
callq 0x3100
leaq -0x419(%rbp), %rdi
callq 0x3290
leaq -0x100(%rbp), %rdi
callq 0xc7760
leaq -0xc0(%rbp), %rdi
callq 0xc7760
leaq -0x90(%rbp), %rdi
callq 0xc7760
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0xae421
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0xae415
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x10ff0
jmp 0xae413
jmp 0xae415
leaq -0x418(%rbp), %rdi
callq 0x3100
leaq -0x419(%rbp), %rdi
callq 0x3290
leaq -0x100(%rbp), %rdi
callq 0xc7760
leaq -0xc0(%rbp), %rdi
callq 0xc7760
leaq -0x90(%rbp), %rdi
callq 0xc7760
movq -0xc8(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nopw %cs:(%rax,%rax)