#include <metal_stdlib>

using namespace metal;
struct tint_private_vars_struct {
  uint tint_msl_thread_index_in_quadgroup;
};


half4 tint_msl_quadSwapDiagonal(half4 e, thread tint_private_vars_struct* const tint_private_vars) {
  return quad_shuffle(e,((*(tint_private_vars)).tint_msl_thread_index_in_quadgroup ^ 3u));
}

half4 quadSwapDiagonal_af19a5(thread tint_private_vars_struct* const tint_private_vars) {
  half4 arg_0 = half4(1.0h);
  half4 res = tint_msl_quadSwapDiagonal(arg_0, tint_private_vars);
  return res;
}

fragment void fragment_main(device half4* tint_symbol [[buffer(0)]], uint tint_thread_index_in_quadgroup [[thread_index_in_quadgroup]]) {
  thread tint_private_vars_struct tint_private_vars = {};
  {
    tint_private_vars.tint_msl_thread_index_in_quadgroup = tint_thread_index_in_quadgroup;
  }
  *(tint_symbol) = quadSwapDiagonal_af19a5(&(tint_private_vars));
  return;
}

kernel void compute_main(device half4* tint_symbol_1 [[buffer(0)]], uint tint_thread_index_in_quadgroup_1 [[thread_index_in_quadgroup]]) {
  thread tint_private_vars_struct tint_private_vars = {};
  {
    tint_private_vars.tint_msl_thread_index_in_quadgroup = tint_thread_index_in_quadgroup_1;
  }
  *(tint_symbol_1) = quadSwapDiagonal_af19a5(&(tint_private_vars));
  return;
}

