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

  int max_ik[5];
  std::fill(std::begin(max_ik), std::end(max_ik), 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 $0x2b8, %rsp            # imm = 0x2B8
leaq 0x120(%rsp), %rbx
pushq $0x4
popq %rsi
pushq $0x5
popq %rdx
pushq $0x8
popq %rcx
movq %rbx, %rdi
callq 0x10b74
leaq 0x98(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x10b92
movq %r14, %rdi
xorl %esi, %esi
callq 0x10bbd
xorl %eax, %eax
cmpq $0x14, %rax
je 0x462ce
movl $0x80000000, 0x70(%rsp,%rax) # imm = 0x80000000
addq $0x4, %rax
jmp 0x462ba
leaq 0x90(%rsp), %rdi
callq 0x49e86
leaq 0x70(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0xb0(%rsp), %rax
movups 0xb8(%rsp), %xmm0
movups %xmm0, 0x148(%rsp)
movq 0xc8(%rsp), %rcx
movq %rcx, 0x158(%rsp)
movups 0xd0(%rsp), %xmm0
movaps %xmm0, 0x160(%rsp)
movq 0xe0(%rsp), %rcx
movq %rcx, 0x170(%rsp)
movups 0xe8(%rsp), %xmm0
movups %xmm0, 0x178(%rsp)
movq 0xf8(%rsp), %rcx
movq %rcx, 0x188(%rsp)
movups 0x88(%rsp), %xmm0
movaps %xmm0, 0x130(%rsp)
movaps %xmm0, 0x120(%rsp)
movq %rax, 0x140(%rsp)
movups 0x178(%rsp), %xmm0
movaps %xmm0, (%rsp)
leaq 0x38(%rsp), %rdi
pushq $0x5
popq %rdx
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x4a046
movq 0x160(%rsp), %rax
testq %rax, %rax
jg 0x4667f
addq 0x168(%rsp), %rax
cmpq $0x4, %rax
jle 0x4667f
movups 0x148(%rsp), %xmm0
leaq 0x20(%rsp), %rcx
movaps %xmm0, (%rcx)
leaq 0x100(%rsp), %rsi
movaps (%rsp), %xmm0
movaps %xmm0, (%rsi)
leaq 0x38(%rsp), %rdi
leaq 0x1d(%rsp), %rdx
callq 0x49ec2
leaq 0x140(%rsp), %rbx
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %rax
addq %r14, %rax
movq %rax, (%rsp)
cmpq (%rsp), %r14
je 0x46456
xorl %r15d, %r15d
cmpq $0x5, %r15
je 0x46451
movq 0x58(%rsp), %r12
movq 0x60(%rsp), %rbp
subq $0x1, %rbp
jb 0x4644c
movq 0x130(%rsp), %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x49cae
movl (%r13,%r15,4), %ecx
movl (%rax), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movq 0x120(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
incq %r12
jmp 0x46410
incq %r15
jmp 0x46400
incq %r14
jmp 0x463f7
leaq 0x98(%rsp), %rax
movq 0x50(%rax), %r14
movq 0x58(%rax), %rax
addq %r14, %rax
movq %rax, (%rsp)
leaq 0x120(%rsp), %r12
leaq 0x38(%rsp), %r13
cmpq (%rsp), %r14
je 0x46641
movl $0x80000000, 0x20(%rsp) # imm = 0x80000000
movq %r12, %rdi
leaq 0x98(%rsp), %rsi
movq %r14, %rdx
callq 0x46f7e
movq 0x120(%rsp), %rbp
movq %r13, %rdi
leaq 0x128(%rsp), %rsi
callq 0x9125
testq %rbp, %rbp
je 0x4655c
movq 0x60(%rsp), %rax
movq 0x40(%rsp), %rcx
movq 0x58(%rsp), %rdx
testq %rdx, %rdx
movl $0x0, %esi
cmovgq %rdx, %rsi
movq 0x48(%rsp), %rdi
testq %rcx, %rcx
movl $0x0, %r8d
cmovleq %r8, %rcx
movl 0x20(%rsp), %r15d
shlq $0x2, %rdi
leaq (,%rax,4), %r8
xorl %r9d, %r9d
cmpq %rcx, %r9
je 0x46575
cmpq $0x1, %rax
jne 0x46534
leaq (,%rdx,4), %r10
addq %rbp, %r10
movq %rbp, %r11
cmpq %r10, %r11
jae 0x46554
movl (%r11), %ebx
addq $0x4, %r11
cmpl %ebx, %r15d
cmovlel %ebx, %r15d
movl %r15d, 0x20(%rsp)
jmp 0x4651a
movq %rsi, %r10
movq %rbp, %r11
subq $0x1, %r10
jb 0x46554
movl (%r11), %ebx
cmpl %ebx, %r15d
cmovlel %ebx, %r15d
movl %r15d, 0x20(%rsp)
addq %r8, %r11
jmp 0x4653a
addq %rdi, %rbp
incq %r9
jmp 0x46501
movq 0x40(%rsp), %rax
imulq 0x58(%rsp), %rax
testq %rax, %rax
jg 0x46660
movl 0x20(%rsp), %r15d
movl 0x70(%rsp,%r14,4), %ebp
movq %r13, %rdi
leaq 0x54340(%rip), %rsi     # 0x9a8c4
leaq 0x100(%rsp), %rdx
callq 0x66a0
xorl %esi, %esi
cmpl %r15d, %ebp
sete %sil
movq %r12, %rdi
movq %r13, %rdx
callq 0x6894
leaq 0x4709b(%rip), %rbx     # 0x8d647
leaq 0x4b03f(%rip), %r15     # 0x915f2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x54314(%rip), %rsi     # 0x9a8dc
callq 0x1079e
movq %rax, %rdi
movq %r15, %rsi
callq 0x106fe
leaq (%rsp,%r14,4), %rsi
addq $0x70, %rsi
movq %rax, %rdi
callq 0x10736
movq %rax, %rdi
movq %rbx, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x54299(%rip), %rsi     # 0x9a896
callq 0x107d8
movq %rax, %rdi
movq %r15, %rsi
callq 0x106fe
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x10736
movq %rax, %rdi
leaq 0x5ec7e(%rip), %rsi     # 0xa52a2
callq 0x106fe
movq %r12, %rdi
callq 0x68d4
movq %r13, %rdi
callq 0x2090
incq %r14
jmp 0x4647a
leaq 0x98(%rsp), %rdi
callq 0x10d02
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x46c28(%rip), %rdi     # 0x8d28f
leaq 0x46a63(%rip), %rsi     # 0x8d0d1
leaq 0x57c0c(%rip), %rcx     # 0x9e281
movl $0x6a1, %edx            # imm = 0x6A1
callq 0x20e0
leaq 0x5481a(%rip), %rdi     # 0x9aea0
leaq 0x54832(%rip), %rsi     # 0x9aebf
leaq 0x561f3(%rip), %rcx     # 0x9c887
movl $0xf2, %edx
callq 0x20e0
jmp 0x466d3
jmp 0x466d3
jmp 0x466d3
jmp 0x466d3
jmp 0x466d3
jmp 0x466d3
movq %rax, %rbx
jmp 0x466bf
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x68d4
leaq 0x38(%rsp), %rdi
callq 0x2090
jmp 0x466d6
movq %rax, %rdi
callq 0x6bba
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x10d02
movq %rbx, %rdi
callq 0x22f0