#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  device uint* prevent_dce;
  threadgroup atomic_uint* arg_0;
};

struct tint_symbol_1 {
  atomic_uint tint_symbol;
};

uint atomicExchange_0a5dca(tint_module_vars_struct tint_module_vars) {
  uint arg_1 = 1u;
  uint res = atomic_exchange_explicit(tint_module_vars.arg_0, arg_1, memory_order_relaxed);
  return res;
}

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);
  (*tint_module_vars.prevent_dce) = atomicExchange_0a5dca(tint_module_vars);
}

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