#include <metal_stdlib>

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

void atomicLoad_361bf1(threadgroup atomic_uint* const tint_symbol_1, device uint* const tint_symbol_2) {
  uint res = atomic_load_explicit(tint_symbol_1, memory_order_relaxed);
  *(tint_symbol_2) = res;
}

void compute_main_inner(uint local_invocation_index, threadgroup atomic_uint* const tint_symbol_3, device uint* const tint_symbol_4) {
  tint_zero_workgroup_memory(local_invocation_index, tint_symbol_3);
  atomicLoad_361bf1(tint_symbol_3, tint_symbol_4);
}

kernel void compute_main(device uint* tint_symbol_6 [[buffer(0)]], uint local_invocation_index [[thread_index_in_threadgroup]]) {
  threadgroup atomic_uint tint_symbol_5;
  compute_main_inner(local_invocation_index, &(tint_symbol_5), tint_symbol_6);
  return;
}

