#include <metal_stdlib>

using namespace metal;
uint2 textureDimensions_674058(texture2d_array<int, access::write> tint_symbol) {
  uint2 res = uint2(tint_symbol.get_width(), tint_symbol.get_height());
  return res;
}

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

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

