#include <metal_stdlib>

using namespace metal;
struct buf0 {
  /* 0x0000 */ float2 resolution;
};
struct tint_array_wrapper {
  int arr[256];
};
struct main_out {
  float4 x_GLF_color_1;
};
struct tint_symbol_1 {
  float4 x_GLF_color_1 [[color(0)]];
};

void main_1(constant buf0& x_7, thread float4* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, thread float4* const tint_symbol_5) {
  float2 pos = 0.0f;
  int2 ipos = 0;
  int i = 0;
  int2 p = 0;
  bool canwalk = false;
  int v = 0;
  int directions = 0;
  int j = 0;
  int d = 0;
  float4 const x_57 = *(tint_symbol_3);
  float2 const x_60 = x_7.resolution;
  pos = (float2(x_57.x, x_57.y) / x_60);
  float const x_63 = pos.x;
  float const x_67 = pos.y;
  ipos = int2(int((x_63 * 16.0f)), int((x_67 * 16.0f)));
  i = 0;
  while (true) {
    int const x_75 = i;
    if ((x_75 < 256)) {
    } else {
      break;
    }
    int const x_78 = i;
    (*(tint_symbol_4)).arr[x_78] = 0;
    {
      int const x_80 = i;
      i = as_type<int>((as_type<uint>(x_80) + as_type<uint>(1)));
    }
  }
  p = int2(0, 0);
  canwalk = true;
  v = 0;
  while (true) {
    bool x_102 = false;
    bool x_122 = false;
    bool x_142 = false;
    bool x_162 = false;
    bool x_103_phi = false;
    bool x_123_phi = false;
    bool x_143_phi = false;
    bool x_163_phi = false;
    int const x_86 = v;
    v = as_type<int>((as_type<uint>(x_86) + as_type<uint>(1)));
    directions = 0;
    int const x_89 = p.x;
    bool const x_90 = (x_89 > 0);
    x_103_phi = x_90;
    if (x_90) {
      int const x_94 = p.x;
      int const x_97 = p.y;
      int const x_101 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_94) - as_type<uint>(2)))) + as_type<uint>(as_type<int>((as_type<uint>(x_97) * as_type<uint>(16))))))];
      x_102 = (x_101 == 0);
      x_103_phi = x_102;
    }
    bool const x_103 = x_103_phi;
    if (x_103) {
      int const x_106 = directions;
      directions = as_type<int>((as_type<uint>(x_106) + as_type<uint>(1)));
    }
    int const x_109 = p.y;
    bool const x_110 = (x_109 > 0);
    x_123_phi = x_110;
    if (x_110) {
      int const x_114 = p.x;
      int const x_116 = p.y;
      int const x_121 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_114) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_116) - as_type<uint>(2)))) * as_type<uint>(16))))))];
      x_122 = (x_121 == 0);
      x_123_phi = x_122;
    }
    bool const x_123 = x_123_phi;
    if (x_123) {
      int const x_126 = directions;
      directions = as_type<int>((as_type<uint>(x_126) + as_type<uint>(1)));
    }
    int const x_129 = p.x;
    bool const x_130 = (x_129 < 14);
    x_143_phi = x_130;
    if (x_130) {
      int const x_134 = p.x;
      int const x_137 = p.y;
      int const x_141 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_134) + as_type<uint>(2)))) + as_type<uint>(as_type<int>((as_type<uint>(x_137) * as_type<uint>(16))))))];
      x_142 = (x_141 == 0);
      x_143_phi = x_142;
    }
    bool const x_143 = x_143_phi;
    if (x_143) {
      int const x_146 = directions;
      directions = as_type<int>((as_type<uint>(x_146) + as_type<uint>(1)));
    }
    int const x_149 = p.y;
    bool const x_150 = (x_149 < 14);
    x_163_phi = x_150;
    if (x_150) {
      int const x_154 = p.x;
      int const x_156 = p.y;
      int const x_161 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_154) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_156) + as_type<uint>(2)))) * as_type<uint>(16))))))];
      x_162 = (x_161 == 0);
      x_163_phi = x_162;
    }
    bool const x_163 = x_163_phi;
    if (x_163) {
      int const x_166 = directions;
      directions = as_type<int>((as_type<uint>(x_166) + as_type<uint>(1)));
    }
    bool x_227 = false;
    bool x_240 = false;
    bool x_279 = false;
    bool x_292 = false;
    bool x_331 = false;
    bool x_344 = false;
    bool x_383 = false;
    bool x_396 = false;
    bool x_228_phi = false;
    bool x_241_phi = false;
    bool x_280_phi = false;
    bool x_293_phi = false;
    bool x_332_phi = false;
    bool x_345_phi = false;
    bool x_384_phi = false;
    bool x_397_phi = false;
    int const x_168 = directions;
    if ((x_168 == 0)) {
      canwalk = false;
      i = 0;
      while (true) {
        int const x_177 = i;
        if ((x_177 < 8)) {
        } else {
          break;
        }
        j = 0;
        while (true) {
          int const x_184 = j;
          if ((x_184 < 8)) {
          } else {
            break;
          }
          int const x_187 = j;
          int const x_189 = i;
          int const x_194 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_187) * as_type<uint>(2)))) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_189) * as_type<uint>(2)))) * as_type<uint>(16))))))];
          if ((x_194 == 0)) {
            int const x_198 = j;
            p.x = as_type<int>((as_type<uint>(x_198) * as_type<uint>(2)));
            int const x_201 = i;
            p.y = as_type<int>((as_type<uint>(x_201) * as_type<uint>(2)));
            canwalk = true;
          }
          {
            int const x_204 = j;
            j = as_type<int>((as_type<uint>(x_204) + as_type<uint>(1)));
          }
        }
        {
          int const x_206 = i;
          i = as_type<int>((as_type<uint>(x_206) + as_type<uint>(1)));
        }
      }
      int const x_209 = p.x;
      int const x_211 = p.y;
      (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_209) + as_type<uint>(as_type<int>((as_type<uint>(x_211) * as_type<uint>(16))))))] = 1;
    } else {
      int const x_215 = v;
      int const x_216 = directions;
      d = (x_215 % x_216);
      int const x_218 = directions;
      int const x_219 = v;
      v = as_type<int>((as_type<uint>(x_219) + as_type<uint>(x_218)));
      int const x_221 = d;
      bool const x_222 = (x_221 >= 0);
      x_228_phi = x_222;
      if (x_222) {
        int const x_226 = p.x;
        x_227 = (x_226 > 0);
        x_228_phi = x_227;
      }
      bool const x_228 = x_228_phi;
      x_241_phi = x_228;
      if (x_228) {
        int const x_232 = p.x;
        int const x_235 = p.y;
        int const x_239 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_232) - as_type<uint>(2)))) + as_type<uint>(as_type<int>((as_type<uint>(x_235) * as_type<uint>(16))))))];
        x_240 = (x_239 == 0);
        x_241_phi = x_240;
      }
      bool const x_241 = x_241_phi;
      if (x_241) {
        int const x_244 = d;
        d = as_type<int>((as_type<uint>(x_244) - as_type<uint>(1)));
        int const x_247 = p.x;
        int const x_249 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_247) + as_type<uint>(as_type<int>((as_type<uint>(x_249) * as_type<uint>(16))))))] = 1;
        int const x_254 = p.x;
        int const x_257 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_254) - as_type<uint>(1)))) + as_type<uint>(as_type<int>((as_type<uint>(x_257) * as_type<uint>(16))))))] = 1;
        int const x_262 = p.x;
        int const x_265 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_262) - as_type<uint>(2)))) + as_type<uint>(as_type<int>((as_type<uint>(x_265) * as_type<uint>(16))))))] = 1;
        int const x_270 = p.x;
        p.x = as_type<int>((as_type<uint>(x_270) - as_type<uint>(2)));
      }
      int const x_273 = d;
      bool const x_274 = (x_273 >= 0);
      x_280_phi = x_274;
      if (x_274) {
        int const x_278 = p.y;
        x_279 = (x_278 > 0);
        x_280_phi = x_279;
      }
      bool const x_280 = x_280_phi;
      x_293_phi = x_280;
      if (x_280) {
        int const x_284 = p.x;
        int const x_286 = p.y;
        int const x_291 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_284) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_286) - as_type<uint>(2)))) * as_type<uint>(16))))))];
        x_292 = (x_291 == 0);
        x_293_phi = x_292;
      }
      bool const x_293 = x_293_phi;
      if (x_293) {
        int const x_296 = d;
        d = as_type<int>((as_type<uint>(x_296) - as_type<uint>(1)));
        int const x_299 = p.x;
        int const x_301 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_299) + as_type<uint>(as_type<int>((as_type<uint>(x_301) * as_type<uint>(16))))))] = 1;
        int const x_306 = p.x;
        int const x_308 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_306) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_308) - as_type<uint>(1)))) * as_type<uint>(16))))))] = 1;
        int const x_314 = p.x;
        int const x_316 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_314) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_316) - as_type<uint>(2)))) * as_type<uint>(16))))))] = 1;
        int const x_322 = p.y;
        p.y = as_type<int>((as_type<uint>(x_322) - as_type<uint>(2)));
      }
      int const x_325 = d;
      bool const x_326 = (x_325 >= 0);
      x_332_phi = x_326;
      if (x_326) {
        int const x_330 = p.x;
        x_331 = (x_330 < 14);
        x_332_phi = x_331;
      }
      bool const x_332 = x_332_phi;
      x_345_phi = x_332;
      if (x_332) {
        int const x_336 = p.x;
        int const x_339 = p.y;
        int const x_343 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_336) + as_type<uint>(2)))) + as_type<uint>(as_type<int>((as_type<uint>(x_339) * as_type<uint>(16))))))];
        x_344 = (x_343 == 0);
        x_345_phi = x_344;
      }
      bool const x_345 = x_345_phi;
      if (x_345) {
        int const x_348 = d;
        d = as_type<int>((as_type<uint>(x_348) - as_type<uint>(1)));
        int const x_351 = p.x;
        int const x_353 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_351) + as_type<uint>(as_type<int>((as_type<uint>(x_353) * as_type<uint>(16))))))] = 1;
        int const x_358 = p.x;
        int const x_361 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_358) + as_type<uint>(1)))) + as_type<uint>(as_type<int>((as_type<uint>(x_361) * as_type<uint>(16))))))] = 1;
        int const x_366 = p.x;
        int const x_369 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_366) + as_type<uint>(2)))) + as_type<uint>(as_type<int>((as_type<uint>(x_369) * as_type<uint>(16))))))] = 1;
        int const x_374 = p.x;
        p.x = as_type<int>((as_type<uint>(x_374) + as_type<uint>(2)));
      }
      int const x_377 = d;
      bool const x_378 = (x_377 >= 0);
      x_384_phi = x_378;
      if (x_378) {
        int const x_382 = p.y;
        x_383 = (x_382 < 14);
        x_384_phi = x_383;
      }
      bool const x_384 = x_384_phi;
      x_397_phi = x_384;
      if (x_384) {
        int const x_388 = p.x;
        int const x_390 = p.y;
        int const x_395 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_388) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_390) + as_type<uint>(2)))) * as_type<uint>(16))))))];
        x_396 = (x_395 == 0);
        x_397_phi = x_396;
      }
      bool const x_397 = x_397_phi;
      if (x_397) {
        int const x_400 = d;
        d = as_type<int>((as_type<uint>(x_400) - as_type<uint>(1)));
        int const x_403 = p.x;
        int const x_405 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_403) + as_type<uint>(as_type<int>((as_type<uint>(x_405) * as_type<uint>(16))))))] = 1;
        int const x_410 = p.x;
        int const x_412 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_410) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_412) + as_type<uint>(1)))) * as_type<uint>(16))))))] = 1;
        int const x_418 = p.x;
        int const x_420 = p.y;
        (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(x_418) + as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_420) + as_type<uint>(2)))) * as_type<uint>(16))))))] = 1;
        int const x_426 = p.y;
        p.y = as_type<int>((as_type<uint>(x_426) + as_type<uint>(2)));
      }
    }
    int const x_430 = ipos.y;
    int const x_433 = ipos.x;
    int const x_436 = (*(tint_symbol_4)).arr[as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(x_430) * as_type<uint>(16)))) + as_type<uint>(x_433)))];
    if ((x_436 == 1)) {
      *(tint_symbol_5) = float4(1.0f, 1.0f, 1.0f, 1.0f);
      return;
    }
    {
      bool const x_440 = canwalk;
      if (x_440) {
      } else {
        break;
      }
    }
  }
  *(tint_symbol_5) = float4(0.0f, 0.0f, 0.0f, 1.0f);
  return;
}

main_out tint_symbol_inner(constant buf0& x_7, float4 gl_FragCoord_param, thread float4* const tint_symbol_6, thread tint_array_wrapper* const tint_symbol_7, thread float4* const tint_symbol_8) {
  *(tint_symbol_6) = gl_FragCoord_param;
  main_1(x_7, tint_symbol_6, tint_symbol_7, tint_symbol_8);
  main_out const tint_symbol_2 = {.x_GLF_color_1=*(tint_symbol_8)};
  return tint_symbol_2;
}

fragment tint_symbol_1 tint_symbol(float4 gl_FragCoord_param [[position]], constant buf0& x_7 [[buffer(0)]]) {
  thread float4 tint_symbol_9 = 0.0f;
  thread tint_array_wrapper tint_symbol_10 = {};
  thread float4 tint_symbol_11 = 0.0f;
  main_out const inner_result = tint_symbol_inner(x_7, gl_FragCoord_param, &(tint_symbol_9), &(tint_symbol_10), &(tint_symbol_11));
  tint_symbol_1 wrapper_result = {};
  wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
  return wrapper_result;
}

