#include <metal_stdlib>
using namespace metal;

struct atomic_compare_exchange_result_u32 {
  uint old_value;
  bool exchanged;
};

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

struct tint_module_vars_struct {
  device SB_RW* sb_rw;
};

atomic_compare_exchange_result_u32 v(device atomic_uint* const atomic_ptr, uint cmp, uint val) {
  uint old_value = cmp;
  bool const v_1 = atomic_compare_exchange_weak_explicit(atomic_ptr, (&old_value), val, memory_order_relaxed, memory_order_relaxed);
  return atomic_compare_exchange_result_u32{.old_value=old_value, .exchanged=v_1};
}

void atomicCompareExchangeWeak_63d8e6(tint_module_vars_struct tint_module_vars) {
  atomic_compare_exchange_result_u32 res = v((&(*tint_module_vars.sb_rw).arg_0), 1u, 1u);
}

fragment void fragment_main(device SB_RW* sb_rw [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.sb_rw=sb_rw};
  atomicCompareExchangeWeak_63d8e6(tint_module_vars);
}

kernel void compute_main(device SB_RW* sb_rw [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.sb_rw=sb_rw};
  atomicCompareExchangeWeak_63d8e6(tint_module_vars);
}
