def offset_bounds_from_strides(context, builder, arrty, arr, shapes, strides):
 itemsize = arr.itemsize
 zero = itemsize.type(0)
 one = zero.type(1)
 if (arrty.layout in 'CF'):
  lower = zero
  upper = builder.mul(itemsize, arr.nitems)
 else:
  lower = zero
  upper = zero
  for i in range(arrty.ndim):
   max_axis_offset = builder.mul(strides[i], builder.sub(shapes[i], one))
   is_upwards = builder.icmp_signed('>=', max_axis_offset, zero)
   upper = builder.select(is_upwards, builder.add(upper, max_axis_offset), upper)
   lower = builder.select(is_upwards, lower, builder.add(lower, max_axis_offset))
  upper = builder.add(upper, itemsize)
  is_empty = builder.icmp_signed('==', arr.nitems, zero)
  upper = builder.select(is_empty, zero, upper)
  lower = builder.select(is_empty, zero, lower)
 return (lower, upper)

def offset_bounds_from_strides ( context , builder , arrty , arr , shapes , strides ) : itemsize = arr . itemsize zero = itemsize . type ( 0 ) one = zero . type ( 1 ) if ( arrty . layout in 'CF' ) : lower = zero upper = builder . mul ( itemsize , arr . nitems ) else : lower = zero upper = zero for i in range ( arrty . ndim ) : max_axis_offset = builder . mul ( strides [ i ] , builder . sub ( shapes [ i ] , one ) ) is_upwards = builder . icmp_signed ( '>=' , max_axis_offset , zero ) upper = builder . select ( is_upwards , builder . add ( upper , max_axis_offset ) , upper ) lower = builder . select ( is_upwards , lower , builder . add ( lower , max_axis_offset ) ) upper = builder . add ( upper , itemsize ) is_empty = builder . icmp_signed ( '==' , arr . nitems , zero ) upper = builder . select ( is_empty , zero , upper ) lower = builder . select ( is_empty , zero , lower ) return ( lower , upper )
compute a half-open range [lower .