#include <metal_stdlib>
using namespace metal;

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 LeftOver_packed_vec3 {
  /* 0x0000 */ float time;
  /* 0x0004 */ uint padding;
  /* 0x0008 */ tint_array<int8_t, 8> tint_pad;
  /* 0x0010 */ float4x4 worldViewProjection;
  /* 0x0050 */ float2 outputSize;
  /* 0x0058 */ float2 stageSize;
  /* 0x0060 */ float2 spriteMapSize;
  /* 0x0068 */ float stageScale;
  /* 0x006c */ float spriteCount;
  /* 0x0070 */ packed_float3 colorMul;
  /* 0x007c */ tint_array<int8_t, 4> tint_pad_1;
};

struct tint_module_vars_struct {
  const constant LeftOver_packed_vec3* x_20;
  texture2d<float, access::sample> frameMapTexture;
  sampler frameMapSampler;
  thread float2* tUV;
  texture2d<float, access::sample> tileMapsTexture0;
  sampler tileMapsSampler;
  texture2d<float, access::sample> tileMapsTexture1;
  texture2d<float, access::sample> animationMapTexture;
  sampler animationMapSampler;
  thread float* mt;
  texture2d<float, access::sample> spriteSheetTexture;
  sampler spriteSheetSampler;
  thread float4* glFragColor;
  thread float2* tileID_1;
  thread float2* levelUnits;
  thread float2* stageUnits_1;
  thread float3* vPosition;
  thread float2* vUV;
};

#define TINT_ISOLATE_UB(VOLATILE_NAME) \
  volatile bool VOLATILE_NAME = true; \
  if (VOLATILE_NAME)

struct main_out {
  float4 glFragColor_1;
};

struct tint_symbol_outputs {
  float4 main_out_glFragColor_1 [[color(0)]];
};

struct tint_symbol_inputs {
  float2 tUV_param [[user(locn2)]];
  float2 tileID_1_param [[user(locn5)]];
  float2 levelUnits_param [[user(locn4)]];
  float2 stageUnits_1_param [[user(locn3)]];
  float3 vPosition_param [[user(locn0)]];
  float2 vUV_param [[user(locn1)]];
};

float4x4 getFrameData_f1_(thread float* const frameID, tint_module_vars_struct tint_module_vars) {
  float fX = 0.0f;
  float const x_15 = (*frameID);
  float const x_25 = (*tint_module_vars.x_20).spriteCount;
  fX = (x_15 / x_25);
  float const x_37 = fX;
  float2 const v = float2(x_37, 0.0f);
  float4 const x_40 = tint_module_vars.frameMapTexture.sample(tint_module_vars.frameMapSampler, v, bias(0.0f));
  float const x_44 = fX;
  float2 const v_1 = float2(x_44, 0.25f);
  float4 const x_47 = tint_module_vars.frameMapTexture.sample(tint_module_vars.frameMapSampler, v_1, bias(0.0f));
  float const x_51 = fX;
  float2 const v_2 = float2(x_51, 0.5f);
  float4 const x_54 = tint_module_vars.frameMapTexture.sample(tint_module_vars.frameMapSampler, v_2, bias(0.0f));
  float4 const v_3 = float4(x_40[0u], x_40[1u], x_40[2u], x_40[3u]);
  float4 const v_4 = float4(x_47[0u], x_47[1u], x_47[2u], x_47[3u]);
  return float4x4(v_3, v_4, float4(x_54[0u], x_54[1u], x_54[2u], x_54[3u]), float4(0.0f));
}

