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

  dense_array<int, 1> max_ik(dense_shape<1>{T.j().extent()}, std::numeric_limits<int>::min());

  // Reduce T along the i and k dimensions, using max as the reduction.
  auto r = ein<j>(max_ik);
  ein_reduce(r = max(r, ein<i, j, k>(T)));

  for (index_t j : T.i()) {
    int max_ik_ref = std::numeric_limits<int>::min();
    T(_, j, _).for_each_value([&](int i) { max_ik_ref = std::max(i, max_ik_ref); });
    ASSERT_EQ(max_ik(j), max_ik_ref);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movabsq $-0x8000000000000000, %r14 # imm = 0x8000000000000000
leaq 0xc0(%rsp), %r15
xorps %xmm0, %xmm0
movups %xmm0, -0x8(%r15)
movups %xmm0, -0x18(%r15)
movq $0x8, 0x8(%r15)
movq %r14, 0x10(%r15)
xorl %eax, %eax
movq %rax, 0x18(%r15)
movq $0x5, 0x20(%r15)
movq %r14, 0x28(%r15)
movq %rax, 0x30(%r15)
movq $0x4, 0x38(%r15)
movq %r14, 0x40(%r15)
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
callq 0x1a362
movq %rbx, %rdi
callq 0x1a43a
movq 0x18(%rbx), %rax
leaq 0x110(%rsp), %rdx
movq %rax, -0x8(%rdx)
movl $0x9, %ecx
movq %rdx, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x10(%rsp), %rax
movl $0x0, (%rax)
leaq 0x68(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x108(%rsp), %rax
movq %rax, 0x8(%rsi)
movq %rdx, %rdi
callq 0x1d4b4
movq 0xe0(%rsp), %r15
xorl %r12d, %r12d
leaq 0x108(%rsp), %rbx
movq %r12, (%rbx)
movq %r15, 0x8(%rbx)
movq %r14, 0x10(%rbx)
xorl %edi, %edi
movq %rbx, %rsi
callq 0xd09f
leaq 0x10(%rsp), %rsi
movq %r12, (%rsi)
movq %r15, 0x8(%rsi)
movl $0x80000000, (%rbx)     # imm = 0x80000000
leaq 0x68(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x18cb6
movq 0x88(%rsp), %rbx
movq 0xd8(%rsp), %r13
cmpq %rbx, %r13
jg 0x55f1c
movq 0x90(%rsp), %rax
leaq (%rax,%rbx), %rcx
movq 0xe0(%rsp), %rdx
addq %r13, %rdx
cmpq %rdx, %rcx
jg 0x55f1c
movq %r13, 0x50(%rsp)
movq 0x80(%rsp), %r15
movq 0xb8(%rsp), %r12
movq 0xc0(%rsp), %r8
movq 0xd0(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq 0xe8(%rsp), %rbp
movq 0xf0(%rsp), %r9
movq 0x100(%rsp), %r14
movq 0xc8(%rsp), %rcx
movq 0xf8(%rsp), %rdx
movq 0x98(%rsp), %rsi
leaq 0x108(%rsp), %rdi
movq %r8, 0x48(%rsp)
movq %r8, (%rdi)
movq %rcx, 0x8(%rdi)
movq %rbx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movq %rsi, 0x28(%rdi)
movq %r9, %r13
movq %r9, 0x30(%rdi)
movq %rdx, 0x38(%rdi)
callq 0x587e6
movq 0x110(%rsp), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x55c33
movq 0x108(%rsp), %rcx
movq 0x120(%rsp), %r9
movq 0x128(%rsp), %rax
movq 0x138(%rsp), %rdi
movq 0x140(%rsp), %rsi
addq %rcx, 0x40(%rsp)
movq %rax, 0x58(%rsp)
leaq (%rax,%r9), %r8
subq %r13, %rdi
imulq %r14, %rdi
movq %r9, 0x60(%rsp)
subq 0x50(%rsp), %r9
imulq %rbp, %r9
shlq $0x2, %r9
leaq (%r9,%rdi,4), %rdi
movq %rcx, %r9
subq 0x48(%rsp), %r9
movq 0x8(%rsp), %r13
imulq %r13, %r9
leaq (%rdi,%r9,4), %rdi
addq %rdi, %r12
shlq $0x2, %r13
movq %r13, 0x8(%rsp)
shlq $0x2, %rbp
shlq $0x2, %r14
movq %r12, %rax
movq 0x60(%rsp), %r10
cmpq $0x0, 0x58(%rsp)
je 0x55c21
testq %rsi, %rsi
je 0x55c16
movq %r10, %r11
subq %rbx, %r11
movl (%r15,%r11,4), %r13d
movq %r12, %r9
movq %rsi, %rdi
movl (%r9), %edx
cmpl %edx, %r13d
cmovlel %edx, %r13d
movl %r13d, (%r15,%r11,4)
addq %r14, %r9
decq %rdi
jne 0x55c00
incq %r10
addq %rbp, %r12
cmpq %r8, %r10
jne 0x55beb
incq %rcx
movq %rax, %r12
addq 0x8(%rsp), %r12
cmpq 0x40(%rsp), %rcx
jne 0x55bdb
movq 0xf8(%rsp), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x55ed4
leaq 0xf0(%rsp), %rax
movq (%rax), %r13
addq %r13, 0x8(%rsp)
leaq 0x10(%rsp), %r15
leaq 0x108(%rsp), %rbp
leaq 0x4b9e7(%rip), %r14     # 0xa1654
movq %r14, %r12
movq 0xb8(%rsp), %rax
leaq 0xf0(%rsp), %rdx
movq 0x10(%rdx), %rcx
leaq 0x28(%rsp), %rsi
movq %rcx, 0x10(%rsi)
movups (%rdx), %xmm0
movups %xmm0, (%rsi)
leaq 0xc0(%rsp), %rdx
movq 0x10(%rdx), %rcx
movq %rcx, 0x20(%rsp)
movups (%rdx), %xmm0
movaps %xmm0, 0x10(%rsp)
movq %r13, %rcx
subq 0xd8(%rsp), %rcx
imulq 0xe8(%rsp), %rcx
testq %rax, %rax
leaq (%rax,%rcx,4), %r14
cmoveq %rax, %r14
movq %r14, 0x108(%rsp)
movaps 0x30(%rsp), %xmm1
leaq 0x110(%rsp), %rsi
movups %xmm1, 0x20(%rsi)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rsi)
movups %xmm0, (%rsi)
movq %r15, %rdi
callq 0xe3b3
testq %r14, %r14
je 0x55d8c
movq 0x18(%rsp), %rax
testq %rax, %rax
jle 0x55da6
movq 0x38(%rsp), %rcx
movq 0x20(%rsp), %rdx
movq 0x30(%rsp), %rsi
shlq $0x2, %rdx
leaq (,%rcx,4), %rdi
movl $0x80000000, %ebx       # imm = 0x80000000
xorl %r8d, %r8d
cmpq $0x1, %rcx
jne 0x55d62
testq %rsi, %rsi
jle 0x55d7f
leaq (%r14,%rsi,4), %r9
movq %r14, %r10
movl (%r10), %r11d
addq $0x4, %r10
cmpl %r11d, %ebx
cmovlel %r11d, %ebx
cmpq %r9, %r10
jb 0x55d4d
jmp 0x55d7f
movq %rsi, %r9
movq %r14, %r10
testq %rsi, %rsi
jle 0x55d7f
movl (%r10), %r11d
cmpl %r11d, %ebx
cmovlel %r11d, %ebx
addq %rdi, %r10
decq %r9
jne 0x55d6d
addq %rdx, %r14
incq %r8
cmpq %rax, %r8
jne 0x55d3b
jmp 0x55dab
movq 0x18(%rsp), %rax
imulq 0x30(%rsp), %rax
movl $0x80000000, %ebx       # imm = 0x80000000
testq %rax, %rax
jle 0x55dab
jmp 0x55efd
movl $0x80000000, %ebx       # imm = 0x80000000
movq 0x80(%rsp), %rax
movq %r13, %rcx
subq 0x88(%rsp), %rcx
movl (%rax,%rcx,4), %r14d
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r15, %rdi
leaq 0x585b3(%rip), %rsi     # 0xae389
leaq 0x585c3(%rip), %rdx     # 0xae3a0
callq 0xd0b8
xorl %esi, %esi
cmpl %ebx, %r14d
sete %sil
movq %rbp, %rdi
movq %r15, %rdx
callq 0xbf0a
movq %r12, %r14
movq %rbp, %rdi
movq %r12, %rsi
callq 0x18a16
movq %rax, %rdi
leaq 0x58593(%rip), %rsi     # 0xae3a1
callq 0x18a86
movq %rax, %rdi
leaq 0x4f50d(%rip), %rsi     # 0xa532a
callq 0x18a16
movq %rax, %r12
cmpb $0x1, 0x188(%rax)
jne 0x55e50
movq %r13, %rax
subq 0x88(%rsp), %rax
movq 0x80(%rsp), %rcx
movq %r12, %rdi
addq $0x10, %rdi
movl (%rcx,%rax,4), %esi
callq 0x22f0
movq %r12, %rdi
movq %r14, %rsi
callq 0x18a16
movq %rax, %rdi
leaq 0x58531(%rip), %rsi     # 0xae396
callq 0x18abe
movq %rax, %rdi
leaq 0x4f4b6(%rip), %rsi     # 0xa532a
callq 0x18a16
movq %rax, %r12
cmpb $0x1, 0x188(%rax)
jne 0x55e93
movq %r12, %rdi
addq $0x10, %rdi
movl %ebx, %esi
callq 0x22f0
movq %r12, %rdi
leaq 0x624cc(%rip), %rsi     # 0xb8369
callq 0x18a16
movq %rbp, %rdi
callq 0xbf62
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x55ec6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
incq %r13
cmpq 0x8(%rsp), %r13
jne 0x55c6d
leaq 0x68(%rsp), %rdi
callq 0x1cc90
leaq 0xa0(%rsp), %rdi
callq 0x1d3b4
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4b3a7(%rip), %rdi     # 0xa12ab
leaq 0x4b1e2(%rip), %rsi     # 0xa10ed
leaq 0x5b40e(%rip), %rcx     # 0xb1320
movl $0x6a1, %edx            # imm = 0x6A1
callq 0x2100
leaq 0x5898d(%rip), %rdi     # 0xae8b0
leaq 0x589a5(%rip), %rsi     # 0xae8cf
leaq 0x594a0(%rip), %rcx     # 0xaf3d1
movl $0xf2, %edx
callq 0x2100
jmp 0x55fa3
jmp 0x55fa3
jmp 0x55f4a
jmp 0x55f43
movq %rax, %rbx
jmp 0x55f8a
jmp 0x55f4a
movq %rax, %rbx
jmp 0x55f80
movq %rax, %rbx
jmp 0x55f64
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xbf62
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x55f80
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x68(%rsp), %rdi
callq 0x1cc90
leaq 0xa0(%rsp), %rdi
callq 0x1d3b4
movq %rbx, %rdi
callq 0x2300
jmp 0x55fa3
jmp 0x55fa3
movq %rax, %rdi
callq 0xc036