// Some Light Shafts!

cbuffer SceneBuffer : register(b0)
{
  float4x4 g_View : packoffset(c0);
  float4x4 g_Proj : packoffset(c4);
  float4x4 g_ViewProjection : packoffset(c8);
  float4x4 g_ViewInverseMatrix : packoffset(c12);
}

cbuffer HPixel_Buffer : register(b12)
{
  float4 g_TargetUvParam : packoffset(c0);
}

cbuffer CamParam_HPixel_Buffer : register(b13)
{
  float4 g_CameraParam : packoffset(c0);
  float4 g_CameraVec : packoffset(c1);
}

cbuffer ShadowView_Buffer : register(b10)
{
  float4 g_ShadowFarInv : packoffset(c0);
  float4 g_DepthOffset : packoffset(c1);
  float4 g_BokeOffset : packoffset(c2);
  float4x4 g_ShadowView : packoffset(c3);
  float4x4 g_ShadowViewProj[4] : packoffset(c7);
}

cbuffer CB : register(b8)
{
  float4 LightPos[4] : packoffset(c0);
  float4 LightDir[4] : packoffset(c4);
  float4 LightColor[4] : packoffset(c8);
  float4 AttnParam[4] : packoffset(c12);
  float4 Num_Far_Step2 : packoffset(c16);
  float4 ScatterParam : packoffset(c17);
}

SamplerState g_Z_TexSampler_s : register(s6);
SamplerState g_Shadow_TexSampler_s : register(s11);
Texture2D<float4> g_Z_Tex : register(t6);
Texture2D<float4> g_Shadow_Tex : register(t11);


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


