#include <metal_stdlib>

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


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

int3 quadSwapDiagonal_a82e1d(thread tint_private_vars_struct* const tint_private_vars) {
  int3 res = tint_msl_quadSwapDiagonal(int3(1), tint_private_vars);
  return res;
}

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

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

