#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  device int4* prevent_dce;
  texture2d<int, access::read_write> arg_0;
};

int4 textureLoad_bbb762(tint_module_vars_struct tint_module_vars) {
  uint2 arg_1 = uint2(1u);
  int4 res = tint_module_vars.arg_0.read(arg_1);
  return res;
}

fragment void fragment_main(device int4* prevent_dce [[buffer(0)]], texture2d<int, 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) = textureLoad_bbb762(tint_module_vars);
}

kernel void compute_main(device int4* prevent_dce [[buffer(0)]], texture2d<int, 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) = textureLoad_bbb762(tint_module_vars);
}