void main_1(tint_module_vars_struct tint_module_vars) {
  float4 color = 0.0f;
  float2 tileUV = 0.0f;
  float2 tileID = 0.0f;
  float2 sheetUnits = 0.0f;
  float spriteUnits = 0.0f;
  float2 stageUnits = 0.0f;
  int i = 0;
  float frameID_1 = 0.0f;
  float4 animationData = 0.0f;
  float f = 0.0f;
  float4x4 frameData = float4x4(0.0f);
  float param = 0.0f;
  float2 frameSize = 0.0f;
  float2 offset_1 = 0.0f;
  float2 ratio = 0.0f;
  float4 nc = 0.0f;
  float alpha = 0.0f;
  float3 mixed = 0.0f;
  color = float4(0.0f);
  float2 const x_86 = (*tint_module_vars.tUV);
  tileUV = fract(x_86);
  float const x_91 = tileUV[1u];
  tileUV[1u] = (1.0f - x_91);
  float2 const x_95 = (*tint_module_vars.tUV);
  tileID = floor(x_95);
  float2 const x_101 = (*tint_module_vars.x_20).spriteMapSize;
  sheetUnits = (float2(1.0f) / x_101);
  float const x_106 = (*tint_module_vars.x_20).spriteCount;
  spriteUnits = (1.0f / x_106);
  float2 const x_111 = (*tint_module_vars.x_20).stageSize;
  stageUnits = (float2(1.0f) / x_111);
  i = 0;
  {
    TINT_ISOLATE_UB(tint_volatile_true) while(true) {
      int const x_122 = i;
      if ((x_122 < 2)) {
      } else {
        break;
      }
      int const x_126 = i;
      switch(x_126) {
        case 1:
        {
          float2 const x_150 = tileID;
          float2 const x_154 = (*tint_module_vars.x_20).stageSize;
          float4 const x_156 = tint_module_vars.tileMapsTexture1.sample(tint_module_vars.tileMapsSampler, ((x_150 + float2(0.5f)) / x_154), bias(0.0f));
          frameID_1 = x_156[0u];
          break;
        }
        case 0:
        {
          float2 const x_136 = tileID;
          float2 const x_140 = (*tint_module_vars.x_20).stageSize;
          float4 const x_142 = tint_module_vars.tileMapsTexture0.sample(tint_module_vars.tileMapsSampler, ((x_136 + float2(0.5f)) / x_140), bias(0.0f));
          frameID_1 = x_142[0u];
          break;
        }
        default:
        {
          break;
        }
      }
      float const x_166 = frameID_1;
      float const x_169 = (*tint_module_vars.x_20).spriteCount;
      float2 const v_5 = float2(((x_166 + 0.5f) / x_169), 0.0f);
      float4 const x_172 = tint_module_vars.animationMapTexture.sample(tint_module_vars.animationMapSampler, v_5, bias(0.0f));
      animationData = x_172;
      float const x_174 = animationData[1u];
      if ((x_174 > 0.0f)) {
        float const x_181 = (*tint_module_vars.x_20).time;
        float const x_184 = animationData[2u];
        (*tint_module_vars.mt) = fmod((x_181 * x_184), 1.0f);
        f = 0.0f;
        {
          TINT_ISOLATE_UB(tint_volatile_true_1) while(true) {
            float const x_193 = f;
            if ((x_193 < 8.0f)) {
            } else {
              break;
            }
            float const x_197 = animationData[1u];
            float const x_198 = (*tint_module_vars.mt);
            if ((x_197 > x_198)) {
              float const x_203 = animationData[0u];
              frameID_1 = x_203;
              break;
            }
            float const x_208 = frameID_1;
            float const x_211 = (*tint_module_vars.x_20).spriteCount;
            float const x_214 = f;
            float4 const x_217 = float4(0.0f);
            animationData = x_217;
            {
              float const x_218 = f;
              f = (x_218 + 1.0f);
            }
            continue;
          }
        }
      }
      float const x_222 = frameID_1;
      param = (x_222 + 0.5f);
      float4x4 const x_225 = getFrameData_f1_((&param), tint_module_vars);
      frameData = x_225;
      float4 const x_228 = frameData[0];
      float2 const x_231 = (*tint_module_vars.x_20).spriteMapSize;
      frameSize = (float2(x_228[3u], x_228[2u]) / x_231);
      float4 const x_235 = frameData[0];
      float2 const x_237 = sheetUnits;
      offset_1 = (float2(x_235[0u], x_235[1u]) * x_237);
      float4 const x_241 = frameData[2];
      float4 const x_244 = frameData[0];
      float2 const v_6 = float2(x_241[0u], x_241[1u]);
      ratio = (v_6 / float2(x_244[3u], x_244[2u]));
      float const x_248 = frameData[2][2u];
      if ((x_248 == 1.0f)) {
        float2 const x_252 = tileUV;
        tileUV = float2(x_252[1u], x_252[0u]);
      }
      int const x_254 = i;
      if ((x_254 == 0)) {
        float2 const x_263 = tileUV;
        float2 const x_264 = frameSize;
        float2 const x_266 = offset_1;
        float4 const x_268 = tint_module_vars.spriteSheetTexture.sample(tint_module_vars.spriteSheetSampler, ((x_263 * x_264) + x_266));
        color = x_268;
      } else {
        float2 const x_274 = tileUV;
        float2 const x_275 = frameSize;
        float2 const x_277 = offset_1;
        float4 const x_279 = tint_module_vars.spriteSheetTexture.sample(tint_module_vars.spriteSheetSampler, ((x_274 * x_275) + x_277));
        nc = x_279;
        float const x_283 = color[3u];
        float const x_285 = nc[3u];
        alpha = min((x_283 + x_285), 1.0f);
        float4 const x_290 = color;
        float4 const x_292 = nc;
        float const x_295 = nc[3u];
        float3 const v_7 = float3(x_290[0u], x_290[1u], x_290[2u]);
        float3 const v_8 = float3(x_292[0u], x_292[1u], x_292[2u]);
        mixed = mix(v_7, v_8, float3(x_295, x_295, x_295));
        float3 const x_298 = mixed;
        float const x_299 = alpha;
        color = float4(x_298[0u], x_298[1u], x_298[2u], x_299);
      }
      {
        int const x_304 = i;
        i = as_type<int>((as_type<uint>(x_304) + as_type<uint>(1)));
      }
      continue;
    }
  }
  float3 const x_310 = float3((*tint_module_vars.x_20).colorMul);
  float4 const x_311 = color;
  float3 const x_313 = (float3(x_311[0u], x_311[1u], x_311[2u]) * x_310);
  float4 const x_314 = color;
  color = float4(x_313[0u], x_313[1u], x_313[2u], x_314[3u]);
  float4 const x_318 = color;
  (*tint_module_vars.glFragColor) = x_318;
}

