// problem with stalingrad smoke

cbuffer _Globals : register(b0)
{

  struct
  {
    float4 vPlane;
    float4 vSettings;
  } g_ClipPlane : packoffset(c0);

  float4 specColor : packoffset(c2);
  float4 ControlData : packoffset(c3);
  float4 difColor : packoffset(c4);
  float4 ambient : packoffset(c5);
  float4 lightCount : packoffset(c6);
  float4 g_avLightPos[4] : packoffset(c7);
  float4 g_avLightColor[4] : packoffset(c11);
  float4 g_avConeDir[4] : packoffset(c15);
  float4 g_vAmbientSettings : packoffset(c19);
  float4 g_vScreenDepthRect : packoffset(c20);
  float4x4 g_mViewProj : packoffset(c21);
  float4x4 g_mIView : packoffset(c25);
  float4x4 g_mWM : packoffset(c29);
  float4x4 g_mView : packoffset(c33);
  float4 g_vCamPos : packoffset(c37);
  float4 g_vDistortionDesc : packoffset(c38);
  float4 g_avPData[150] : packoffset(c39);

  struct
  {
    float4 vDesc;
    float4 vFogLayerPlane;
    float4 vFogLayerColor;
    float4 vFogLayerSettings;
    float4 vFogColor;
    float4 vFogDistance;
  } g_FogDesc : packoffset(c189);

  float4 ExPos[4] : packoffset(c195);
  float4 ExRad[4] : packoffset(c199);
  float4 g_vExVolumeSettings : packoffset(c203);
  float4 g_vExVolumeRect : packoffset(c204);
  float4 GrayK : packoffset(c205) = {0.333000004,0.333000004,0.333000004,0};
}



// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main( 
  float4 v0 : POSITION0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2,
  out float4 o4 : TEXCOORD3,
  out float2 o5 : TEXCOORD4,
  out float2 p5 : TEXCOORD5,
  out float4 o6 : COLOR0,
  out float4 o7 : COLOR1,
  out float4 o8 : COLOR2,
  out float4 o9 : COLOR3,
  out float o10 : SV_ClipDistance0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 stereo = StereoParams.Load(0);
  float4 tmp;
  
  r0.xy = float2(1,2) + v0.ww;
  r0.z = (uint)v0.w;
  r0.xy = (uint2)r0.xy;
  r1.xyz = g_avPData[r0.z].xyz;
  r1.w = 1;
  r2.x = dot(r1.xyzw, g_mWM._m00_m10_m20_m30);
  r2.y = dot(r1.xyzw, g_mWM._m01_m11_m21_m31);
  r2.z = dot(r1.xyzw, g_mWM._m02_m12_m22_m32);
  r1.xyz = g_avPData[r0.z].www * v0.xyz;
  r0.w = g_avPData[r0.x].x * r1.y;
  r3.x = r1.x * g_avPData[r0.x].y + -r0.w;
  r3.y = dot(r1.xy, g_avPData[r0.x].xy);
  r3.z = r1.z;
  
  r1.x = dot(r3.xyz, g_mIView._m00_m10_m20);
  r1.y = dot(r3.xyz, g_mIView._m01_m11_m21);
  r1.z = dot(r3.xyz, g_mIView._m02_m12_m22);
  r1.xyz = r1.xyz + r2.xyz;
  r1.w = 1;
  r3.x = dot(r1.xyzw, g_mViewProj._m00_m10_m20_m30);
  r3.y = dot(r1.xyzw, g_mViewProj._m01_m11_m21_m31);
  o0.z = dot(r1.xyzw, g_mViewProj._m02_m12_m22_m32);
  r3.w = dot(r1.xyzw, g_mViewProj._m03_m13_m23_m33);
