#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 atomicMin_69d383(tint_module_vars_struct tint_module_vars) {
  uint arg_1 = 1u;
  uint res = atomic_fetch_min_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) = atomicMin_69d383(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);
}