main_out tint_symbol_inner(float2 tUV_param, float2 tileID_1_param, float2 levelUnits_param, float2 stageUnits_1_param, float3 vPosition_param, float2 vUV_param, tint_module_vars_struct tint_module_vars) {
  (*tint_module_vars.tUV) = tUV_param;
  (*tint_module_vars.tileID_1) = tileID_1_param;
  (*tint_module_vars.levelUnits) = levelUnits_param;
  (*tint_module_vars.stageUnits_1) = stageUnits_1_param;
  (*tint_module_vars.vPosition) = vPosition_param;
  (*tint_module_vars.vUV) = vUV_param;
  main_1(tint_module_vars);
  return main_out{.glFragColor_1=(*tint_module_vars.glFragColor)};
}

fragment tint_symbol_outputs tint_symbol(tint_symbol_inputs inputs [[stage_in]], const constant LeftOver_packed_vec3* x_20 [[buffer(0)]], texture2d<float, access::sample> frameMapTexture [[texture(3)]], sampler frameMapSampler [[sampler(2)]], texture2d<float, access::sample> tileMapsTexture0 [[texture(1)]], sampler tileMapsSampler [[sampler(0)]], texture2d<float, access::sample> tileMapsTexture1 [[texture(0)]], texture2d<float, access::sample> animationMapTexture [[texture(2)]], sampler animationMapSampler [[sampler(1)]], texture2d<float, access::sample> spriteSheetTexture [[texture(4)]], sampler spriteSheetSampler [[sampler(3)]]) {
  thread float2 tUV = 0.0f;
  thread float mt = 0.0f;
  thread float4 glFragColor = 0.0f;
  thread float2 tileID_1 = 0.0f;
  thread float2 levelUnits = 0.0f;
  thread float2 stageUnits_1 = 0.0f;
  thread float3 vPosition = 0.0f;
  thread float2 vUV = 0.0f;
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.x_20=x_20, .frameMapTexture=frameMapTexture, .frameMapSampler=frameMapSampler, .tUV=(&tUV), .tileMapsTexture0=tileMapsTexture0, .tileMapsSampler=tileMapsSampler, .tileMapsTexture1=tileMapsTexture1, .animationMapTexture=animationMapTexture, .animationMapSampler=animationMapSampler, .mt=(&mt), .spriteSheetTexture=spriteSheetTexture, .spriteSheetSampler=spriteSheetSampler, .glFragColor=(&glFragColor), .tileID_1=(&tileID_1), .levelUnits=(&levelUnits), .stageUnits_1=(&stageUnits_1), .vPosition=(&vPosition), .vUV=(&vUV)};
  tint_symbol_outputs tint_wrapper_result = {};
  tint_wrapper_result.main_out_glFragColor_1 = tint_symbol_inner(inputs.tUV_param, inputs.tileID_1_param, inputs.levelUnits_param, inputs.stageUnits_1_param, inputs.vPosition_param, inputs.vUV_param, tint_module_vars).glFragColor_1;
  return tint_wrapper_result;
}
