#include <metal_stdlib>

using namespace metal;
uint3 tint_clamp(uint3 e, uint3 low, uint3 high) {
  return min(max(e, low), high);
}

uint3 clamp_548fc7() {
  uint3 arg_0 = uint3(1u);
  uint3 arg_1 = uint3(1u);
  uint3 arg_2 = uint3(1u);
  uint3 res = tint_clamp(arg_0, arg_1, arg_2);
  return res;
}

fragment void fragment_main(device packed_uint3* tint_symbol_1 [[buffer(0)]]) {
  *(tint_symbol_1) = packed_uint3(clamp_548fc7());
  return;
}

kernel void compute_main(device packed_uint3* tint_symbol_2 [[buffer(0)]]) {
  *(tint_symbol_2) = packed_uint3(clamp_548fc7());
  return;
}

struct VertexOutput {
  float4 pos;
  uint3 prevent_dce;
};

struct tint_symbol {
  uint3 prevent_dce [[user(locn0)]] [[flat]];
  float4 pos [[position]];
};

VertexOutput vertex_main_inner() {
  VertexOutput out = {};
  out.pos = float4(0.0f);
  out.prevent_dce = clamp_548fc7();
  return out;
}

vertex tint_symbol vertex_main() {
  VertexOutput const inner_result = vertex_main_inner();
  tint_symbol wrapper_result = {};
  wrapper_result.pos = inner_result.pos;
  wrapper_result.prevent_dce = inner_result.prevent_dce;
  return wrapper_result;
}