tmp.xyzw = r3.xyzw;  
r3.x += (stereo.x * (r3.w - stereo.y));    

  r0.w = cmp(0.5 < g_ClipPlane.vSettings.x);
  if (r0.w != 0) {
    o10.x = dot(g_ClipPlane.vPlane.xyzw, r1.xyzw);
  } else {
    o10.x = 1;
  }
  r4.xy = r3.xy / r3.ww;
  r4.xy = float2(0.5,0.5) * r4.xy;
  r4.zw = r4.xy * float2(1,-1) + float2(0.5,0.5);  
  o5.xy = r4.zw * g_vExVolumeRect.zw + g_vExVolumeRect.xy;
  r4.zw = float2(0.5,0) + r4.xw;

  o4.xy = r4.zw * g_vScreenDepthRect.zw + g_vScreenDepthRect.xy;
  r0.z = g_avPData[r0.z].w * 0.5;
  r0.z = 1 / r0.z;
  r5.xy = saturate(v0.xy);
  r0.w = cmp(1.00100005 < g_vDistortionDesc.w);
  if (r0.w != 0) {
    r0.w = 1 / g_vDistortionDesc.w;
    r2.w = g_vDistortionDesc.w * g_vDistortionDesc.w + -1;
    r3.z = max(g_avPData[r0.x].w, 0);
    r2.w = min(r3.z, r2.w);
    r3.z = (int)r2.w;
    r2.w = trunc(r2.w);
    r2.w = r2.w * r0.w + 9.99999975e-005;
    r6.y = floor(r2.w);
    r2.w = (int)r6.y;
    r2.w = mad((int)-r2.w, (int)r3.z, (int)r3.z);
    r6.x = (int)r2.w;
    r5.z = 1 + -r5.y;
    r6.xy = r6.xy + r5.xz;
    r4.xy = r6.xy * r0.ww;
  } else {
    r5.w = 1 + -r5.y;
    r4.xy = r5.xw;
  }
  r6.xyz = -g_vCamPos.xyz + r1.xyz;
  r0.w = dot(r6.xyz, r6.xyz);
  r0.w = sqrt(r0.w);
  r0.w = g_FogDesc.vFogDistance.x * r0.w;
  r0.w = min(1, r0.w);
  r1.w = dot(r1.xyzw, g_FogDesc.vFogLayerPlane.xyzw);
  r1.xyz = g_vCamPos.xyz + -r1.xyz;
  r2.w = cmp(g_FogDesc.vDesc.z >= 0);
  if (r2.w != 0) {
    r2.w = cmp(r1.w < -g_FogDesc.vFogLayerSettings.y);
    if (r2.w != 0) {
      r1.w = -g_FogDesc.vFogLayerSettings.y;
    }
    r2.w = cmp(r1.w >= 0);
    if (r2.w != 0) {
      o2.w = 0;
      r2.w = 0;
      r3.z = -1;
    } else {
      r5.z = dot(r1.xyz, r1.xyz);
      r5.z = rsqrt(r5.z);
      r6.xyz = r5.zzz * r1.xyz;
      r5.z = dot(g_FogDesc.vFogLayerPlane.xyz, r6.xyz);
      r5.w = cmp(9.99999975e-005 < abs(r5.z));
      if (r5.w != 0) {
        r5.z = 1 / r5.z;
        r5.w = g_FogDesc.vDesc.z + -r1.w;
        r6.x = g_FogDesc.vDesc.z * r5.z;
        r2.w = r5.w * r5.z + -r6.x;
      } else {
        r2.w = 0;
      }
      r3.z = cmp(r2.w < 9.99999975e-005);
      if (r3.z != 0) {
        o2.w = 0;
      }
    }
    if (r3.z == 0) {
      r2.w = g_FogDesc.vFogLayerSettings.x * r2.w;
      r2.w = 1.44254541 * r2.w;
      r2.w = exp2(r2.w);
      r2.w = 1 / r2.w;
      o2.w = 1 + -r2.w;
    }
  } else {
    r1.w = cmp(r1.w >= 0);
    if (r1.w != 0) {
      r1.w = dot(r1.xyz, r1.xyz);
      r1.w = rsqrt(r1.w);
      r6.xyz = r1.xyz * r1.www;
      r1.w = dot(g_FogDesc.vFogLayerPlane.xyz, r6.xyz);
      r2.w = cmp(9.99999975e-005 < abs(r1.w));
      if (r2.w != 0) {
        r1.w = g_FogDesc.vDesc.z / r1.w;
      }
      r2.w = cmp(r1.w < 9.99999975e-005);
      if (r2.w != 0) {
        o2.w = 0;
      }
    } else {
      r1.x = dot(r1.xyz, r1.xyz);
      r1.w = sqrt(r1.x);
      r2.w = 0;
    }
    if (r2.w == 0) {
      r1.x = g_FogDesc.vFogLayerSettings.x * r1.w;
      r1.x = 1.44254541 * r1.x;
      r1.x = exp2(r1.x);
      r1.x = 1 / r1.x;
      r1.x = -1 + r1.x;
      o2.w = -r1.x;
    }
  }
  r1.x = dot(g_FogDesc.vFogColor.xyz, float3(1,1,1));
  r1.x = cmp(0.00100000005 < r1.x);
  r1.y = cmp(r0.w < g_FogDesc.vDesc.x);
  if (r1.y != 0) {
    r1.y = g_FogDesc.vDesc.y * r0.w;
    r1.y = r1.y / g_FogDesc.vDesc.x;
  } else {
    r1.zw = float2(1,1) + -g_FogDesc.vDesc.yx;
    r2.w = -g_FogDesc.vDesc.x + r0.w;
    r1.z = r2.w * r1.z;
    r1.z = r1.z / r1.w;
    r1.y = g_FogDesc.vDesc.y + r1.z;
  }
  r1.yzw = g_FogDesc.vFogColor.xyz * r1.yyy;
  r1.yzw = log2(r1.yzw);
  r1.yzw = g_FogDesc.vFogColor.www * r1.yzw;
  r1.yzw = exp2(r1.yzw);
  r1.yzw = float3(-1.44269502,-1.44269502,-1.44269502) * r1.yzw;
  r1.yzw = exp2(r1.yzw);
  r1.yzw = float3(1,1,1) + -r1.yzw;
  r2.w = cmp(0.800000012 < r0.w);
  r1.x = r1.x ? r2.w : 0;
  if (r1.x != 0) {
    r0.w = -0.800000012 + r0.w;
    r0.w = 5 * r0.w;
    r6.xyz = float3(1,1,1) + -r1.yzw;
    r1.yzw = r0.www * r6.xyz + r1.yzw;
  }
  r0.w = -0.25 + g_FogDesc.vFogDistance.w;
  r0.w = r0.w + r0.w;
  r1.x = dot(r1.yzw, float3(0.333299994,0.333299994,0.333299994));
  r6.xyz = r1.xxx + -r1.yzw;
  o2.xyz = r0.www * r6.xyz + r1.yzw;
  r0.w = min(4, lightCount.x);
  r0.w = (int)r0.w;
  r1.xyzw = float4(0,0,0,0);
  r6.xyzw = float4(0,0,0,0);
  r7.xyzw = float4(0,0,0,0);
  r8.xyzw = float4(0,0,0,0);
  r2.w = 0;
  while (true) {
    r3.z = cmp((int)r2.w >= (int)r0.w);
    if (r3.z != 0) break;
    r3.z = cmp(1 < g_avLightPos[r2.w].w);
    if (r3.z != 0) {
      r9.xyz = g_avLightPos[r2.w].xyz + -r2.xyz;
      r3.z = dot(r9.xyz, r9.xyz);
      r5.z = sqrt(r3.z);
      r9.xyz = r9.xyz / r5.zzz;
      r3.z = r3.z * g_avLightColor[r2.w].w + 1;
      r3.z = 1 / r3.z;
      r3.z = -0.100000001 + r3.z;
      r10.w = saturate(1.11111116 * r3.z);
      r3.z = cmp(2 < g_avLightPos[r2.w].w);
      if (r3.z != 0) {
        r3.z = g_avLightPos[r2.w].w + -3;
        r5.z = dot(r9.xyz, g_avConeDir[r2.w].xyz);
        r5.w = 1 + -abs(r5.z);
        r5.w = sqrt(r5.w);
        r9.w = abs(r5.z) * -0.0187292993 + 0.0742610022;
        r9.w = r9.w * abs(r5.z) + -0.212114394;
        r9.w = r9.w * abs(r5.z) + 1.57072878;
        r11.x = r9.w * r5.w;
        r11.x = r11.x * -2 + 3.14159274;
        r5.z = cmp(r5.z < -r5.z);
        r5.z = r5.z ? r11.x : 0;
        r5.z = r9.w * r5.w + r5.z;
        r5.w = cmp(r5.z < r3.z);
        if (r5.w != 0) {
          r5.w = frac(g_avConeDir[r2.w].w);
          r3.z = r5.z / r3.z;
          r3.z = r3.z + -r5.w;
          r5.z = 1 + -r5.w;
          r3.z = saturate(r3.z / r5.z);
          r3.z = 1 + -r3.z;
        } else {
          r3.z = 0;
        }
        r10.w = r10.w * r3.z;
      }
    } else {
      r9.xyz = -g_avLightPos[r2.w].xyz;
      r10.w = 1;
    }
    r3.z = dot(r9.xyz, g_mView._m00_m10_m20);
    r5.z = dot(r9.xyz, g_mView._m01_m11_m21);
    r9.z = dot(r9.xyz, g_mView._m02_m12_m22);
    r5.zw = g_avPData[r0.x].xy * r5.zz;
    r9.x = r3.z * g_avPData[r0.x].y + r5.z;
    r9.y = -r3.z * g_avPData[r0.x].x + r5.w;
    r10.xyz = r9.xyz * float3(0.5,0.5,-0.5) + float3(0.5,0.5,0.5);
    if (r2.w == 0) {
      r1.xyzw = r10.xyzw;
    } else {
      r3.z = cmp((int)r2.w == 1);
      if (r3.z != 0) {
        r6.xyzw = r10.xyzw;
      } else {
        r3.z = cmp((int)r2.w == 2);
        if (r3.z != 0) {
          r7.xyzw = r10.xyzw;
        } else {
          r8.xyzw = r10.xyzw;
        }
      }
    }
    r2.w = (int)r2.w + 1;
  }
  o6.xyzw = r1.xyzw;
  o7.xyzw = r6.xyzw;
  o8.xyzw = r7.xyzw;
  o9.xyzw = r8.xyzw;
  r1.xyz = g_vCamPos.xyz + -r2.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = sqrt(r0.w);
  r1.x = -ExPos[0].y + r2.y;
  r1.x = saturate(-r1.x * ExPos[0].x + 1);
  r0.w = 0.00499999989 * r0.w;
  r0.w = min(1, r0.w);
  r1.x = -1 + r1.x;
  r0.w = r0.w * r1.x + 1;
  r0.x = g_avPData[r0.x].z * r0.w;
  r0.w = saturate(r3.w * r0.z);
  o3.w = r0.x * r0.w;
  tmp.z = r3.z;
  // o0.xyw = r3.xyw;
  o0.xyw = tmp.xyw;
  o1.xyzw = r4.xyzw;
  o3.xyz = g_avPData[r0.y].xyz;
  o4.z = r3.w;
  o4.w = r0.z;
  p5.xy = r5.xy * float2(1,-1) + float2(0,1);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.57 on Sun Jun 18 15:52:55 2017
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   struct
//   {
//       
//       float4 vPlane;                 // Offset:    0
//       float4 vSettings;              // Offset:   16
//
//   } g_ClipPlane;                     // Offset:    0 Size:    32
//   float4 specColor;                  // Offset:   32 Size:    16 [unused]
//   float4 ControlData;                // Offset:   48 Size:    16 [unused]
//   float4 difColor;                   // Offset:   64 Size:    16 [unused]
//   float4 ambient;                    // Offset:   80 Size:    16 [unused]
//   float4 lightCount;                 // Offset:   96 Size:    16
//   float4 g_avLightPos[4];            // Offset:  112 Size:    64
//   float4 g_avLightColor[4];          // Offset:  176 Size:    64
//   float4 g_avConeDir[4];             // Offset:  240 Size:    64
//   float4 g_vAmbientSettings;         // Offset:  304 Size:    16 [unused]
//   float4 g_vScreenDepthRect;         // Offset:  320 Size:    16
//   float4x4 g_mViewProj;              // Offset:  336 Size:    64
//   float4x4 g_mIView;                 // Offset:  400 Size:    64
//   float4x4 g_mWM;                    // Offset:  464 Size:    64
//   float4x4 g_mView;                  // Offset:  528 Size:    64
//   float4 g_vCamPos;                  // Offset:  592 Size:    16
//   float4 g_vDistortionDesc;          // Offset:  608 Size:    16
//   float4 g_avPData[150];             // Offset:  624 Size:  2400
//   
//   struct
//   {
//       
//       float4 vDesc;                  // Offset: 3024
//       float4 vFogLayerPlane;         // Offset: 3040
//       float4 vFogLayerColor;         // Offset: 3056
//       float4 vFogLayerSettings;      // Offset: 3072
//       float4 vFogColor;              // Offset: 3088
//       float4 vFogDistance;           // Offset: 3104
//
//   } g_FogDesc;                       // Offset: 3024 Size:    96
//   float4 ExPos[4];                   // Offset: 3120 Size:    64
//   float4 ExRad[4];                   // Offset: 3184 Size:    64 [unused]
//   float4 g_vExVolumeSettings;        // Offset: 3248 Size:    16 [unused]
//   float4 g_vExVolumeRect;            // Offset: 3264 Size:    16
//   float4 GrayK;                      // Offset: 3280 Size:    16 [unused]
//      = 0x3eaa7efa 0x3eaa7efa 0x3eaa7efa 0x00000000 
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xy          5     NONE   float   xy  
// TEXCOORD                 5     zw        5     NONE   float     zw
// COLOR                    0   xyzw        6     NONE   float   xyzw
// COLOR                    1   xyzw        7     NONE   float   xyzw
// COLOR                    2   xyzw        8     NONE   float   xyzw
// COLOR                    3   xyzw        9     NONE   float   xyzw
// SV_ClipDistance          0   x          10  CLIPDST   float   x   
//
vs_4_0
dcl_constantbuffer cb0[205], dynamicIndexed
dcl_input v0.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_output o5.xy
dcl_output o5.zw
dcl_output o6.xyzw
dcl_output o7.xyzw
dcl_output o8.xyzw
dcl_output o9.xyzw
dcl_output_siv o10.x, clip_distance
dcl_temps 12
add r0.xy, v0.wwww, l(1.000000, 2.000000, 0.000000, 0.000000)
ftou r0.z, v0.w
ftou r0.xy, r0.xyxx
mov r1.xyz, cb0[r0.z + 39].xyzx
mov r1.w, l(1.000000)
dp4 r2.x, r1.xyzw, cb0[29].xyzw
dp4 r2.y, r1.xyzw, cb0[30].xyzw
dp4 r2.z, r1.xyzw, cb0[31].xyzw
mul r1.xyz, v0.xyzx, cb0[r0.z + 39].wwww
mul r0.w, r1.y, cb0[r0.x + 39].x
mad r3.x, r1.x, cb0[r0.x + 39].y, -r0.w
dp2 r3.y, r1.xyxx, cb0[r0.x + 39].xyxx
mov r3.z, r1.z
dp3 r1.x, r3.xyzx, cb0[25].xyzx
dp3 r1.y, r3.xyzx, cb0[26].xyzx
dp3 r1.z, r3.xyzx, cb0[27].xyzx
add r1.xyz, r2.xyzx, r1.xyzx
mov r1.w, l(1.000000)
dp4 r3.x, r1.xyzw, cb0[21].xyzw
dp4 r3.y, r1.xyzw, cb0[22].xyzw
dp4 o0.z, r1.xyzw, cb0[23].xyzw
dp4 r3.w, r1.xyzw, cb0[24].xyzw
lt r0.w, l(0.500000), cb0[1].x
if_nz r0.w
  dp4 o10.x, cb0[0].xyzw, r1.xyzw
