SKIP: FAILED

#include <metal_stdlib>
using namespace metal;

struct RenderParams {
  float4x4 modelViewProjectionMatrix;
  float3 right;
  float3 up;
};

struct SimulationParams {
  float deltaTime;
  float4 seed;
};

template<typename T, size_t N>
struct tint_array {
  const constant T& operator[](size_t i) const constant { return elements[i]; }
  device T& operator[](size_t i) device { return elements[i]; }
  const device T& operator[](size_t i) const device { return elements[i]; }
  thread T& operator[](size_t i) thread { return elements[i]; }
  const thread T& operator[](size_t i) const thread { return elements[i]; }
  threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
  const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
  T elements[N];
};

struct Particle {
  float3 position;
  float lifetime;
  float4 color;
  float3 velocity;
};

struct Particles {
  tint_array<Particle, 1> particles;
};

struct UBO {
  uint width;
};

struct Buffer {
  tint_array<float, 1> weights;
};

struct tint_module_vars_struct {
  thread float2* rand_seed;
  const constant RenderParams* render_params;
  const constant SimulationParams* sim_params;
  device Particles* data;
  texture2d<float, access::sample> tint_symbol;
  const constant UBO* ubo;
  const device Buffer* buf_in;
  device Buffer* buf_out;
  texture2d<float, access::sample> tex_in;
  texture2d<float, access::write> tex_out;
};

struct VertexOutput {
  float4 position;
  float4 color;
  float2 quad_pos;
};

struct VertexInput {
  float3 position;
  float4 color;
  float2 quad_pos;
};

struct vs_main_outputs {
  float4 VertexOutput_position [[position]];
  float4 VertexOutput_color [[user(locn0)]];
  float2 VertexOutput_quad_pos [[user(locn1)]];
};

struct vs_main_inputs {
  float3 VertexInput_position [[attribute(0)]];
  float4 VertexInput_color [[attribute(1)]];
  float2 VertexInput_quad_pos [[attribute(2)]];
};

struct fs_main_outputs {
  float4 tint_symbol_1 [[color(0)]];
};

struct fs_main_inputs {
  float4 VertexOutput_color [[user(locn0)]];
  float2 VertexOutput_quad_pos [[user(locn1)]];
};

float rand(tint_module_vars_struct tint_module_vars) {
  (*tint_module_vars.rand_seed)[0u] = fract((cos(dot((*tint_module_vars.rand_seed), float2(23.1407794952392578125f, 232.6168975830078125f))) * 136.816802978515625f));
  (*tint_module_vars.rand_seed)[1u] = fract((cos(dot((*tint_module_vars.rand_seed), float2(54.478565216064453125f, 345.841522216796875f))) * 534.7645263671875f));
  return (*tint_module_vars.rand_seed)[1u];
}

VertexOutput vs_main_inner(VertexInput in, tint_module_vars_struct tint_module_vars) {
  float3 quad_pos = (float2x3((*tint_module_vars.render_params).right, (*tint_module_vars.render_params).up) * in.quad_pos);
  float3 position = (in.position + (quad_pos * 0.00999999977648258209f));
  VertexOutput out = {};
  float4x4 const v = (*tint_module_vars.render_params).modelViewProjectionMatrix;
  out.position = (v * float4(position, 1.0f));
  out.color = in.color;
  out.quad_pos = in.quad_pos;
  return out;
}

float4 fs_main_inner(VertexOutput in) {
  float4 color = in.color;
  float const v_1 = color[3u];
  color[3u] = (v_1 * max((1.0f - length(in.quad_pos)), 0.0f));
  return color;
}

void tint_store_and_preserve_padding(device Particle* const target, Particle value_param) {
  (*target).position = value_param.position;
  (*target).lifetime = value_param.lifetime;
  (*target).color = value_param.color;
  (*target).velocity = value_param.velocity;
}

