// File: /workspace/github_cpp_makefile_star2_O1/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 $0x2e8, %rsp            # imm = 0x2E8
movq %rdi, %rbp
xorl %ebx, %ebx
leaq 0x158(%rsp), %r14
movq %rbx, (%r14)
movl $0x64, %r15d
movq %r15, 0x8(%r14)
movabsq $-0x8000000000000000, %r12 # imm = 0x8000000000000000
movq %r12, 0x10(%r14)
xorl %edi, %edi
movq %r14, %rsi
callq 0xd09f
leaq 0x110(%rsp), %r13
xorps %xmm0, %xmm0
movups %xmm0, -0x18(%r13)
movups %xmm0, -0x8(%r13)
movq %rbp, 0x8(%r13)
movq %r12, 0x10(%r13)
movq %rbx, 0x18(%r13)
movq $0x50, 0x20(%r13)
movq %r12, 0x28(%r13)
movq %rbx, 0x30(%r13)
movq %r15, 0x38(%r13)
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
callq 0xc2a2
movq %rbx, %rdi
callq 0xc38a
movq 0x18(%rbx), %rax
movq %rax, (%r14)
leaq 0x160(%rsp), %rax
movl $0x9, %ecx
movq %rax, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x80(%rsp), %rcx
movl $0x0, (%rcx)
leaq 0x28(%rsp), %rsi
movq %rcx, (%rsi)
movq %r14, 0x8(%rsi)
movq %rax, %rdi
callq 0x5fc7c
movq $0x0, 0x10(%rsp)
testq %rbp, %rbp
jle 0x5f1a0
leaq 0x158(%rsp), %r12
xorl %r13d, %r13d
movq %rbp, 0x78(%rsp)
movq 0x108(%rsp), %rbp
movq 0x128(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x140(%rsp), %r15
movq 0x148(%rsp), %r14
subq 0x110(%rsp), %r13
imulq 0x120(%rsp), %r13
movq 0x130(%rsp), %rbx
movq %r15, 0x158(%rsp)
movq %r14, 0x160(%rsp)
movq $0x1, 0x168(%rsp)
xorl %edi, %edi
movq %r12, %rsi
callq 0xd09f
testq %rbp, %rbp
leaq (%rbp,%r13,4), %rax
cmoveq %rbp, %rax
movq %rax, 0x80(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %rbx, 0x90(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x98(%rsp)
movq %r15, 0xa0(%rsp)
leaq 0x38(%rsp), %r15
movq %r14, 0xa8(%rsp)
movq 0x130(%rsp), %r13
movq 0x148(%rsp), %rbp
movq %r15, 0x28(%rsp)
leaq 0x28(%rsp), %r15
movq %r15, %rdi
leaq 0x53312(%rip), %rsi     # 0xb2081
leaq 0x53355(%rip), %rdx     # 0xb20cb
callq 0xd0b8
imulq %r14, %rbx
testq %rbx, %rbx
movl $0x0, %eax
cmovleq %rax, %rbx
imulq %rbp, %r13
xorl %esi, %esi
cmpq %r13, %rbx
sete %sil
movq %r12, %rdi
movq %r15, %rdx
callq 0xbf0a
leaq 0x428aa(%rip), %rbx     # 0xa1654
leaq 0x46579(%rip), %r15     # 0xa532a
movq %r12, %rdi
movq %rbx, %rsi
callq 0x18a16
movq %rax, %rdi
leaq 0x53306(%rip), %rsi     # 0xb20cc
callq 0x608a2
movq %rax, %rdi
movq %r15, %rsi
callq 0x18a16
movq %rax, %r14
cmpb $0x1, 0x188(%rax)
jne 0x5ee0b
movq 0xa8(%rsp), %rsi
imulq 0x90(%rsp), %rsi
testq %rsi, %rsi
movl $0x0, %eax
cmovleq %rax, %rsi
movq %r14, %rdi
addq $0x10, %rdi
callq 0x21b0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x18a16
movq %rax, %rdi
leaq 0x5328f(%rip), %rsi     # 0xb20af
callq 0x458ca
movq %rax, %rdi
movq %r15, %rsi
callq 0x18a16
movq %rax, %rbx
cmpb $0x1, 0x188(%rax)
jne 0x5ee59
movq 0x130(%rsp), %rsi
imulq 0x148(%rsp), %rsi
movq %rbx, %rdi
addq $0x10, %rdi
callq 0x21b0
movq %rbx, %rdi
leaq 0x59506(%rip), %rsi     # 0xb8369
callq 0x18a16
movq %r12, %rdi
callq 0xbf62
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x5ee8c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x80(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x90(%rsp), %r13
testq %r13, %r13
je 0x5eef2
movq 0x88(%rsp), %r14
addq %r14, %r13
movq 0xa8(%rsp), %rbp
testq %rbp, %rbp
je 0x5eeea
movq 0xa0(%rsp), %rbx
movq %r12, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x608da
incl %ebx
decq %rbp
jne 0x5eed6
incq %r14
cmpq %r13, %r14
jne 0x5eec1
movq 0x108(%rsp), %rax
movq %rax, 0x158(%rsp)
movl $0x9, %ecx
leaq 0x160(%rsp), %rdi
leaq 0x110(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x1, (%rsp)
movl $0x5, %edx
movl $0x3, %ecx
movl $0x50, %r8d
movl $0x46, %r9d
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x5faf9
movq 0x10(%rsp), %r15
movq 0x60(%rsp), %r13
movq 0x68(%rsp), %rbx
movq 0x28(%rsp), %rbp
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %r14
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r13, 0x158(%rsp)
movq %rbx, 0x160(%rsp)
movq $0x1, 0x168(%rsp)
xorl %edi, %edi
movq %r12, %rsi
callq 0xd09f
movq %r13, %rax
subq 0x60(%rsp), %rax
movq 0x18(%rsp), %rdx
movq %rdx, %rcx
subq 0x48(%rsp), %rcx
imulq 0x58(%rsp), %rcx
subq 0x30(%rsp), %r15
imulq 0x40(%rsp), %r15
testq %rbp, %rbp
leaq (%rbp,%rax,4), %rax
leaq (%rax,%rcx,4), %rax
leaq (%rax,%r15,4), %rax
cmoveq %rbp, %rax
movq %rax, 0xb8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %r14, 0xc8(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq %r13, 0xd8(%rsp)
movq %rbx, 0xe0(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, 0x28(%rsp)
leaq 0x28(%rsp), %r13
movq %r13, %rdi
leaq 0x530d8(%rip), %rsi     # 0xb20f7
leaq 0x53101(%rip), %rdx     # 0xb2127
callq 0xd0b8
imulq %rbx, %r14
xorl %esi, %esi
cmpq $0x13a1, %r14           # imm = 0x13A1
sete %sil
movq %r12, %rdi
movq %r13, %rdx
callq 0xbf0a
leaq 0x42606(%rip), %rbx     # 0xa1654
leaq 0x462d5(%rip), %r13     # 0xa532a
movq %r12, %rdi
movq %rbx, %rsi
callq 0x18a16
movq %rax, %rdi
leaq 0x530be(%rip), %rsi     # 0xb2128
callq 0x41786
movq %rax, %rdi
movq %r13, %rsi
callq 0x18a16
movq %rax, %r14
cmpb $0x1, 0x188(%rax)
jne 0x5f0af
movq 0xe0(%rsp), %rsi
imulq 0xc8(%rsp), %rsi
testq %rsi, %rsi
movl $0x0, %eax
cmovleq %rax, %rsi
movq %r14, %rdi
addq $0x10, %rdi
callq 0x2110
movq %r14, %rdi
movq %rbx, %rsi
callq 0x18a16
movq %rax, %rdi
leaq 0x53050(%rip), %rsi     # 0xb2114
callq 0x19340
movq %rax, %rdi
movq %r13, %rsi
callq 0x18a16
movq %rax, %rbx
cmpb $0x1, 0x188(%rax)
jne 0x5f0f1
movq %rbx, %rdi
addq $0x10, %rdi
movl $0x13a1, %esi           # imm = 0x13A1
callq 0x22f0
movq %rbx, %rdi
leaq 0x5926e(%rip), %rsi     # 0xb8369
callq 0x18a16
movq %r12, %rdi
callq 0xbf62
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x5f11f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0xb8(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0xc8(%rsp), %r13
testq %r13, %r13
je 0x5f185
movq 0xc0(%rsp), %r14
addq %r14, %r13
movq 0xe0(%rsp), %rbp
testq %rbp, %rbp
je 0x5f17d
movq 0xd8(%rsp), %rbx
movq %r12, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x60aba
incl %ebx
decq %rbp
jne 0x5f169
incq %r14
cmpq %r13, %r14
jne 0x5f154
movq 0x10(%rsp), %r13
incq %r13
movq %r13, 0x10(%rsp)
movq 0x78(%rsp), %rbp
cmpq %rbp, %r13
jl 0x5ec8f
leaq 0xf0(%rsp), %rdi
callq 0xd16c
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5f244
jmp 0x5f22c
jmp 0x5f22c
jmp 0x5f22c
jmp 0x5f22c
jmp 0x5f1de
jmp 0x5f1fa
movq %rax, %rbx
jmp 0x5f1ee
movq %rax, %rbx
jmp 0x5f20a
jmp 0x5f1de
jmp 0x5f1fa
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0xbf62
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
jne 0x5f219
jmp 0x5f22f
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0xbf62
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x5f22f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x5f22f
jmp 0x5f244
jmp 0x5f22c
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0xd16c
movq %rbx, %rdi
callq 0x2300
movq %rax, %rdi
callq 0xc036