else 
  mov o10.x, l(1.000000)
endif 
div r4.xy, r3.xyxx, r3.wwww
mul r4.xy, r4.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
mad r4.zw, r4.xxxy, l(0.000000, 0.000000, 1.000000, -1.000000), l(0.000000, 0.000000, 0.500000, 0.500000)
mad o5.xy, r4.zwzz, cb0[204].zwzz, cb0[204].xyxx
add r4.zw, r4.xxxw, l(0.000000, 0.000000, 0.500000, 0.000000)
mad o4.xy, r4.zwzz, cb0[20].zwzz, cb0[20].xyxx
mul r0.z, l(0.500000), cb0[r0.z + 39].w
div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
mov_sat r5.xy, v0.xyxx
lt r0.w, l(1.001000), cb0[38].w
if_nz r0.w
  div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[38].w
  mad r2.w, cb0[38].w, cb0[38].w, l(-1.000000)
  max r3.z, l(0.000000), cb0[r0.x + 39].w
  min r2.w, r2.w, r3.z
  ftoi r3.z, r2.w
  round_z r2.w, r2.w
  mad r2.w, r2.w, r0.w, l(0.000100)
  round_ni r6.y, r2.w
  ftoi r2.w, r6.y
  imad r2.w, -r2.w, r3.z, r3.z
  itof r6.x, r2.w
  add r5.z, -r5.y, l(1.000000)
  add r6.xy, r5.xzxx, r6.xyxx
  mul r4.xy, r0.wwww, r6.xyxx
