#include <metal_stdlib>
#pragma clang diagnostic ignored "-Wparentheses-equality"
using namespace metal;
struct xlatMtlShaderInput {
  half2 xlv_TEXCOORD0;
};
struct xlatMtlShaderOutput {
  half4 _fragData [[color(0)]];
};
struct xlatMtlShaderUniform {
  half _NumPasses;
  half4 _ContrastShift;
  half4 _SaturationShift;
  half4 _HueShift;
  half4 _LuminosityShift;
};
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
  ,   texture2d<half> _MainTex [[texture(0)]], sampler _mtlsmp__MainTex [[sampler(0)]])
{
  xlatMtlShaderOutput _mtl_o;
  half4 t_1;
  half4 tmpvar_2;
  tmpvar_2 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0));
  t_1 = tmpvar_2;
  if ((_mtl_u._NumPasses > (half)0.0)) {
    half passes_3;
    passes_3 = _mtl_u._NumPasses;
    float i_4;
    half3 res_5;
    res_5 = tmpvar_2.xyz;
    i_4 = 0.0;
    while (true) {
      if ((i_4 >= 4.0)) {
        break;
      };
      if ((i_4 == (float)passes_3)) {
        break;
      };
      if ((i_4 == 0.0)) {
        half3 tmpvar_6;
        half val_7;
        val_7 = ((_mtl_u._ContrastShift.x * (half)3.0) + (half)12.0);
        half tmpvar_8;
        tmpvar_8 = pow ((cos(val_7) + (half)1.0), val_7);
        tmpvar_6 = ((res_5 - (half)0.5) * tmpvar_8);
        res_5 = tmpvar_6;
      } else {
        if ((i_4 == 1.0)) {
          half3 tmpvar_9;
          half val_10;
          val_10 = ((_mtl_u._SaturationShift.y * (half)3.0) + (half)12.0);
          half tmpvar_11;
          tmpvar_11 = pow ((cos(val_10) + (half)1.0), val_10);
          tmpvar_9 = ((res_5 - (half)0.5) * tmpvar_11);
          res_5 = tmpvar_9;
        } else {
          if ((i_4 == 2.0)) {
            half3 tmpvar_12;
            half val_13;
            val_13 = ((_mtl_u._HueShift.z * (half)3.0) + (half)12.0);
            half tmpvar_14;
            tmpvar_14 = pow ((cos(val_13) + (half)1.0), val_13);
            tmpvar_12 = ((res_5 - (half)0.5) * tmpvar_14);
            res_5 = tmpvar_12;
          } else {
            half3 tmpvar_15;
            half val_16;
            val_16 = ((_mtl_u._LuminosityShift.x * (half)3.0) + (half)12.0);
            half tmpvar_17;
            tmpvar_17 = pow ((cos(val_16) + (half)1.0), val_16);
            tmpvar_15 = ((res_5 - (half)0.5) * tmpvar_17);
            res_5 = tmpvar_15;
          };
        };
      };
      i_4 += 1.0;
    };
    t_1.xyz = res_5;
  };
  half4 tmpvar_18;
  tmpvar_18.w = half(1.0);
  tmpvar_18.xyz = t_1.xyz;
  _mtl_o._fragData = tmpvar_18;
  return _mtl_o;
}


// stats: 37 alu 1 tex 7 flow
// inputs: 1
//  #0: xlv_TEXCOORD0 (medium float) 2x1 [-1]
// uniforms: 5 (total size: 40)
//  #0: _NumPasses (medium float) 1x1 [-1] loc 0
//  #1: _ContrastShift (medium float) 4x1 [-1] loc 8
//  #2: _SaturationShift (medium float) 4x1 [-1] loc 16
//  #3: _HueShift (low float) 4x1 [-1] loc 24
//  #4: _LuminosityShift (low float) 4x1 [-1] loc 32
// textures: 1
//  #0: _MainTex (low 2d) 0x0 [-1] loc 0
