#include <metal_stdlib>

using namespace metal;
void tint_zero_workgroup_memory(uint local_idx, threadgroup atomic_uint* const tint_symbol) {
  if ((local_idx < 1u)) {
    atomic_store_explicit(tint_symbol, 0u, memory_order_relaxed);
  }
  threadgroup_barrier(mem_flags::mem_threadgroup);
}

void atomicStore_726882(threadgroup atomic_uint* const tint_symbol_1) {
  uint arg_1 = 1u;
  atomic_store_explicit(tint_symbol_1, arg_1, memory_order_relaxed);
}

void compute_main_inner(uint local_invocation_index, threadgroup atomic_uint* const tint_symbol_2) {
  tint_zero_workgroup_memory(local_invocation_index, tint_symbol_2);
  atomicStore_726882(tint_symbol_2);
}

kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
  threadgroup atomic_uint tint_symbol_3;
  compute_main_inner(local_invocation_index, &(tint_symbol_3));
  return;
}

