#include <metal_stdlib>
using namespace metal;

struct S0 {
  int x;
  atomic_uint a;
  int y;
  int z;
};

struct S1 {
  int x;
  S0 a;
  int y;
  int z;
};

struct S2 {
  int x;
  int y;
  int z;
  S1 a;
};

struct tint_module_vars_struct {
  threadgroup S2* wg;
};

struct tint_symbol_1 {
  S2 tint_symbol;
};

void compute_main_inner(uint tint_local_index, tint_module_vars_struct tint_module_vars) {
  if ((tint_local_index == 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);
  atomic_store_explicit((&(*tint_module_vars.wg).a.a.a), 1u, memory_order_relaxed);
}

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{.wg=(&(*v).tint_symbol)};
  compute_main_inner(tint_local_index, tint_module_vars);
}
