struct atomic_compare_exchange_result_i32 {
  int old_value;
  bool exchanged;
};

struct foo_outputs {
  int tint_symbol : SV_Target0;
};


RWByteAddressBuffer a : register(u0);
static bool continue_execution = true;
int foo_inner() {
  continue_execution = false;
  int x = 0;
  int v = 0;
  a.InterlockedCompareExchange(int(0u), 0, 1, v);
  int v_1 = v;
  atomic_compare_exchange_result_i32 v_2 = {v_1, (v_1 == 0)};
  atomic_compare_exchange_result_i32 result = v_2;
  if (result.exchanged) {
    atomic_compare_exchange_result_i32 v_3 = v_2;
    x = v_3.old_value;
  }
  return x;
}

foo_outputs foo() {
  foo_outputs v_4 = {foo_inner()};
  if (!(continue_execution)) {
    discard;
  }
  foo_outputs v_5 = v_4;
  return v_5;
}

