#include <metal_stdlib>
using namespace metal;
struct tint_module_vars_struct {
  device int* prevent_dce;
};
struct VertexOutput {
  float4 pos;
  int prevent_dce;
};
struct vertex_main_outputs {
  float4 VertexOutput_pos [[position]];
  int VertexOutput_prevent_dce [[user(locn0)]] [[flat]];
};

int insertBits_65468b() {
  int arg_0 = 1;
  int arg_1 = 1;
  uint arg_2 = 1u;
  uint arg_3 = 1u;
  int const v = arg_0;
  int const v_1 = arg_1;
  uint const v_2 = arg_3;
  uint const v_3 = min(arg_2, 32u);
  int res = insert_bits(v, v_1, v_3, min(v_2, (32u - v_3)));
  return res;
}
fragment void fragment_main(device int* prevent_dce [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce};
  (*tint_module_vars.prevent_dce) = insertBits_65468b();
}
kernel void compute_main(device int* prevent_dce [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce};
  (*tint_module_vars.prevent_dce) = insertBits_65468b();
}
VertexOutput vertex_main_inner() {
  VertexOutput out = {};
  out.pos = float4(0.0f);
  out.prevent_dce = insertBits_65468b();
  return out;
}
vertex vertex_main_outputs vertex_main() {
  VertexOutput const v_4 = vertex_main_inner();
  return vertex_main_outputs{.VertexOutput_pos=v_4.pos, .VertexOutput_prevent_dce=v_4.prevent_dce};
}
