#include <metal_stdlib>

using namespace metal;

struct atomic_compare_exchange_result_i32 {
  int old_value;
  bool exchanged;
};
atomic_compare_exchange_result_i32 atomicCompareExchangeWeak_1(device atomic_int* atomic, int compare, int value) {
  int old_value = compare;
  bool exchanged = atomic_compare_exchange_weak_explicit(atomic, &old_value, value, memory_order_relaxed, memory_order_relaxed);
  return {old_value, exchanged};
}

struct SB_RW {
  /* 0x0000 */ atomic_int arg_0;
};

void atomicCompareExchangeWeak_1bd40a(device SB_RW* const tint_symbol) {
  atomic_compare_exchange_result_i32 res = atomicCompareExchangeWeak_1(&((*(tint_symbol)).arg_0), 1, 1);
}

fragment void fragment_main(device SB_RW* tint_symbol_1 [[buffer(0)]]) {
  atomicCompareExchangeWeak_1bd40a(tint_symbol_1);
  return;
}

kernel void compute_main(device SB_RW* tint_symbol_2 [[buffer(0)]]) {
  atomicCompareExchangeWeak_1bd40a(tint_symbol_2);
  return;
}

