#include <metal_stdlib>

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


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

uint2 quadSwapY_a27e1c(thread tint_private_vars_struct* const tint_private_vars) {
  uint2 arg_0 = uint2(1u);
  uint2 res = tint_msl_quadSwapY(arg_0, 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) = quadSwapY_a27e1c(&(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) = quadSwapY_a27e1c(&(tint_private_vars));
  return;
}

