// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
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 0xd133
leaq 0x110(%rsp), %rbp
pxor %xmm0, %xmm0
movdqu %xmm0, -0x18(%rbp)
movdqu %xmm0, -0x8(%rbp)
movq %r13, 0x8(%rbp)
movq %r12, 0x10(%rbp)
movq %rbx, 0x18(%rbp)
movq $0x50, 0x20(%rbp)
movq %r12, 0x28(%rbp)
movq %rbx, 0x30(%rbp)
movq %r15, 0x38(%rbp)
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
callq 0xc30a
movq %rbx, %rdi
callq 0xc412
movq 0x18(%rbx), %rax
movq %rax, (%r14)
leaq 0x160(%rsp), %rax
movl $0x9, %ecx
movq %rax, %rdi
movq %rbp, %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 0x611a0
movq $0x0, 0x8(%rsp)
testq %r13, %r13
jle 0x60724
leaq 0x38(%rsp), %r15
leaq 0x158(%rsp), %r12
xorl %eax, %eax
movq %r13, 0x78(%rsp)
movq 0x108(%rsp), %rcx
movq 0x128(%rsp), %r14
movq 0x140(%rsp), %r13
movq 0x148(%rsp), %rbx
subq 0x110(%rsp), %rax
imulq 0x120(%rsp), %rax
movq %r13, 0x158(%rsp)
movq %rbx, 0x160(%rsp)
movq $0x1, 0x168(%rsp)
testq %rcx, %rcx
leaq (%rcx,%rax,4), %rbp
cmoveq %rcx, %rbp
movups 0x130(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %edi, %edi
movq %r12, %rsi
callq 0xd133
movq %rbp, 0x80(%rsp)
movq %r14, 0x88(%rsp)
movdqa 0x10(%rsp), %xmm0
movdqu %xmm0, 0x90(%rsp)
movq %r13, 0xa0(%rsp)
movq %rbx, 0xa8(%rsp)
movq 0x130(%rsp), %r14
movq 0x148(%rsp), %r13
movq %r15, 0x28(%rsp)
leaq 0x28(%rsp), %rbp
movq %rbp, %rdi
leaq 0x53cb9(%rip), %rsi     # 0xb3fb1
leaq 0x53cfc(%rip), %rdx     # 0xb3ffb
callq 0xd14c
movdqa 0x10(%rsp), %xmm0
movq %xmm0, %rax
imulq %rbx, %rax
testq %rax, %rax
movl $0x0, %ecx
cmovleq %rcx, %rax
imulq %r13, %r14
xorl %esi, %esi
cmpq %r14, %rax
sete %sil
movq %r12, %rdi
movq %rbp, %rdx
callq 0xbf80
leaq 0x43346(%rip), %rbx     # 0xa3684
leaq 0x46f11(%rip), %r13     # 0xa7256
movq %r12, %rdi
movq %rbx, %rsi
callq 0x18fba
movq %rax, %rdi
leaq 0x53ca2(%rip), %rsi     # 0xb3ffc
callq 0x61dec
movq %rax, %rdi
movq %r13, %rsi
callq 0x18fba
movq %rax, %r14
cmpb $0x1, 0x188(%rax)
jne 0x6039f
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 0x18fba
movq %rax, %rdi
leaq 0x53c2b(%rip), %rsi     # 0xb3fdf
callq 0x46308
movq %rax, %rdi
movq %r13, %rsi
callq 0x18fba
movq %rax, %rbx
cmpb $0x1, 0x188(%rax)
jne 0x603ed
movq 0x130(%rsp), %rsi
imulq 0x148(%rsp), %rsi
movq %rbx, %rdi
addq $0x10, %rdi
callq 0x21b0
movq %rbx, %rdi
leaq 0x59ea2(%rip), %rsi     # 0xba299
callq 0x18fba
movq %r12, %rdi
callq 0xbfd8
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x6041b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x80(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x8(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x90(%rsp), %r13
testq %r13, %r13
je 0x60481
movq 0x88(%rsp), %r14
addq %r14, %r13
movq 0xa8(%rsp), %rbp
testq %rbp, %rbp
je 0x60479
movq 0xa0(%rsp), %rbx
movq %r12, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x61e24
incl %ebx
decq %rbp
jne 0x60465
incq %r14
cmpq %r13, %r14
jne 0x60450
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 0x6103d
movq 0x8(%rsp), %r13
movq 0x60(%rsp), %r14
movq 0x68(%rsp), %rbx
movq 0x28(%rsp), %rbp
movq 0x48(%rsp), %r15
movq %r14, 0x158(%rsp)
movq %rbx, 0x160(%rsp)
movq $0x1, 0x168(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %edi, %edi
movq %r12, %rsi
callq 0xd133
movq %r14, %rax
subq 0x60(%rsp), %rax
movq %r15, %rcx
subq 0x48(%rsp), %rcx
imulq 0x58(%rsp), %rcx
subq 0x30(%rsp), %r13
imulq 0x40(%rsp), %r13
testq %rbp, %rbp
leaq (%rbp,%rax,4), %rax
leaq (%rax,%rcx,4), %rax
leaq (%rax,%r13,4), %rax
cmoveq %rbp, %rax
movq %rax, 0xb8(%rsp)
movq %r15, 0xc0(%rsp)
movdqa 0x10(%rsp), %xmm0
movdqu %xmm0, 0xc8(%rsp)
movq %r14, 0xd8(%rsp)
movq %rbx, 0xe0(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, 0x28(%rsp)
leaq 0x28(%rsp), %r14
movq %r14, %rdi
leaq 0x53a8e(%rip), %rsi     # 0xb4027
leaq 0x53ab7(%rip), %rdx     # 0xb4057
callq 0xd14c
movdqa 0x10(%rsp), %xmm0
movq %xmm0, %rax
imulq %rbx, %rax
xorl %esi, %esi
cmpq $0x13a1, %rax           # imm = 0x13A1
sete %sil
movq %r12, %rdi
movq %r14, %rdx
callq 0xbf80
leaq 0x430b2(%rip), %rbx     # 0xa3684
leaq 0x46c7d(%rip), %r13     # 0xa7256
movq %r12, %rdi
movq %rbx, %rsi
callq 0x18fba
movq %rax, %rdi
leaq 0x53a6a(%rip), %rsi     # 0xb4058
callq 0x421f8
movq %rax, %rdi
movq %r13, %rsi
callq 0x18fba
movq %rax, %r14
cmpb $0x1, 0x188(%rax)
jne 0x60633
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 0x18fba
movq %rax, %rdi
leaq 0x539fc(%rip), %rsi     # 0xb4044
callq 0x1990c
movq %rax, %rdi
movq %r13, %rsi
callq 0x18fba
movq %rax, %rbx
cmpb $0x1, 0x188(%rax)
jne 0x60675
movq %rbx, %rdi
addq $0x10, %rdi
movl $0x13a1, %esi           # imm = 0x13A1
callq 0x22f0
movq %rbx, %rdi
leaq 0x59c1a(%rip), %rsi     # 0xba299
callq 0x18fba
movq %r12, %rdi
callq 0xbfd8
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x606a3
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0xb8(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x8(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0xc8(%rsp), %r13
testq %r13, %r13
je 0x60709
movq 0xc0(%rsp), %r14
addq %r14, %r13
movq 0xe0(%rsp), %rbp
testq %rbp, %rbp
je 0x60701
movq 0xd8(%rsp), %rbx
movq %r12, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x62004
incl %ebx
decq %rbp
jne 0x606ed
incq %r14
cmpq %r13, %r14
jne 0x606d8
movq 0x8(%rsp), %rax
incq %rax
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %r13
cmpq %r13, %rax
jl 0x60236
leaq 0xf0(%rsp), %rdi
callq 0xd206
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x607b3
jmp 0x6079b
jmp 0x6079b
jmp 0x6079b
jmp 0x6079b
jmp 0x6075c
jmp 0x6076e
jmp 0x60753
movq %rax, %rbx
jmp 0x6077e
jmp 0x6075c
jmp 0x6076e
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0xbfd8
jmp 0x6077e
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0xbfd8
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x6079e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x6079e
jmp 0x607b3
jmp 0x6079b
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0xd206
movq %rbx, %rdi
callq 0x2300
movq %rax, %rdi
callq 0xc0a9