// File: /workspace/github_cpp_makefile_star2_O2/dsharlet[P]array/test/image.cpp
// Function: void nda::test_slice<nda::shape<nda::dim<-9l, -9l, 1l>, nda::dim<-9l, -9l, -9l>, nda::dim<-9l, -9l, -9l>>>(long)
void test_slice(index_t channels) {
  array<int, Shape> base({100, 80, channels});
  fill_pattern(base);

  for (index_t c = 0; c < channels; c++) {
    auto slice = slice_channel(base, c);
    ASSERT_EQ(static_cast<index_t>(slice.shape().size()), base.width() * base.height());
    for_all_indices(slice.shape(),
        [&](int x, int y) { ASSERT_EQ(slice(x, y), pattern<int>(std::make_tuple(x, y, c))); });

    auto crop_slice = slice_channel(crop(base, 5, 3, 80, 70, crop_origin::crop), c);
    ASSERT_EQ(crop_slice.shape().size(), (80 - 5) * (70 - 3));
    for_all_indices(crop_slice.shape(),
        [&](int x, int y) { ASSERT_EQ(crop_slice(x, y), pattern<int>(std::make_tuple(x, y, c))); });
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, %rcx
leaq 0x128(%rsp), %rbx
pushq $0x64
popq %rsi
pushq $0x50
popq %rdx
movq %rbx, %rdi
movq %rcx, 0x28(%rsp)
callq 0x52408
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6750
movq %r14, %rdi
xorl %esi, %esi
callq 0x51520
leaq 0x128(%rsp), %r12
xorl %edx, %edx
movq %rdx, 0x18(%rsp)
cmpq 0x28(%rsp), %rdx
jge 0x50a9b
leaq 0x68(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x52427
movq 0x78(%rsp), %rbx
movq 0x90(%rsp), %rbp
movq 0x100(%rsp), %r14
movq 0x118(%rsp), %r13
leaq 0x30(%rsp), %r15
movq %r15, %rdi
leaq 0x4e8e4(%rip), %rsi     # 0x9f092
leaq 0x14(%rsp), %rdx
callq 0x66a0
imulq %rbp, %rbx
testq %rbx, %rbx
movl $0x0, %eax
cmovleq %rax, %rbx
imulq %r13, %r14
xorl %esi, %esi
cmpq %r14, %rbx
sete %sil
movq %r12, %rdi
movq %r15, %rdx
callq 0x6894
leaq 0x20(%rsp), %r13
movq %r12, %rdi
leaq 0x3ce58(%rip), %rsi     # 0x8d647
callq 0x106fe
leaq 0xa0(%rsp), %rbx
movq %rax, %rdi
leaq 0x4e8d7(%rip), %rsi     # 0x9f0dd
callq 0x5245a
movq %rax, %rdi
leaq 0x40ddd(%rip), %rsi     # 0x915f2
callq 0x106fe
movq 0x78(%rsp), %rcx
imulq 0x90(%rsp), %rcx
testq %rcx, %rcx
movl $0x0, %edx
cmovleq %rdx, %rcx
movq %rcx, 0xa0(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x107ba
movq %rax, %rdi
leaq 0x3cdf6(%rip), %rsi     # 0x8d647
callq 0x106fe
movq %rax, %rdi
leaq 0x4e860(%rip), %rsi     # 0x9f0c0
callq 0x384ee
movq %rax, %rdi
leaq 0x40d83(%rip), %rsi     # 0x915f2
callq 0x106fe
movq 0x100(%rsp), %rcx
imulq 0x118(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x107ba
movq %rax, %rdi
leaq 0x54a03(%rip), %rsi     # 0xa52a2
callq 0x106fe
movq %r12, %rdi
callq 0x68d4
movq %r15, %rdi
callq 0x2090
leaq 0x68(%rsp), %rax
movq %rax, 0x128(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %r15
addq %rbx, %r15
cmpq %r15, %rbx
je 0x5090d
movl 0x88(%rsp), %r14d
movq 0x90(%rsp), %rbp
subq $0x1, %rbp
jb 0x50908
movq %r12, %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x5254a
incl %r14d
jmp 0x508f0
incq %rbx
jmp 0x508db
movl $0x1, (%rsp)
movq %r12, %rdi
leaq 0xc0(%rsp), %rsi
pushq $0x5
popq %rdx
pushq $0x3
popq %rcx
pushq $0x50
popq %r8
pushq $0x46
popq %r9
callq 0x5154e
movq 0x18(%rsp), %rdx
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x52475
movq 0x40(%rsp), %rbx
movq 0x58(%rsp), %r14
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
leaq 0x4e7a8(%rip), %rsi     # 0x9f108
leaq 0x13(%rsp), %rdx
callq 0x66a0
imulq %r14, %rbx
xorl %esi, %esi
cmpq $0x13a1, %rbx           # imm = 0x13A1
sete %sil
movq %r12, %rdi
movq %r15, %rdx
callq 0x6894
movq %r12, %rdi
leaq 0x3ccb7(%rip), %rsi     # 0x8d647
callq 0x106fe
movq %rax, %rdi
leaq 0x4e79a(%rip), %rsi     # 0x9f139
callq 0x3425c
movq %rax, %rdi
leaq 0x40c44(%rip), %rsi     # 0x915f2
callq 0x106fe
movq 0x40(%rsp), %rcx
imulq 0x58(%rsp), %rcx
testq %rcx, %rcx
movl $0x0, %edx
cmovleq %rdx, %rcx
movq %rcx, 0x20(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x11052
movq %rax, %rdi
leaq 0x3cc63(%rip), %rsi     # 0x8d647
callq 0x106fe
movq %rax, %rdi
leaq 0x4e732(%rip), %rsi     # 0x9f125
callq 0x11036
movq %rax, %rdi
leaq 0x40bf0(%rip), %rsi     # 0x915f2
callq 0x106fe
movl $0x13a1, 0x14(%rsp)     # imm = 0x13A1
movq %rax, %rdi
leaq 0x14(%rsp), %rsi
callq 0x10736
movq %rax, %rdi
leaq 0x5487c(%rip), %rsi     # 0xa52a2
callq 0x106fe
movq %r12, %rdi
callq 0x68d4
movq %r15, %rdi
callq 0x2090
leaq 0x30(%rsp), %rax
movq %rax, 0x128(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x38(%rsp), %rbx
movq 0x40(%rsp), %r15
addq %rbx, %r15
cmpq %r15, %rbx
je 0x50a8e
movl 0x50(%rsp), %r14d
movq 0x58(%rsp), %rbp
subq $0x1, %rbp
jb 0x50a89
movq %r12, %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x527a6
incl %r14d
jmp 0x50a71
incq %rbx
jmp 0x50a62
movq 0x18(%rsp), %rdx
incq %rdx
jmp 0x50760
leaq 0xc0(%rsp), %rdi
callq 0x69c2
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x50b16
jmp 0x50b16
jmp 0x50b16
jmp 0x50b16
jmp 0x50ad6
jmp 0x50b16
movq %rax, %rbx
jmp 0x50ae6
jmp 0x50af0
movq %rax, %rbx
jmp 0x50b00
jmp 0x50ad6
jmp 0x50af0
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x68d4
leaq 0xa0(%rsp), %rdi
jmp 0x50b05
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x68d4
leaq 0x30(%rsp), %rdi
callq 0x2090
jmp 0x50b19
movq %rax, %rdi
callq 0x6bba
jmp 0x50b16
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x69c2
movq %rbx, %rdi
callq 0x22f0