#include <metal_stdlib>
using namespace metal;

struct atomic_compare_exchange_result_u32 {
  uint old_value;
  bool exchanged;
};

struct tint_module_vars_struct {
  threadgroup atomic_uint* arg_0;
};

struct tint_symbol_1 {
  atomic_uint tint_symbol;
};

atomic_compare_exchange_result_u32 v(threadgroup atomic_uint* const atomic_ptr, uint cmp, uint val) {
  uint old_value = cmp;
  bool const v_1 = atomic_compare_exchange_weak_explicit(atomic_ptr, (&old_value), val, memory_order_relaxed, memory_order_relaxed);
  return atomic_compare_exchange_result_u32{.old_value=old_value, .exchanged=v_1};
}

void atomicCompareExchangeWeak_83580d(tint_module_vars_struct tint_module_vars) {
  uint arg_1 = 1u;
  uint arg_2 = 1u;
  atomic_compare_exchange_result_u32 res = v(tint_module_vars.arg_0, arg_1, arg_2);
}

void compute_main_inner(uint tint_local_index, tint_module_vars_struct tint_module_vars) {
  if ((tint_local_index == 0u)) {
    atomic_store_explicit(tint_module_vars.arg_0, 0u, memory_order_relaxed);
  }
  threadgroup_barrier(mem_flags::mem_threadgroup);
  atomicCompareExchangeWeak_83580d(tint_module_vars);
}

kernel void compute_main(uint tint_local_index [[thread_index_in_threadgroup]], threadgroup tint_symbol_1* v_2 [[threadgroup(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.arg_0=(&(*v_2).tint_symbol)};
  compute_main_inner(tint_local_index, tint_module_vars);
}
