#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  threadgroup atomic_int* arg_0;
};

struct tint_symbol_1 {
  atomic_int tint_symbol;
};

void atomicStore_8bea94(tint_module_vars_struct tint_module_vars) {
  int arg_1 = 1;
  atomic_store_explicit(tint_module_vars.arg_0, arg_1, memory_order_relaxed);
}

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);
  atomicStore_8bea94(tint_module_vars);
}

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