else 
  add r5.w, -r5.y, l(1.000000)
  mov r4.xy, r5.xwxx
endif 
add r6.xyz, r1.xyzx, -cb0[37].xyzx
dp3 r0.w, r6.xyzx, r6.xyzx
sqrt r0.w, r0.w
mul r0.w, r0.w, cb0[194].x
min r0.w, r0.w, l(1.000000)
dp4 r1.w, r1.xyzw, cb0[190].xyzw
add r1.xyz, -r1.xyzx, cb0[37].xyzx
ge r2.w, cb0[189].z, l(0.000000)
if_nz r2.w
  lt r2.w, r1.w, -cb0[192].y
  if_nz r2.w
    mov r1.w, -cb0[192].y
  endif 
  ge r2.w, r1.w, l(0.000000)
  if_nz r2.w
    mov o2.w, l(0)
    mov r2.w, l(0)
    mov r3.z, l(-1)
  else 
    dp3 r5.z, r1.xyzx, r1.xyzx
    rsq r5.z, r5.z
    mul r6.xyz, r1.xyzx, r5.zzzz
    dp3 r5.z, cb0[190].xyzx, r6.xyzx
    lt r5.w, l(0.000100), |r5.z|
    if_nz r5.w
      div r5.z, l(1.000000, 1.000000, 1.000000, 1.000000), r5.z
      add r5.w, -r1.w, cb0[189].z
      mul r6.x, r5.z, cb0[189].z
      mad r2.w, r5.w, r5.z, -r6.x
    else 
      mov r2.w, l(0)
    endif 
    lt r3.z, r2.w, l(0.000100)
    if_nz r3.z
      mov o2.w, l(0)
    endif 
  endif 
  if_z r3.z
    mul r2.w, r2.w, cb0[192].x
    mul r2.w, r2.w, l(1.44254541)
    exp r2.w, r2.w
    div r2.w, l(1.000000, 1.000000, 1.000000, 1.000000), r2.w
    add o2.w, -r2.w, l(1.000000)
  endif 
