#include <metal_stdlib>

using namespace metal;
uint textureNumLayers_8e1bd0(texture2d_array<int, access::read_write> tint_symbol) {
  uint res = tint_symbol.get_array_size();
  return res;
}

fragment void fragment_main(device uint* tint_symbol_1 [[buffer(0)]], texture2d_array<int, access::read_write> tint_symbol_2 [[texture(0)]]) {
  *(tint_symbol_1) = textureNumLayers_8e1bd0(tint_symbol_2);
  return;
}

kernel void compute_main(device uint* tint_symbol_3 [[buffer(0)]], texture2d_array<int, access::read_write> tint_symbol_4 [[texture(0)]]) {
  *(tint_symbol_3) = textureNumLayers_8e1bd0(tint_symbol_4);
  return;
}

