#version 310 es


struct atomic_compare_exchange_result_u32 {
  uint old_value;
  bool exchanged;
};

struct atomic_compare_exchange_result_i32 {
  int old_value;
  bool exchanged;
};

layout(binding = 0, std430)
buffer a_u32_block_1_ssbo {
  uint inner;
} v;
layout(binding = 1, std430)
buffer a_i32_block_1_ssbo {
  int inner;
} v_1;
shared uint b_u32;
shared int b_i32;
void tint_symbol_inner(uint tint_local_index) {
  if ((tint_local_index == 0u)) {
    atomicExchange(b_u32, 0u);
    atomicExchange(b_i32, 0);
  }
  barrier();
  uint value = 42u;
  uint v_2 = atomicCompSwap(v.inner, 0u, value);
  atomic_compare_exchange_result_u32 r1 = atomic_compare_exchange_result_u32(v_2, (v_2 == 0u));
  uint v_3 = atomicCompSwap(v.inner, 0u, value);
  atomic_compare_exchange_result_u32 r2 = atomic_compare_exchange_result_u32(v_3, (v_3 == 0u));
  uint v_4 = atomicCompSwap(v.inner, 0u, value);
  atomic_compare_exchange_result_u32 r3 = atomic_compare_exchange_result_u32(v_4, (v_4 == 0u));
  int value_1 = 42;
  int v_5 = atomicCompSwap(v_1.inner, 0, value_1);
  atomic_compare_exchange_result_i32 r1_1 = atomic_compare_exchange_result_i32(v_5, (v_5 == 0));
  int v_6 = atomicCompSwap(v_1.inner, 0, value_1);
  atomic_compare_exchange_result_i32 r2_1 = atomic_compare_exchange_result_i32(v_6, (v_6 == 0));
  int v_7 = atomicCompSwap(v_1.inner, 0, value_1);
  atomic_compare_exchange_result_i32 r3_1 = atomic_compare_exchange_result_i32(v_7, (v_7 == 0));
  uint value_2 = 42u;
  uint v_8 = atomicCompSwap(b_u32, 0u, value_2);
  atomic_compare_exchange_result_u32 r1_2 = atomic_compare_exchange_result_u32(v_8, (v_8 == 0u));
  uint v_9 = atomicCompSwap(b_u32, 0u, value_2);
  atomic_compare_exchange_result_u32 r2_2 = atomic_compare_exchange_result_u32(v_9, (v_9 == 0u));
  uint v_10 = atomicCompSwap(b_u32, 0u, value_2);
  atomic_compare_exchange_result_u32 r3_2 = atomic_compare_exchange_result_u32(v_10, (v_10 == 0u));
  int value_3 = 42;
  int v_11 = atomicCompSwap(b_i32, 0, value_3);
  atomic_compare_exchange_result_i32 r1_3 = atomic_compare_exchange_result_i32(v_11, (v_11 == 0));
  int v_12 = atomicCompSwap(b_i32, 0, value_3);
  atomic_compare_exchange_result_i32 r2_3 = atomic_compare_exchange_result_i32(v_12, (v_12 == 0));
  int v_13 = atomicCompSwap(b_i32, 0, value_3);
  atomic_compare_exchange_result_i32 r3_3 = atomic_compare_exchange_result_i32(v_13, (v_13 == 0));
}
layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
void main() {
  tint_symbol_inner(gl_LocalInvocationIndex);
}
