#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  device uint* prevent_dce;
  texture1d<float, access::read_write> arg_0;
};

uint textureDimensions_a7ae4c(tint_module_vars_struct tint_module_vars) {
  uint res = uint(tint_module_vars.arg_0.get_width());
  return res;
}

fragment void fragment_main(device uint* prevent_dce [[buffer(0)]], texture1d<float, access::read_write> arg_0 [[texture(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce, .arg_0=arg_0};
  (*tint_module_vars.prevent_dce) = textureDimensions_a7ae4c(tint_module_vars);
}

kernel void compute_main(device uint* prevent_dce [[buffer(0)]], texture1d<float, access::read_write> arg_0 [[texture(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce, .arg_0=arg_0};
  (*tint_module_vars.prevent_dce) = textureDimensions_a7ae4c(tint_module_vars);
}
