#include <metal_stdlib>

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

int2 clamp_6c1749() {
  int2 arg_0 = int2(1);
  int2 arg_1 = int2(1);
  int2 arg_2 = int2(1);
  int2 res = tint_clamp(arg_0, arg_1, arg_2);
  return res;
}

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

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

struct VertexOutput {
  float4 pos;
  int2 prevent_dce;
};

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

VertexOutput vertex_main_inner() {
  VertexOutput out = {};
  out.pos = float4(0.0f);
  out.prevent_dce = clamp_6c1749();
  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;
}

