#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  device int4* prevent_dce;
};

struct VertexOutput {
  float4 pos;
  int4 prevent_dce;
};

struct vertex_main_outputs {
  float4 VertexOutput_pos [[position]];
  int4 VertexOutput_prevent_dce [[user(locn0)]] [[flat]];
};

int4 firstLeadingBit_c1f940() {
  int4 arg_0 = int4(1);
  uint4 const v = as_type<uint4>(arg_0);
  int4 res = as_type<int4>(select((select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u))) | (select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u))) | (select(uint4(4u), uint4(0u), ((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) & uint4(240u)) == uint4(0u))) | (select(uint4(2u), uint4(0u), (((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) >> select(uint4(4u), uint4(0u), ((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) & uint4(240u)) == uint4(0u)))) & uint4(12u)) == uint4(0u))) | select(uint4(1u), uint4(0u), ((((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) >> select(uint4(4u), uint4(0u), ((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) & uint4(240u)) == uint4(0u)))) >> select(uint4(2u), uint4(0u), (((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) >> select(uint4(4u), uint4(0u), ((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) & uint4(240u)) == uint4(0u)))) & uint4(12u)) == uint4(0u)))) & uint4(2u)) == uint4(0u))))))), uint4(4294967295u), (((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) >> select(uint4(4u), uint4(0u), ((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) & uint4(240u)) == uint4(0u)))) >> select(uint4(2u), uint4(0u), (((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) >> select(uint4(4u), uint4(0u), ((((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) >> select(uint4(8u), uint4(0u), (((select(~(v), v, (v < uint4(2147483648u))) >> select(uint4(16u), uint4(0u), ((select(~(v), v, (v < uint4(2147483648u))) & uint4(4294901760u)) == uint4(0u)))) & uint4(65280u)) == uint4(0u)))) & uint4(240u)) == uint4(0u)))) & uint4(12u)) == uint4(0u)))) == uint4(0u))));
  return res;
}

fragment void fragment_main(device int4* 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) = firstLeadingBit_c1f940();
}

kernel void compute_main(device int4* 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) = firstLeadingBit_c1f940();
}

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

vertex vertex_main_outputs vertex_main() {
  VertexOutput const v_1 = vertex_main_inner();
  vertex_main_outputs tint_wrapper_result = {};
  tint_wrapper_result.VertexOutput_pos = v_1.pos;
  tint_wrapper_result.VertexOutput_prevent_dce = v_1.prevent_dce;
  return tint_wrapper_result;
}
