// File: dsharlet[P]array/include/array/array.h
// Function: bool nda::internal::is_stride_ok<nda::dim<-9l, -9l, -9l>>(long, long, nda::dim<-9l, -9l, -9l> const&)
NDARRAY_HOST_DEVICE bool is_stride_ok(index_t stride, index_t extent, const Dim& dim) {
  if (is_unresolved(dim.stride())) {
    // If the dimension has an unknown stride, it's OK, we're
    // resolving the current dim first.
    return true;
  }
  if (extent == 1 && abs(stride) == abs(dim.stride()) && dim.extent() > 1) {
    // If a dimension is extent 1, avoid giving this dimension the same stride
    // as another dimension with extent greater than 1. This doesn't affect the
    // results of most programs (because the stride only ever multiplied with
    // zero), but it makes the strides less objectionable to asserts in some
    // other libraries that make extra assumptions about images, and may be
    // easier to understand.
    return false;
  }
  if (dim.extent() * abs(dim.stride()) <= stride) {
    // The dim is completely inside the proposed stride.
    return true;
  }
  index_t flat_extent = extent * stride;
  if (abs(dim.stride()) >= flat_extent) {
    // The dim is completely outside the proposed stride.
    return true;
  }
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x98(%rbp)
movq %rsi, -0xa0(%rbp)
movq %rdx, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
cmpq %rax, -0x88(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
cmpq $0x0, %rax
je 0x1282d
movb $0x1, -0x89(%rbp)
jmp 0x129fd
cmpq $0x1, -0xa0(%rbp)
jne 0x128f8
movq -0x98(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jl 0x1285a
movq -0x58(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x12867
xorl %eax, %eax
subq -0x58(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jl 0x128ab
movq -0x60(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x128b8
xorl %eax, %eax
subq -0x60(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rax
movq -0xc8(%rbp), %rcx
cmpq %rcx, %rax
jne 0x128f8
movq -0xa8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x1, (%rax)
jle 0x128f8
movb $0x0, -0x89(%rbp)
jmp 0x129fd
movq -0xa8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jl 0x12953
movq -0x68(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0x12960
xorl %eax, %eax
subq -0x68(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rax
movq -0xd8(%rbp), %rcx
imulq %rcx, %rax
cmpq -0x98(%rbp), %rax
jg 0x12984
movb $0x1, -0x89(%rbp)
jmp 0x129fd
movq -0xa0(%rbp), %rax
imulq -0x98(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jl 0x129d0
movq -0x70(%rbp), %rax
movq %rax, -0xe0(%rbp)
jmp 0x129dd
xorl %eax, %eax
subq -0x70(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0xb0(%rbp), %rax
jl 0x129f6
movb $0x1, -0x89(%rbp)
jmp 0x129fd
movb $0x0, -0x89(%rbp)
movb -0x89(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)