void simulate_inner(uint3 GlobalInvocationID, tint_module_vars_struct tint_module_vars) {
  float2 const v_2 = (*tint_module_vars.sim_params).seed.xy;
  float2 const v_3 = (v_2 + float2(GlobalInvocationID.xy));
  (*tint_module_vars.rand_seed) = (v_3 * (*tint_module_vars.sim_params).seed.zw);
  uint const idx = GlobalInvocationID[0u];
  Particle particle = (*tint_module_vars.data).particles[idx];
  particle.velocity[2u] = (particle.velocity[2u] - ((*tint_module_vars.sim_params).deltaTime * 0.5f));
  particle.position = (particle.position + ((*tint_module_vars.sim_params).deltaTime * particle.velocity));
  particle.lifetime = (particle.lifetime - (*tint_module_vars.sim_params).deltaTime);
  particle.color[3u] = smoothstep(0.0f, 0.5f, particle.lifetime);
  if ((particle.lifetime < 0.0f)) {
    uint2 coord = uint2(0u);
    {
      uint level = (tint_module_vars.tint_symbol.get_num_mip_levels() - 1u);
      while(true) {
        if ((level > 0u)) {
        } else {
          break;
        }
        float4 const probabilites = tint_module_vars.tint_symbol.read(coord, level);
        float4 const value = float4(rand(tint_module_vars));
        bool4 const mask = ((value >= float4(0.0f, probabilites.xyz)) & (value < probabilites));
        coord = (coord * 2u);
        uint const v_4 = select(0u, 1u, any(mask.yw));
        coord[0u] = (coord[0u] + v_4);
        uint const v_5 = select(0u, 1u, any(mask.zw));
        coord[1u] = (coord[1u] + v_5);
        {
          level = (level - 1u);
        }
        continue;
      }
    }
    float2 const v_6 = float2(coord);
    uint const v_7 = tint_module_vars.tint_symbol.get_width(0u);
    float2 const uv = (v_6 / float2(uint2(v_7, tint_module_vars.tint_symbol.get_height(0u))));
    particle.position = float3((((uv - 0.5f) * 3.0f) * float2(1.0f, -1.0f)), 0.0f);
    particle.color = tint_module_vars.tint_symbol.read(coord, 0);
    particle.velocity[0u] = ((rand(tint_module_vars) - 0.5f) * 0.10000000149011611938f);
    particle.velocity[1u] = ((rand(tint_module_vars) - 0.5f) * 0.10000000149011611938f);
    particle.velocity[2u] = (rand(tint_module_vars) * 0.30000001192092895508f);
    particle.lifetime = (0.5f + (rand(tint_module_vars) * 2.0f));
  }
  tint_store_and_preserve_padding((&(*tint_module_vars.data).particles[idx]), particle);
}

void import_level_inner(uint3 coord, tint_module_vars_struct tint_module_vars) {
  uint const offset = (coord[0u] + (coord[1u] * (*tint_module_vars.ubo).width));
  (*tint_module_vars.buf_out).weights[offset] = tint_module_vars.tex_in.read(uint2(int2(coord.xy)), 0)[3u];
}

void export_level_inner(uint3 coord, tint_module_vars_struct tint_module_vars) {
  uint const v_8 = tint_module_vars.tex_out.get_width(0u);
  if (all((coord.xy < uint2(uint2(v_8, tint_module_vars.tex_out.get_height(0u)))))) {
    uint const dst_offset = (coord[0u] + (coord[1u] * (*tint_module_vars.ubo).width));
    uint const src_offset = ((coord[0u] * 2u) + ((coord[1u] * 2u) * (*tint_module_vars.ubo).width));
    float const a = (*tint_module_vars.buf_in).weights[(src_offset + 0u)];
    float const b = (*tint_module_vars.buf_in).weights[(src_offset + 1u)];
    float const c = (*tint_module_vars.buf_in).weights[((src_offset + 0u) + (*tint_module_vars.ubo).width)];
    float const d = (*tint_module_vars.buf_in).weights[((src_offset + 1u) + (*tint_module_vars.ubo).width)];
    float const sum = dot(float4(a, b, c, d), float4(1.0f));
    (*tint_module_vars.buf_out).weights[dst_offset] = (sum / 4.0f);
    float4 const v_9 = float4(a, (a + b), ((a + b) + c), sum);
    float4 const probabilities = (v_9 / max(sum, 0.00009999999747378752f));
    tint_module_vars.tex_out.write(probabilities, uint2(int2(coord.xy)));
  }
}

