#pragma clang diagnostic ignored "-Wmissing-prototypes"

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

using namespace metal;

struct BDA;

struct BDA
{
    float v;
};

struct SSBO
{
    uint v;
};

struct Registers
{
    coherent device BDA* ssbo;
};

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

static inline __attribute__((always_inline))
void foo(coherent device SSBO& _25, texture2d<float, access::write, memory_coherence_device> img)
{
    _25.v += 2u;
    img.write(float4(8.0), uint2(int2(4)));
}

static inline __attribute__((always_inline))
void write_in_func(texture2d<float, access::write, memory_coherence_device> img)
{
    img.write(float4(4.0), uint2(int2(2)));
}

static inline __attribute__((always_inline))
void write_in_func(coherent device BDA* const thread & s)
{
    s->v += 6.0;
}

kernel void main0(coherent device SSBO& _25 [[buffer(0)]], constant Registers& _69 [[buffer(1)]], texture2d<float, access::write, memory_coherence_device> img [[texture(0)]])
{
    _25.v += 10u;
    foo(_25, img);
    img.write(float4(1.0), uint2(int2(1)));
    write_in_func(img);
    coherent device BDA* tmp = _69.ssbo;
    tmp->v += 4.0;
    coherent device BDA* param = tmp;
    write_in_func(param);
}

