#include <metal_stdlib>
using namespace metal;

struct atomic_compare_exchange_result_i32 {
  int old_value;
  bool exchanged;
};

struct tint_module_vars_struct {
  threadgroup atomic_int* arg_0;
};

struct tint_symbol_1 {
  atomic_int tint_symbol;
};

atomic_compare_exchange_result_i32 v(threadgroup atomic_int* const atomic_ptr, int cmp, int val) {
  int 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_i32{.old_value=old_value, .exchanged=v_1};
}

void atomicCompareExchangeWeak_e88938(tint_module_vars_struct tint_module_vars) {
  int arg_1 = 1;
  int arg_2 = 1;
  atomic_compare_exchange_result_i32 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, 0, memory_order_relaxed);
  }
  threadgroup_barrier(mem_flags::mem_threadgroup);
  atomicCompareExchangeWeak_e88938(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);
}