else 
  ge r1.w, r1.w, l(0.000000)
  if_nz r1.w
    dp3 r1.w, r1.xyzx, r1.xyzx
    rsq r1.w, r1.w
    mul r6.xyz, r1.wwww, r1.xyzx
    dp3 r1.w, cb0[190].xyzx, r6.xyzx
    lt r2.w, l(0.000100), |r1.w|
    if_nz r2.w
      div r1.w, cb0[189].z, r1.w
    endif 
    lt r2.w, r1.w, l(0.000100)
    if_nz r2.w
      mov o2.w, l(0)
    endif 
  else 
    dp3 r1.x, r1.xyzx, r1.xyzx
    sqrt r1.w, r1.x
    mov r2.w, l(0)
  endif 
  if_z r2.w
    mul r1.x, r1.w, cb0[192].x
    mul r1.x, r1.x, l(1.44254541)
    exp r1.x, r1.x
    div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), r1.x
    add r1.x, r1.x, l(-1.000000)
    mov o2.w, -r1.x
  endif 
endif 
dp3 r1.x, cb0[193].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
lt r1.x, l(0.001000), r1.x
lt r1.y, r0.w, cb0[189].x
if_nz r1.y
  mul r1.y, r0.w, cb0[189].y
  div r1.y, r1.y, cb0[189].x
