#include <metal_stdlib>
using namespace metal;
struct tint_module_vars_struct {
  texture2d_array<int, access::write> arg_0;
  device uint2* prevent_dce;
};
struct vertex_main_outputs {
  float4 tint_symbol [[position]];
};

void textureDimensions_c44fc1(tint_module_vars_struct tint_module_vars) {
  uint const v = tint_module_vars.arg_0.get_width(0u);
  uint2 res = uint2(v, tint_module_vars.arg_0.get_height(0u));
  (*tint_module_vars.prevent_dce) = res;
}
float4 vertex_main_inner(tint_module_vars_struct tint_module_vars) {
  textureDimensions_c44fc1(tint_module_vars);
  return float4(0.0f);
}
fragment void fragment_main(texture2d_array<int, access::write> arg_0 [[texture(0)]], device uint2* prevent_dce [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.arg_0=arg_0, .prevent_dce=prevent_dce};
  textureDimensions_c44fc1(tint_module_vars);
}
kernel void compute_main(texture2d_array<int, access::write> arg_0 [[texture(0)]], device uint2* prevent_dce [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.arg_0=arg_0, .prevent_dce=prevent_dce};
  textureDimensions_c44fc1(tint_module_vars);
}
vertex vertex_main_outputs vertex_main(texture2d_array<int, access::write> arg_0 [[texture(0)]], device uint2* prevent_dce [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.arg_0=arg_0, .prevent_dce=prevent_dce};
  return vertex_main_outputs{.tint_symbol=vertex_main_inner(tint_module_vars)};
}