void main( 
  float4 v0 : SV_POSITION0,
  float2 v1 : TEXCOORD0,
  out float3 o0 : SV_Target0,
  out float4 o1 : SV_Target1,
  out float4 o2 : SV_Target2)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 x0[16];
  r0.xy = float2(0.25,0.25) / g_TargetUvParam.zw;
  r0.xy = v1.xy + -r0.xy;
  r0.z = r0.x * 2 + -1;
  r1.x = r0.z / g_Proj._m00;
  r0.z = r0.y * -2 + 1;
  r1.y = r0.z / g_Proj._m11;
  r0.z = g_Z_Tex.Sample(g_Z_TexSampler_s, r0.xy).x;
  r0.z = r0.z * g_CameraParam.y + g_CameraParam.x;
  r0.z = min(Num_Far_Step2.y, r0.z);
  r1.xy = r1.xy * r0.zz;
  r1.z = -r0.z;
  r1.w = 1;
  
  float4 stereo = StereoParams.Load(0);
  r1.x += stereo.x * (r1.z + stereo.y) * g_Proj._m11;
  
  r2.x = dot(r1.xyzw, g_ViewInverseMatrix._m00_m10_m20_m30);
  r2.y = dot(r1.xyzw, g_ViewInverseMatrix._m01_m11_m21_m31);
  r2.z = dot(r1.xyzw, g_ViewInverseMatrix._m02_m12_m22_m32);
  r1.xyz = -g_CameraVec.xyz + r2.xyz;
  r2.x = dot(r1.xyz, r1.xyz);
  r0.w = (uint)Num_Far_Step2.x;
  x0[0].x = 0;
  x0[1].x = 0.5;
  x0[2].x = 0.125;
  x0[3].x = 0.625;
  x0[4].x = 0.75;
  x0[5].x = 0.25;
  x0[6].x = 0.875;
  x0[7].x = 0.375;
  x0[8].x = 0.1875;
  x0[9].x = 0.6875;
  x0[10].x = 0.0625;
  x0[11].x = 0.5625;
  x0[12].x = 0.9375;
  x0[13].x = 0.4375;
  x0[14].x = 0.8125;
  x0[15].x = 0.3125;
  r0.xy = g_TargetUvParam.zw * r0.xy;
  r0.xy = (int2)r0.xy;
  bitmask.y = ((~(-1 << 2)) << 2) & 0xffffffff;  r0.y = (((uint)r0.y << 2) & bitmask.y) | ((uint)0 & ~bitmask.y);
  bitmask.x = ((~(-1 << 2)) << 0) & 0xffffffff;  r0.x = (((uint)r0.x << 0) & bitmask.x) | ((uint)r0.y & ~bitmask.x);
  r0.x = x0[r0.x+0].x;
  r0.y = rsqrt(r2.x);
  r3.xyz = r1.xyz * r0.yyy;
  r0.y = 1 / Num_Far_Step2.y;
  r1.w = Num_Far_Step2.w + -Num_Far_Step2.z;
  r4.yz = float2(1,0);
  r5.w = 1;
  r6.xyzw = float4(0,0,0,0);
  r7.xyzw = float4(0,0,0,0);
  r8.xyz = float3(0,0,0);
  r2.w = 0;
  while (true) {
    r3.w = cmp((uint)r2.w >= (uint)r0.w);
    if (r3.w != 0) break;
    r9.xyz = -LightPos[r2.w].xyz + g_CameraVec.xyz;
    r10.x = dot(r1.xyz, LightDir[r2.w].xyz);
    r10.y = dot(r9.xyz, LightDir[r2.w].xyz);
    r2.y = dot(r9.xyz, r1.xyz);
    r2.z = dot(r9.xyz, r9.xyz);
    r3.w = LightDir[r2.w].w * LightDir[r2.w].w;
    r11.xyz = r3.www * r2.xyz;
    r10.xzw = r10.xxy * r10.xyy + -r11.xyz;
    r2.y = cmp(abs(r10.x) < 1.1920929e-007);
    if (r2.y != 0) {
      r2.y = (int)r2.w + 1;
      r2.w = r2.y;
      continue;
    } else {
      r2.y = r2.w;
    }
    r3.w = r10.x * r10.w;
    r3.w = r10.z * r10.z + -r3.w;
    r8.w = cmp(r3.w < 1.1920929e-007);
    if (r8.w != 0) {
      r8.w = (int)r2.y + 1;
      r2.w = r8.w;
      continue;
    }
    r3.w = sqrt(r3.w);
    r8.w = 1 / r10.x;
    r9.w = cmp(0 < r8.w);
    r10.x = cmp(r8.w < 0);
    r9.w = (int)r10.x + (int)-r9.w;
    r9.w = (int)r9.w;
    r2.z = sqrt(r2.z);
    r2.z = LightDir[r2.w].w * r2.z;
    r2.z = cmp(r2.z < r10.y);
    r10.x = -r9.w * r3.w + -r10.z;
    r10.x = r10.x * r8.w;
    r10.w = cmp(r10.x < 0);
    r3.w = r9.w * r3.w + -r10.z;
    r4.x = r3.w * r8.w;
    r3.w = r10.w ? r4.x : r10.x;
    r8.w = cmp(0 < r3.w);
    r9.w = cmp(r3.w < 1);
    r8.w = r8.w ? r9.w : 0;
    r4.w = r8.w ? r3.w : 1;
    r3.w = cmp(0 < r10.x);
    r11.xyz = r10.xxx * r1.xyz + r9.xyz;
    r8.w = dot(r11.xyz, LightDir[r2.w].xyz);
    r8.w = cmp(0 < r8.w);
    r3.w = r3.w ? r8.w : 0;
    r10.y = min(1, r4.x);
    r9.xyz = r4.xxx * r1.xyz + r9.xyz;
    r8.w = dot(r9.xyz, LightDir[r2.w].xyz);
    r8.w = cmp(0 < r8.w);
    r9.xy = r8.ww ? r4.xy : float2(-1,0);
    r9.xy = r3.ww ? r10.xy : r9.xy;
    r4.xw = r2.zz ? r4.zw : r9.xy;
    r2.z = cmp(r4.x >= 0);
    r3.w = cmp(r4.x < 1);
    r2.z = r2.z ? r3.w : 0;
    if (r2.z != 0) {
      r4.xw = r4.xw * r0.zz;
      r2.z = r4.x * r0.y;
      r2.z = r2.z * r1.w + Num_Far_Step2.z;
      r3.w = r2.z * r0.x + r4.x;
      r8.w = (int)r2.y & 1;
      r9.x = (uint)r2.y >> 1;
      r10.x = (uint)r8.w;
      r10.y = (uint)r9.x;
      r9.xy = r10.xy * float2(0.5,0.5) + float2(0.25,0.25);
      r8.w = (uint)r2.y << 2;
      r10.xyzw = float4(0,0,0,0);
      r11.xyzw = float4(0,0,0,0);
      r9.z = r4.x;
      r9.w = r2.z;
      r12.x = r3.w;
      r12.y = 0;
      while (true) {
        r12.z = cmp(r12.x >= r4.w);
        if (r12.z != 0) break;
        r5.xyz = r12.xxx * r3.xyz + g_CameraVec.xyz;
        r13.x = dot(r5.xyzw, g_ShadowViewProj[r8.w/4]._m00_m10_m20_m30);
        r13.y = dot(r5.xyzw, g_ShadowViewProj[r8.w/4]._m01_m11_m21_m31);
        r13.z = dot(r5.xyzw, g_ShadowViewProj[r8.w/4]._m02_m12_m22_m32);
        r12.z = dot(r5.xyzw, g_ShadowViewProj[r8.w/4]._m03_m13_m23_m33);
        r13.xyz = r13.xyz / r12.zzz;
        r12.zw = r13.xy * float2(0.25,-0.25) + r9.xy;
        r12.z = g_Shadow_Tex.SampleLevel(g_Shadow_TexSampler_s, r12.zw, 0).x;
        r12.z = cmp(r13.z < r12.z);
        if (r12.z != 0) {
          r5.xyz = -LightPos[r2.w].xyz + r5.xyz;
          r12.z = dot(r5.xyz, r5.xyz);
          r12.z = sqrt(r12.z);
          r5.xyz = r5.xyz / r12.zzz;
          r12.w = dot(r5.xyz, r3.xyz);
          r12.w = ScatterParam.z * r12.w + ScatterParam.y;
          r12.w = log2(abs(r12.w));
          r12.w = 1.5 * r12.w;
          r12.w = exp2(r12.w);
          r12.w = ScatterParam.x / r12.w;
          r5.x = dot(r5.xyz, LightDir[r2.w].xyz);
          r5.y = 1 + -abs(r5.x);
          r5.y = sqrt(r5.y);
          r5.z = abs(r5.x) * -0.0187292993 + 0.0742610022;
          r5.z = r5.z * abs(r5.x) + -0.212114394;
          r5.z = r5.z * abs(r5.x) + 1.57072878;
          r13.x = r5.z * r5.y;
          r13.x = r13.x * -2 + 3.14159274;
          r5.x = cmp(r5.x < -r5.x);
          r5.x = r5.x ? r13.x : 0;
          r5.x = r5.z * r5.y + r5.x;
          r5.x = saturate(AttnParam[r2.y].x * r5.x + AttnParam[r2.y].y);
          r5.y = saturate(AttnParam[r2.y].z * r12.z + AttnParam[r2.y].w);
          r5.z = r12.w * r9.w;
          r5.x = r5.z * r5.x;
          r5.y = r5.y * r5.y;
          r5.z = r5.x * r5.y;
          r12.y = r5.x * r5.y + r12.y;
          r5.x = sqrt(r12.x);
          r13.xyzw = saturate(r5.xxxx * ScatterParam.wwww + float4(-0,-1,-2,-3));
          r13.xyzw = float4(1,1,1,1) + -r13.xyzw;
          r10.xyzw = r5.zzzz * r13.xyzw + r10.xyzw;
          r11.xyzw = r5.zzzz * r13.xyzw + r11.xyzw;
        }
        r9.z = r9.z + r9.w;
        r5.x = r9.z * r0.y;
        r9.w = r5.x * r1.w + Num_Far_Step2.z;
        r12.x = r9.w * r0.x + r9.z;
      }
      r8.xyz = r12.yyy * LightColor[r2.y].xyz + r8.xyz;
      r6.xyzw = r10.xyzw * LightColor[r2.y].wwww + r6.xyzw;
      r7.xyzw = r11.xyzw * LightColor[r2.y].wwww + r7.xyzw;
    }
    r2.w = (int)r2.y + 1;
  }
  o1.xyzw = r6.xyzw;
  o2.xyzw = r7.xyzw;
  o0.xyz = r8.xyz;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.57 on Sun May 07 00:37:58 2017
