#include <metal_stdlib>
using namespace metal;

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

uint3 textureDimensions_4df14c(tint_module_vars_struct tint_module_vars) {
  uint3 res = uint3(tint_module_vars.arg_0.get_width(0u), tint_module_vars.arg_0.get_height(0u), tint_module_vars.arg_0.get_depth(0u));
  return res;
}

fragment void fragment_main(device packed_uint3* prevent_dce [[buffer(0)]], texture3d<uint, 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) = packed_uint3(textureDimensions_4df14c(tint_module_vars));
}

kernel void compute_main(device packed_uint3* prevent_dce [[buffer(0)]], texture3d<uint, 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) = packed_uint3(textureDimensions_4df14c(tint_module_vars));
}
