#include <metal_stdlib>

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


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

uint2 quadSwapDiagonal_348173(thread tint_private_vars_struct* const tint_private_vars) {
  uint2 res = tint_msl_quadSwapDiagonal(uint2(1u), tint_private_vars);
  return res;
}

fragment void fragment_main(device uint2* 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_348173(&(tint_private_vars));
  return;
}

kernel void compute_main(device uint2* 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_348173(&(tint_private_vars));
  return;
}

