// File: /workspace/github_cpp_makefile_star2_O3/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 $0x2a8, %rsp            # imm = 0x2A8
movabsq $-0x8000000000000000, %r14 # imm = 0x8000000000000000
leaq 0xb8(%rsp), %r15
pxor %xmm0, %xmm0
movdqu %xmm0, -0x8(%r15)
movdqu %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 0x98(%rsp), %rbx
movq %rbx, %rdi
callq 0x1a8cc
movq %rbx, %rdi
callq 0x1a9a6
movq 0x18(%rbx), %rax
leaq 0x118(%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 0x48(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rsi)
movq %rdx, %rdi
callq 0x1d948
movq 0xd8(%rsp), %r15
xorl %r12d, %r12d
leaq 0x110(%rsp), %rbx
movq %r12, (%rbx)
movq %r15, 0x8(%rbx)
movq %r14, 0x10(%rbx)
xorl %edi, %edi
movq %rbx, %rsi
callq 0xd133
leaq 0x10(%rsp), %rsi
movq %r12, (%rsi)
movq %r15, 0x8(%rsi)
movl $0x80000000, (%rbx)     # imm = 0x80000000
leaq 0x48(%rsp), %rdi
leaq 0x110(%rsp), %rdx
callq 0x1925a
movq 0x68(%rsp), %rbx
movq 0xd0(%rsp), %r13
cmpq %rbx, %r13
jg 0x56fee
movdqu 0x70(%rsp), %xmm0
movq %xmm0, %rax
addq %rbx, %rax
movq 0xd8(%rsp), %rcx
addq %r13, %rcx
cmpq %rcx, %rax
jg 0x56fee
leaq 0x60(%rsp), %rax
movq (%rax), %r15
movq 0xb0(%rsp), %r12
movups 0xb8(%rsp), %xmm1
movq 0xc8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xe0(%rsp), %rbp
movups 0xe8(%rsp), %xmm2
movq 0xf8(%rsp), %r14
leaq 0x110(%rsp), %rdi
movaps %xmm1, 0x80(%rsp)
movaps %xmm1, (%rdi)
movq %rbx, 0x18(%rdi)
movdqa %xmm0, 0x20(%rdi)
movaps %xmm2, 0x100(%rsp)
movaps %xmm2, 0x30(%rdi)
callq 0x59c7e
movq 0x118(%rsp), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x56ce8
movq 0x110(%rsp), %rcx
movq 0x128(%rsp), %rax
movq 0x130(%rsp), %rdx
movq 0x140(%rsp), %rdi
movq 0x148(%rsp), %rsi
addq %rcx, 0x40(%rsp)
movq %rdx, 0x90(%rsp)
leaq (%rdx,%rax), %r8
movdqa 0x80(%rsp), %xmm0
movq %xmm0, %r9
movdqa 0x100(%rsp), %xmm0
movq %xmm0, %r10
subq %r10, %rdi
imulq %r14, %rdi
movq %rax, 0x80(%rsp)
movq %rax, %r10
subq %r13, %r10
imulq %rbp, %r10
shlq $0x2, %r10
leaq (%r10,%rdi,4), %rdi
movq %rcx, %r10
subq %r9, %r10
movq 0x8(%rsp), %r13
imulq %r13, %r10
leaq (%rdi,%r10,4), %rdi
addq %rdi, %r12
shlq $0x2, %r13
movq %r13, 0x8(%rsp)
shlq $0x2, %rbp
shlq $0x2, %r14
movq %r12, %rax
movq 0x80(%rsp), %r10
cmpq $0x0, 0x90(%rsp)
je 0x56cd6
testq %rsi, %rsi
je 0x56ccb
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 0x56cb5
incq %r10
addq %rbp, %r12
cmpq %r8, %r10
jne 0x56ca0
incq %rcx
movq %rax, %r12
addq 0x8(%rsp), %r12
cmpq 0x40(%rsp), %rcx
jne 0x56c8a
movq 0xf0(%rsp), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x56f80
leaq 0xe8(%rsp), %rax
movq (%rax), %r13
addq %r13, 0x8(%rsp)
leaq 0x10(%rsp), %r15
leaq 0x110(%rsp), %rbp
leaq 0x4c962(%rip), %r14     # 0xa3684
movq %r14, %r12
movq 0xb0(%rsp), %rbx
leaq 0xe8(%rsp), %rcx
movq 0x10(%rcx), %rax
leaq 0x28(%rsp), %rdx
movq %rax, 0x10(%rdx)
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
leaq 0xb8(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x20(%rsp)
movdqu (%rcx), %xmm0
movdqa %xmm0, 0x10(%rsp)
movq %r13, %rax
subq 0xd0(%rsp), %rax
imulq 0xe0(%rsp), %rax
testq %rbx, %rbx
leaq (%rbx,%rax,4), %r14
cmovneq %r14, %rbx
movq %rbx, 0x110(%rsp)
movaps 0x30(%rsp), %xmm1
leaq 0x118(%rsp), %rsi
movups %xmm1, 0x20(%rsi)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rsi)
movdqu %xmm0, (%rsi)
movq %r15, %rdi
callq 0xe6c1
testq %rbx, %rbx
je 0x56e44
movq 0x18(%rsp), %rax
testq %rax, %rax
jle 0x56e5e
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 0x56e1a
testq %rsi, %rsi
jle 0x56e37
leaq (%r14,%rsi,4), %r9
movq %r14, %r10
movl (%r10), %r11d
addq $0x4, %r10
cmpl %r11d, %ebx
cmovlel %r11d, %ebx
cmpq %r9, %r10
jb 0x56e05
jmp 0x56e37
movq %rsi, %r9
movq %r14, %r10
testq %rsi, %rsi
jle 0x56e37
movl (%r10), %r11d
cmpl %r11d, %ebx
cmovlel %r11d, %ebx
addq %rdi, %r10
decq %r9
jne 0x56e25
addq %rdx, %r14
incq %r8
cmpq %rax, %r8
jne 0x56df3
jmp 0x56e63
movq 0x18(%rsp), %rax
imulq 0x30(%rsp), %rax
movl $0x80000000, %ebx       # imm = 0x80000000
testq %rax, %rax
jle 0x56e63
jmp 0x56fcf
movl $0x80000000, %ebx       # imm = 0x80000000
movq 0x60(%rsp), %rax
movq %r13, %rcx
subq 0x68(%rsp), %rcx
movl (%rax,%rcx,4), %r14d
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r15, %rdi
leaq 0x59431(%rip), %rsi     # 0xb02b9
leaq 0x59441(%rip), %rdx     # 0xb02d0
callq 0xd14c
xorl %esi, %esi
cmpl %ebx, %r14d
sete %sil
movq %rbp, %rdi
movq %r15, %rdx
callq 0xbf80
movq %r12, %r14
movq %rbp, %rdi
movq %r12, %rsi
callq 0x18fba
movq %rax, %rdi
leaq 0x59411(%rip), %rsi     # 0xb02d1
callq 0x1902a
movq %rax, %rdi
leaq 0x50387(%rip), %rsi     # 0xa7256
callq 0x18fba
movq %rax, %r12
cmpb $0x1, 0x188(%rax)
jne 0x56efc
movq %r13, %rax
subq 0x68(%rsp), %rax
movq 0x60(%rsp), %rcx
movq %r12, %rdi
addq $0x10, %rdi
movl (%rcx,%rax,4), %esi
callq 0x22f0
movq %r12, %rdi
movq %r14, %rsi
callq 0x18fba
movq %rax, %rdi
leaq 0x593b5(%rip), %rsi     # 0xb02c6
callq 0x19062
movq %rax, %rdi
leaq 0x50336(%rip), %rsi     # 0xa7256
callq 0x18fba
movq %rax, %r12
cmpb $0x1, 0x188(%rax)
jne 0x56f3f
movq %r12, %rdi
addq $0x10, %rdi
movl %ebx, %esi
callq 0x22f0
movq %r12, %rdi
leaq 0x63350(%rip), %rsi     # 0xba299
callq 0x18fba
movq %rbp, %rdi
callq 0xbfd8
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x56f72
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
incq %r13
cmpq 0x8(%rsp), %r13
jne 0x56d22
cmpq $0x0, 0x60(%rsp)
je 0x56fb0
pxor %xmm0, %xmm0
leaq 0x60(%rsp), %rax
movdqu %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
shlq $0x2, %rsi
callq 0x21f0
leaq 0x98(%rsp), %rdi
callq 0x1d848
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4c305(%rip), %rdi     # 0xa32db
leaq 0x4c140(%rip), %rsi     # 0xa311d
leaq 0x5c26c(%rip), %rcx     # 0xb3250
movl $0x6a1, %edx            # imm = 0x6A1
callq 0x2100
leaq 0x597eb(%rip), %rdi     # 0xb07e0
leaq 0x59803(%rip), %rsi     # 0xb07ff
leaq 0x5a2fe(%rip), %rcx     # 0xb1301
movl $0xf2, %edx
callq 0x2100
jmp 0x5709a
jmp 0x5701d
jmp 0x57016
movq %rax, %rbx
jmp 0x57083
jmp 0x5701d
movq %rax, %rbx
jmp 0x57053
movq %rax, %rbx
jmp 0x57037
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0xbfd8
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x57053
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpq $0x0, 0x60(%rsp)
je 0x57083
pxor %xmm0, %xmm0
leaq 0x60(%rsp), %rax
movdqu %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
shlq $0x2, %rsi
callq 0x21f0
leaq 0x98(%rsp), %rdi
callq 0x1d848
movq %rbx, %rdi
callq 0x2300
jmp 0x5709a
movq %rax, %rdi
callq 0xc0a9