else 
  add r1.zw, -cb0[189].yyyx, l(0.000000, 0.000000, 1.000000, 1.000000)
  add r2.w, r0.w, -cb0[189].x
  mul r1.z, r1.z, r2.w
  div r1.z, r1.z, r1.w
  add r1.y, r1.z, cb0[189].y
endif 
mul r1.yzw, r1.yyyy, cb0[193].xxyz
log r1.yzw, r1.yyzw
mul r1.yzw, r1.yyzw, cb0[193].wwww
exp r1.yzw, r1.yyzw
mul r1.yzw, r1.yyzw, l(0.000000, -1.442695, -1.442695, -1.442695)
exp r1.yzw, r1.yyzw
add r1.yzw, -r1.yyzw, l(0.000000, 1.000000, 1.000000, 1.000000)
lt r2.w, l(0.800000), r0.w
and r1.x, r1.x, r2.w
if_nz r1.x
  add r0.w, r0.w, l(-0.800000)
  mul r0.w, r0.w, l(5.000000)
  add r6.xyz, -r1.yzwy, l(1.000000, 1.000000, 1.000000, 0.000000)
  mad r1.yzw, r0.wwww, r6.xxyz, r1.yyzw
endif 
add r0.w, cb0[194].w, l(-0.250000)
add r0.w, r0.w, r0.w
dp3 r1.x, r1.yzwy, l(0.333300, 0.333300, 0.333300, 0.000000)
add r6.xyz, -r1.yzwy, r1.xxxx
mad o2.xyz, r0.wwww, r6.xyzx, r1.yzwy
min r0.w, cb0[6].x, l(4.000000)
ftoi r0.w, r0.w
mov r1.xyzw, l(0,0,0,0)
mov r6.xyzw, l(0,0,0,0)
mov r7.xyzw, l(0,0,0,0)
mov r8.xyzw, l(0,0,0,0)
mov r2.w, l(0)
loop 
  ige r3.z, r2.w, r0.w
  breakc_nz r3.z
  lt r3.z, l(1.000000), cb0[r2.w + 7].w
  if_nz r3.z
    add r9.xyz, -r2.xyzx, cb0[r2.w + 7].xyzx
    dp3 r3.z, r9.xyzx, r9.xyzx
    sqrt r5.z, r3.z
    div r9.xyz, r9.xyzx, r5.zzzz
    mad r3.z, r3.z, cb0[r2.w + 11].w, l(1.000000)
    div r3.z, l(1.000000, 1.000000, 1.000000, 1.000000), r3.z
    add r3.z, r3.z, l(-0.100000)
    mul_sat r10.w, r3.z, l(1.11111116)
    lt r3.z, l(2.000000), cb0[r2.w + 7].w
    if_nz r3.z
      add r3.z, l(-3.000000), cb0[r2.w + 7].w
      dp3 r5.z, r9.xyzx, cb0[r2.w + 15].xyzx
      add r5.w, -|r5.z|, l(1.000000)
      sqrt r5.w, r5.w
      mad r9.w, |r5.z|, l(-0.0187292993), l(0.074261)
      mad r9.w, r9.w, |r5.z|, l(-0.212114394)
      mad r9.w, r9.w, |r5.z|, l(1.57072878)
      mul r11.x, r5.w, r9.w
      mad r11.x, r11.x, l(-2.000000), l(3.14159274)
      lt r5.z, r5.z, -r5.z
      and r5.z, r5.z, r11.x
      mad r5.z, r9.w, r5.w, r5.z
      lt r5.w, r5.z, r3.z
      if_nz r5.w
        frc r5.w, cb0[r2.w + 15].w
        div r3.z, r5.z, r3.z
        add r3.z, -r5.w, r3.z
        add r5.z, -r5.w, l(1.000000)
        div_sat r3.z, r3.z, r5.z
        add r3.z, -r3.z, l(1.000000)
      else 
        mov r3.z, l(0)
      endif 
      mul r10.w, r3.z, r10.w
    endif 
  else 
    mov r9.xyz, -cb0[r2.w + 7].xyzx
    mov r10.w, l(1.000000)
  endif 
  dp3 r3.z, r9.xyzx, cb0[33].xyzx
  dp3 r5.z, r9.xyzx, cb0[34].xyzx
  dp3 r9.z, r9.xyzx, cb0[35].xyzx
  mul r5.zw, r5.zzzz, cb0[r0.x + 39].xxxy
  mad r9.x, r3.z, cb0[r0.x + 39].y, r5.z
  mad r9.y, -r3.z, cb0[r0.x + 39].x, r5.w
  mad r10.xyz, r9.xyzx, l(0.500000, 0.500000, -0.500000, 0.000000), l(0.500000, 0.500000, 0.500000, 0.000000)
  if_z r2.w
    mov r1.xyzw, r10.xyzw
  else 
    ieq r3.z, r2.w, l(1)
    if_nz r3.z
      mov r6.xyzw, r10.xyzw
    else 
      ieq r3.z, r2.w, l(2)
      if_nz r3.z
        mov r7.xyzw, r10.xyzw
      else 
        mov r8.xyzw, r10.xyzw
      endif 
    endif 
  endif 
  iadd r2.w, r2.w, l(1)
endloop 
mov o6.xyzw, r1.xyzw
mov o7.xyzw, r6.xyzw
mov o8.xyzw, r7.xyzw
mov o9.xyzw, r8.xyzw
add r1.xyz, -r2.xyzx, cb0[37].xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
sqrt r0.w, r0.w
add r1.x, r2.y, -cb0[195].y
mad_sat r1.x, -r1.x, cb0[195].x, l(1.000000)
mul r0.w, r0.w, l(0.005000)
min r0.w, r0.w, l(1.000000)
add r1.x, r1.x, l(-1.000000)
mad r0.w, r0.w, r1.x, l(1.000000)
mul r0.x, r0.w, cb0[r0.x + 39].z
mul_sat r0.w, r0.z, r3.w
mul o3.w, r0.w, r0.x
mov o0.xyw, r3.xyxw
mov o1.xyzw, r4.xyzw
mov o3.xyz, cb0[r0.y + 39].xyzx
mov o4.z, r3.w
mov o4.w, r0.z
mad o5.zw, r5.xxxy, l(0.000000, 0.000000, 1.000000, -1.000000), l(0.000000, 0.000000, 0.000000, 1.000000)
ret 
// Approximately 261 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
