#include <metal_stdlib>

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


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

float3 quadSwapDiagonal_b905fc(thread tint_private_vars_struct* const tint_private_vars) {
  float3 arg_0 = float3(1.0f);
  float3 res = tint_msl_quadSwapDiagonal(arg_0, tint_private_vars);
  return res;
}

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

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

