#pragma clang diagnostic ignored "-Wunused-variable"

#include <metal_stdlib>
#include <simd/simd.h>
#include <metal_atomic>

using namespace metal;

struct SSBO
{
    uint u32;
    int i32;
};

constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);

kernel void main0(device SSBO& ssbo [[buffer(0)]], texture2d<uint, access::read_write> uImage [[texture(0)]], texture2d_array<uint, access::read_write> uImageArray [[texture(1)]], texture2d<int, access::read_write> iImage [[texture(2)]])
{
    uint _19 = uImage.atomic_fetch_add(uint2(int2(1, 5)), 1u).x;
    uint _27 = uImageArray.atomic_fetch_add(uint3(int3(1, 5, 8)).xy, uint3(int3(1, 5, 8)).z, 1u).x;
    uint _35 = uImage.atomic_fetch_add(uint2(int2(1, 5)), 1u).x;
    iImage.write(int4(int(_35)), uint2(int2(1, 6)));
    uint _40 = uImage.atomic_fetch_or(uint2(int2(1, 5)), 1u).x;
    uint _42 = uImage.atomic_fetch_xor(uint2(int2(1, 5)), 1u).x;
    uint _44 = uImage.atomic_fetch_and(uint2(int2(1, 5)), 1u).x;
    uint _46 = uImage.atomic_fetch_min(uint2(int2(1, 5)), 1u).x;
    uint _48 = uImage.atomic_fetch_max(uint2(int2(1, 5)), 1u).x;
    uint _52;
    uint4 _110;
    do
    {
        _110.x = 10u;
    } while (!uImage.atomic_compare_exchange_weak(uint2(int2(1, 5)), &_110, 2u) && _110.x == 10u);
    _52 = _110.x;
    int _55 = iImage.atomic_fetch_add(uint2(int2(1, 6)), 1).x;
    int _57 = iImage.atomic_fetch_or(uint2(int2(1, 6)), 1).x;
    int _59 = iImage.atomic_fetch_xor(uint2(int2(1, 6)), 1).x;
    int _61 = iImage.atomic_fetch_and(uint2(int2(1, 6)), 1).x;
    int _63 = iImage.atomic_fetch_min(uint2(int2(1, 6)), 1).x;
    int _65 = iImage.atomic_fetch_max(uint2(int2(1, 6)), 1).x;
    int _69;
    int4 _112;
    do
    {
        _112.x = 10;
    } while (!iImage.atomic_compare_exchange_weak(uint2(int2(1, 5)), &_112, 2) && _112.x == 10);
    _69 = _112.x;
    uint _76 = atomic_fetch_add_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed);
    uint _78 = atomic_fetch_or_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed);
    uint _80 = atomic_fetch_xor_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed);
    uint _82 = atomic_fetch_and_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed);
    uint _84 = atomic_fetch_min_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed);
    uint _86 = atomic_fetch_max_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed);
    uint _88 = atomic_exchange_explicit((device atomic_uint*)&ssbo.u32, 1u, memory_order_relaxed);
    uint _90;
    do
    {
        _90 = 10u;
    } while (!atomic_compare_exchange_weak_explicit((device atomic_uint*)&ssbo.u32, &_90, 2u, memory_order_relaxed, memory_order_relaxed) && _90 == 10u);
    int _93 = atomic_fetch_add_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed);
    int _95 = atomic_fetch_or_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed);
    int _97 = atomic_fetch_xor_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed);
    int _99 = atomic_fetch_and_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed);
    int _101 = atomic_fetch_min_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed);
    int _103 = atomic_fetch_max_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed);
    int _105 = atomic_exchange_explicit((device atomic_int*)&ssbo.i32, 1, memory_order_relaxed);
    int _107;
    do
    {
        _107 = 10;
    } while (!atomic_compare_exchange_weak_explicit((device atomic_int*)&ssbo.i32, &_107, 2, memory_order_relaxed, memory_order_relaxed) && _107 == 10);
}

