#include <metal_stdlib>
#pragma clang diagnostic ignored "-Wparentheses-equality"
using namespace metal;
struct xlatMtlShaderInput {
  float2 xlv_TEXCOORD0;
};
struct xlatMtlShaderOutput {
  half4 _glesFragData_0 [[color(0)]];
};
struct xlatMtlShaderUniform {
  float _RangeScale;
};
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
  ,   texture2d<half> _MainTex [[texture(0)]], sampler _mtlsmp__MainTex [[sampler(0)]]
  ,   texture2d<half> _Curve [[texture(1)]], sampler _mtlsmp__Curve [[sampler(1)]])
{
  xlatMtlShaderOutput _mtl_o;
  float newLum_1;
  float3 cie_2;
  float4 color_3;
  half4 tmpvar_4;
  tmpvar_4 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0));
  color_3 = float4(tmpvar_4);
  float3 Yxy_5;
  float3 tmpvar_6;
  tmpvar_6 = (float3x3(float3(0.514136, 0.265068, 0.0241188), float3(0.323879, 0.670234, 0.122818), float3(0.160364, 0.0640916, 0.844427)) * color_3.xyz);
  Yxy_5.x = tmpvar_6.y;
  Yxy_5.yz = (tmpvar_6.xy / dot (float3(1.0, 1.0, 1.0), tmpvar_6));
  cie_2.yz = Yxy_5.yz;
  float2 tmpvar_7;
  tmpvar_7.y = 0.5;
  tmpvar_7.x = (tmpvar_6.y * _mtl_u._RangeScale);
  half tmpvar_8;
  tmpvar_8 = _Curve.sample(_mtlsmp__Curve, (float2)(tmpvar_7)).x;
  newLum_1 = float(tmpvar_8);
  cie_2.x = newLum_1;
  float3 XYZ_9;
  XYZ_9.x = ((newLum_1 * Yxy_5.y) / Yxy_5.z);
  XYZ_9.y = cie_2.x;
  XYZ_9.z = ((newLum_1 * (
    (1.0 - Yxy_5.y)
   - Yxy_5.z)) / Yxy_5.z);
  color_3.xyz = (float3x3(float3(2.5651, -1.0217, 0.0753), float3(-1.1665, 1.9777, -0.2543), float3(-0.3986, 0.0439, 1.1892)) * XYZ_9);
  _mtl_o._glesFragData_0 = half4(color_3);
  return _mtl_o;
}


// stats: 12 alu 2 tex 0 flow
// inputs: 1
//  #0: xlv_TEXCOORD0 (high float) 2x1 [-1]
// uniforms: 1 (total size: 4)
//  #0: _RangeScale (high float) 1x1 [-1] loc 0
// textures: 2
//  #0: _MainTex (low 2d) 0x0 [-1] loc 0
//  #1: _Curve (low 2d) 0x0 [-1] loc 1