//
//
// Buffer Definitions: 
//
// cbuffer SceneBuffer
// {
//
//   float4x4 g_View;                   // Offset:    0 Size:    64 [unused]
//   float4x4 g_Proj;                   // Offset:   64 Size:    64
//   float4x4 g_ViewProjection;         // Offset:  128 Size:    64 [unused]
//   float4x4 g_ViewInverseMatrix;      // Offset:  192 Size:    64
//
// }
//
// cbuffer HPixel_Buffer
// {
//
//   float4 g_TargetUvParam;            // Offset:    0 Size:    16
//
// }
//
// cbuffer CamParam_HPixel_Buffer
// {
//
//   float4 g_CameraParam;              // Offset:    0 Size:    16
//   float4 g_CameraVec;                // Offset:   16 Size:    16
//
// }
//
// cbuffer ShadowView_Buffer
// {
//
//   float4 g_ShadowFarInv;             // Offset:    0 Size:    16 [unused]
//   float4 g_DepthOffset;              // Offset:   16 Size:    16 [unused]
//   float4 g_BokeOffset;               // Offset:   32 Size:    16 [unused]
//   float4x4 g_ShadowView;             // Offset:   48 Size:    64 [unused]
//   float4x4 g_ShadowViewProj[4];      // Offset:  112 Size:   256
//
// }
//
// cbuffer CB
// {
//
//   float4 LightPos[4];                // Offset:    0 Size:    64
//   float4 LightDir[4];                // Offset:   64 Size:    64
//   float4 LightColor[4];              // Offset:  128 Size:    64
//   float4 AttnParam[4];               // Offset:  192 Size:    64
//   float4 Num_Far_Step2;              // Offset:  256 Size:    16
//   float4 ScatterParam;               // Offset:  272 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_Z_TexSampler                    sampler      NA          NA    6        1
// g_Shadow_TexSampler               sampler      NA          NA   11        1
// g_Z_Tex                           texture  float4          2d    6        1
// g_Shadow_Tex                      texture  float4          2d   11        1
// SceneBuffer                       cbuffer      NA          NA    0        1
// CB                                cbuffer      NA          NA    8        1
// ShadowView_Buffer                 cbuffer      NA          NA   10        1
// HPixel_Buffer                     cbuffer      NA          NA   12        1
// CamParam_HPixel_Buffer            cbuffer      NA          NA   13        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float       
// TEXCOORD                 0   xy          1     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyz         0   TARGET   float   xyz 
// SV_Target                1   xyzw        1   TARGET   float   xyzw
// SV_Target                2   xyzw        2   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[15], immediateIndexed
dcl_constantbuffer cb12[1], immediateIndexed
dcl_constantbuffer cb13[2], immediateIndexed
dcl_constantbuffer cb10[23], dynamicIndexed
dcl_constantbuffer cb8[18], dynamicIndexed
dcl_sampler s6, mode_default
dcl_sampler s11, mode_default
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texture2d (float,float,float,float) t11
dcl_input_ps linear v1.xy
dcl_output o0.xyz
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_temps 14
dcl_indexableTemp x0[16], 4
div r0.xy, l(0.250000, 0.250000, 0.000000, 0.000000), cb12[0].zwzz
add r0.xy, -r0.xyxx, v1.xyxx
mad r0.z, r0.x, l(2.000000), l(-1.000000)
div r1.x, r0.z, cb0[4].x
mad r0.z, r0.y, l(-2.000000), l(1.000000)
div r1.y, r0.z, cb0[5].y
sample_indexable(texture2d)(float,float,float,float) r0.z, r0.xyxx, t6.yzxw, s6
mad r0.z, r0.z, cb13[0].y, cb13[0].x
min r0.z, r0.z, cb8[16].y
mul r1.xy, r0.zzzz, r1.xyxx
mov r1.z, -r0.z
mov r1.w, l(1.000000)
dp4 r2.x, r1.xyzw, cb0[12].xyzw
dp4 r2.y, r1.xyzw, cb0[13].xyzw
dp4 r2.z, r1.xyzw, cb0[14].xyzw
add r1.xyz, r2.xyzx, -cb13[1].xyzx
dp3 r2.x, r1.xyzx, r1.xyzx
ftou r0.w, cb8[16].x
mov x0[0].x, l(0)
mov x0[1].x, l(0.500000)
mov x0[2].x, l(0.125000)
mov x0[3].x, l(0.625000)
mov x0[4].x, l(0.750000)
mov x0[5].x, l(0.250000)
mov x0[6].x, l(0.875000)
mov x0[7].x, l(0.375000)
mov x0[8].x, l(0.187500)
mov x0[9].x, l(0.687500)
mov x0[10].x, l(0.062500)
mov x0[11].x, l(0.562500)
mov x0[12].x, l(0.937500)
mov x0[13].x, l(0.437500)
mov x0[14].x, l(0.812500)
mov x0[15].x, l(0.312500)
mul r0.xy, r0.xyxx, cb12[0].zwzz
ftoi r0.xy, r0.xyxx
bfi r0.y, l(2), l(2), r0.y, l(0)
bfi r0.x, l(2), l(0), r0.x, r0.y
mov r0.x, x0[r0.x + 0].x
rsq r0.y, r2.x
mul r3.xyz, r0.yyyy, r1.xyzx
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), cb8[16].y
add r1.w, -cb8[16].z, cb8[16].w
mov r4.yz, l(0,1.000000,0,0)
mov r5.w, l(1.000000)
mov r6.xyzw, l(0,0,0,0)
mov r7.xyzw, l(0,0,0,0)
mov r8.xyz, l(0,0,0,0)
mov r2.w, l(0)
loop 
  uge r3.w, r2.w, r0.w
  breakc_nz r3.w
  add r9.xyz, cb13[1].xyzx, -cb8[r2.w + 0].xyzx
  dp3 r10.x, r1.xyzx, cb8[r2.w + 4].xyzx
  dp3 r10.y, r9.xyzx, cb8[r2.w + 4].xyzx
  dp3 r2.y, r9.xyzx, r1.xyzx
  dp3 r2.z, r9.xyzx, r9.xyzx
  mul r3.w, cb8[r2.w + 4].w, cb8[r2.w + 4].w
  mul r11.xyz, r2.xyzx, r3.wwww
  mad r10.xzw, r10.xxxy, r10.xxyy, -r11.xxyz
  lt r2.y, |r10.x|, l(1.192092896E-007)
  if_nz r2.y
    iadd r2.y, r2.w, l(1)
    mov r2.w, r2.y
    continue 
  else 
    mov r2.y, r2.w
  endif 
  mul r3.w, r10.w, r10.x
  mad r3.w, r10.z, r10.z, -r3.w
  lt r8.w, r3.w, l(1.192092896E-007)
  if_nz r8.w
    iadd r8.w, r2.y, l(1)
    mov r2.w, r8.w
    continue 
  endif 
  sqrt r3.w, r3.w
  div r8.w, l(1.000000, 1.000000, 1.000000, 1.000000), r10.x
  lt r9.w, l(0.000000), r8.w
  lt r10.x, r8.w, l(0.000000)
  iadd r9.w, r10.x, -r9.w
  itof r9.w, r9.w
  sqrt r2.z, r2.z
  mul r2.z, r2.z, cb8[r2.w + 4].w
  lt r2.z, r2.z, r10.y
  mad r10.x, -r9.w, r3.w, -r10.z
  mul r10.x, r8.w, r10.x
  lt r10.w, r10.x, l(0.000000)
  mad r3.w, r9.w, r3.w, -r10.z
  mul r4.x, r8.w, r3.w
  movc r3.w, r10.w, r4.x, r10.x
  lt r8.w, l(0.000000), r3.w
  lt r9.w, r3.w, l(1.000000)
  and r8.w, r8.w, r9.w
  movc r4.w, r8.w, r3.w, l(1.000000)
  lt r3.w, l(0.000000), r10.x
  mad r11.xyz, r10.xxxx, r1.xyzx, r9.xyzx
  dp3 r8.w, r11.xyzx, cb8[r2.w + 4].xyzx
  lt r8.w, l(0.000000), r8.w
  and r3.w, r3.w, r8.w
  min r10.y, r4.x, l(1.000000)
  mad r9.xyz, r4.xxxx, r1.xyzx, r9.xyzx
  dp3 r8.w, r9.xyzx, cb8[r2.w + 4].xyzx
  lt r8.w, l(0.000000), r8.w
  movc r9.xy, r8.wwww, r4.xyxx, l(-1.000000,0,0,0)
  movc r9.xy, r3.wwww, r10.xyxx, r9.xyxx
  movc r4.xw, r2.zzzz, r4.zzzw, r9.xxxy
  ge r2.z, r4.x, l(0.000000)
  lt r3.w, r4.x, l(1.000000)
  and r2.z, r2.z, r3.w
  if_nz r2.z
    mul r4.xw, r0.zzzz, r4.xxxw
    mul r2.z, r0.y, r4.x
    mad r2.z, r2.z, r1.w, cb8[16].z
    mad r3.w, r2.z, r0.x, r4.x
    and r8.w, r2.y, l(1)
    ushr r9.x, r2.y, l(1)
    utof r10.x, r8.w
    utof r10.y, r9.x
    mad r9.xy, r10.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), l(0.250000, 0.250000, 0.000000, 0.000000)
    ishl r8.w, r2.y, l(2)
    mov r10.xyzw, l(0,0,0,0)
    mov r11.xyzw, l(0,0,0,0)
    mov r9.z, r4.x
    mov r9.w, r2.z
    mov r12.x, r3.w
    mov r12.y, l(0)
    loop 
      ge r12.z, r12.x, r4.w
      breakc_nz r12.z
      mad r5.xyz, r12.xxxx, r3.xyzx, cb13[1].xyzx
      dp4 r13.x, r5.xyzw, cb10[r8.w + 7].xyzw
      dp4 r13.y, r5.xyzw, cb10[r8.w + 8].xyzw
      dp4 r13.z, r5.xyzw, cb10[r8.w + 9].xyzw
      dp4 r12.z, r5.xyzw, cb10[r8.w + 10].xyzw
      div r13.xyz, r13.xyzx, r12.zzzz
      mad r12.zw, r13.xxxy, l(0.000000, 0.000000, 0.250000, -0.250000), r9.xxxy
      sample_l_indexable(texture2d)(float,float,float,float) r12.z, r12.zwzz, t11.yzxw, s11, l(0.000000)
      lt r12.z, r13.z, r12.z
      if_nz r12.z
        add r5.xyz, r5.xyzx, -cb8[r2.w + 0].xyzx
        dp3 r12.z, r5.xyzx, r5.xyzx
        sqrt r12.z, r12.z
        div r5.xyz, r5.xyzx, r12.zzzz
        dp3 r12.w, r5.xyzx, r3.xyzx
        mad r12.w, cb8[17].z, r12.w, cb8[17].y
        log r12.w, |r12.w|
        mul r12.w, r12.w, l(1.500000)
        exp r12.w, r12.w
        div r12.w, cb8[17].x, r12.w
        dp3 r5.x, r5.xyzx, cb8[r2.w + 4].xyzx
        add r5.y, -|r5.x|, l(1.000000)
        sqrt r5.y, r5.y
        mad r5.z, |r5.x|, l(-0.0187292993), l(0.074261)
        mad r5.z, r5.z, |r5.x|, l(-0.212114394)
        mad r5.z, r5.z, |r5.x|, l(1.57072878)
        mul r13.x, r5.y, r5.z
        mad r13.x, r13.x, l(-2.000000), l(3.14159274)
        lt r5.x, r5.x, -r5.x
        and r5.x, r5.x, r13.x
        mad r5.x, r5.z, r5.y, r5.x
        mad_sat r5.x, cb8[r2.y + 12].x, r5.x, cb8[r2.y + 12].y
        mad_sat r5.y, cb8[r2.y + 12].z, r12.z, cb8[r2.y + 12].w
        mul r5.z, r9.w, r12.w
        mul r5.x, r5.x, r5.z
        mul r5.y, r5.y, r5.y
        mul r5.z, r5.y, r5.x
        mad r12.y, r5.x, r5.y, r12.y
        sqrt r5.x, r12.x
        mad_sat r13.xyzw, r5.xxxx, cb8[17].wwww, l(-0.000000, -1.000000, -2.000000, -3.000000)
        add r13.xyzw, -r13.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
        mad r10.xyzw, r5.zzzz, r13.xyzw, r10.xyzw
        mad r11.xyzw, r5.zzzz, r13.xyzw, r11.xyzw
      endif 
      add r9.z, r9.w, r9.z
      mul r5.x, r0.y, r9.z
      mad r9.w, r5.x, r1.w, cb8[16].z
      mad r12.x, r9.w, r0.x, r9.z
    endloop 
    mad r8.xyz, r12.yyyy, cb8[r2.y + 8].xyzx, r8.xyzx
    mad r6.xyzw, r10.xyzw, cb8[r2.y + 8].wwww, r6.xyzw
    mad r7.xyzw, r11.xyzw, cb8[r2.y + 8].wwww, r7.xyzw
  endif 
  iadd r2.w, r2.y, l(1)
endloop 
mov o1.xyzw, r6.xyzw
mov o2.xyzw, r7.xyzw
mov o0.xyz, r8.xyzx
ret 
// Approximately 189 instruction slots used

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