vertex vs_main_outputs vs_main(vs_main_inputs inputs [[stage_in]], const constant RenderParams* render_params [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.render_params=render_params};
  VertexOutput const v_10 = vs_main_inner(VertexInput{.position=inputs.VertexInput_position, .color=inputs.VertexInput_color, .quad_pos=inputs.VertexInput_quad_pos}, tint_module_vars);
  return vs_main_outputs{.VertexOutput_position=v_10.position, .VertexOutput_color=v_10.color, .VertexOutput_quad_pos=v_10.quad_pos};
}

fragment fs_main_outputs fs_main(float4 VertexOutput_position [[position]], fs_main_inputs inputs [[stage_in]]) {
  return fs_main_outputs{.tint_symbol_1=fs_main_inner(VertexOutput{.position=VertexOutput_position, .color=inputs.VertexOutput_color, .quad_pos=inputs.VertexOutput_quad_pos})};
}

kernel void simulate(uint3 GlobalInvocationID [[thread_position_in_grid]], const constant SimulationParams* sim_params [[buffer(0)]], device Particles* data [[buffer(1)]], texture2d<float, access::sample> tint_symbol [[texture(0)]]) {
  thread float2 rand_seed = 0.0f;
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.rand_seed=(&rand_seed), .sim_params=sim_params, .data=data, .tint_symbol=tint_symbol};
  simulate_inner(GlobalInvocationID, tint_module_vars);
}

kernel void import_level(uint3 coord [[thread_position_in_grid]], const constant UBO* ubo [[buffer(2)]], device Buffer* buf_out [[buffer(3)]], texture2d<float, access::sample> tex_in [[texture(1)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.ubo=ubo, .buf_out=buf_out, .tex_in=tex_in};
  import_level_inner(coord, tint_module_vars);
}

kernel void export_level(uint3 coord [[thread_position_in_grid]], const constant UBO* ubo [[buffer(2)]], const device Buffer* buf_in [[buffer(4)]], device Buffer* buf_out [[buffer(3)]], texture2d<float, access::write> tex_out [[texture(2)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.ubo=ubo, .buf_in=buf_in, .buf_out=buf_out, .tex_out=tex_out};
  export_level_inner(coord, tint_module_vars);
}
program_source:192:104: error: call to deleted constructor of 'texture2d<float, access::sample>'
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.render_params=render_params};
                                                                                                       ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.194/include/metal/metal_texture:6083:3: note: 'texture2d' has been explicitly marked deleted here
  texture2d() thread = delete;
  ^
program_source:51:36: note: in implicit initialization of field 'tint_symbol' with omitted initializer
  texture2d<float, access::sample> tint_symbol;
                                   ^
program_source:203:161: error: call to deleted constructor of 'texture2d<float, access::sample>'
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.rand_seed=(&rand_seed), .sim_params=sim_params, .data=data, .tint_symbol=tint_symbol};
                                                                                                                                                                ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.194/include/metal/metal_texture:6083:3: note: 'texture2d' has been explicitly marked deleted here
  texture2d() thread = delete;
  ^
program_source:55:36: note: in implicit initialization of field 'tex_in' with omitted initializer
  texture2d<float, access::sample> tex_in;
                                   ^
program_source:208:118: error: call to deleted constructor of 'texture2d<float, access::sample>'
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.ubo=ubo, .buf_out=buf_out, .tex_in=tex_in};
                                                                                                                     ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.194/include/metal/metal_texture:6083:3: note: 'texture2d' has been explicitly marked deleted here
  texture2d() thread = delete;
  ^
program_source:51:36: note: in implicit initialization of field 'tint_symbol' with omitted initializer
  texture2d<float, access::sample> tint_symbol;
                                   ^
program_source:213:136: error: call to deleted constructor of 'texture2d<float, access::sample>'
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.ubo=ubo, .buf_in=buf_in, .buf_out=buf_out, .tex_out=tex_out};
                                                                                                                                       ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.194/include/metal/metal_texture:6083:3: note: 'texture2d' has been explicitly marked deleted here
  texture2d() thread = delete;
  ^
program_source:51:36: note: in implicit initialization of field 'tint_symbol' with omitted initializer
  texture2d<float, access::sample> tint_symbol;
                                   ^

