#include <metal_stdlib>
using namespace metal;
struct S0_atomic {
  int x;
  atomic_uint a;
  int y;
  int z;
};
struct S1_atomic {
  int x;
  S0_atomic a;
  int y;
  int z;
};
struct S2_atomic {
  int x;
  int y;
  int z;
  S1_atomic a;
};
struct tint_module_vars_struct {
  thread uint* local_invocation_index_1;
  threadgroup S2_atomic* wg;
};
struct tint_symbol_1 {
  S2_atomic tint_symbol;
};

void compute_main_inner(uint local_invocation_index_2, tint_module_vars_struct tint_module_vars) {
  (*tint_module_vars.wg).x = 0;
  (*tint_module_vars.wg).y = 0;
  (*tint_module_vars.wg).z = 0;
  (*tint_module_vars.wg).a.x = 0;
  (*tint_module_vars.wg).a.a.x = 0;
  atomic_store_explicit((&(*tint_module_vars.wg).a.a.a), 0u, memory_order_relaxed);
  (*tint_module_vars.wg).a.a.y = 0;
  (*tint_module_vars.wg).a.a.z = 0;
  (*tint_module_vars.wg).a.y = 0;
  (*tint_module_vars.wg).a.z = 0;
  threadgroup_barrier(mem_flags::mem_threadgroup);
  atomic_store_explicit((&(*tint_module_vars.wg).a.a.a), 1u, memory_order_relaxed);
}
void compute_main_1(tint_module_vars_struct tint_module_vars) {
  uint const x_44 = (*tint_module_vars.local_invocation_index_1);
  compute_main_inner(x_44, tint_module_vars);
}
void compute_main_inner_1(uint local_invocation_index_1_param, tint_module_vars_struct tint_module_vars) {
  if ((local_invocation_index_1_param == 0u)) {
    (*tint_module_vars.wg).x = 0;
    (*tint_module_vars.wg).y = 0;
    (*tint_module_vars.wg).z = 0;
    (*tint_module_vars.wg).a.x = 0;
    (*tint_module_vars.wg).a.a.x = 0;
    atomic_store_explicit((&(*tint_module_vars.wg).a.a.a), 0u, memory_order_relaxed);
    (*tint_module_vars.wg).a.a.y = 0;
    (*tint_module_vars.wg).a.a.z = 0;
    (*tint_module_vars.wg).a.y = 0;
    (*tint_module_vars.wg).a.z = 0;
  }
  threadgroup_barrier(mem_flags::mem_threadgroup);
  (*tint_module_vars.local_invocation_index_1) = local_invocation_index_1_param;
  compute_main_1(tint_module_vars);
}
kernel void compute_main(uint local_invocation_index_1_param [[thread_index_in_threadgroup]], threadgroup tint_symbol_1* v [[threadgroup(0)]]) {
  thread uint local_invocation_index_1 = 0u;
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.local_invocation_index_1=(&local_invocation_index_1), .wg=(&(*v).tint_symbol)};
  compute_main_inner_1(local_invocation_index_1_param, tint_module_vars);
}
