// asmtool.py -i --fix-fcprimal-volumetric-fog --only-autofixed -f 51cb4c1f75e34427-cs.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.31 on Wed Mar 02 08:06:43 2016
//
//
// Buffer Definitions: 
//
// cbuffer CViewportShaderParameterProvider
// {
//
//   float4x4 InvProjectionMatrix;      // Offset:    0 Size:    64 [unused]
//   float4x4 InvViewMatrix;            // Offset:   64 Size:    64 [unused]
//   float4x4 ProjectionMatrix;         // Offset:  128 Size:    64 [unused]
//   float4x4 ViewMatrix;               // Offset:  192 Size:    64 [unused]
//   float4x4 ViewProjectionMatrix;     // Offset:  256 Size:    64 [unused]
//   float4x4 ViewRotProjectionMatrix;  // Offset:  320 Size:    64 [unused]
//   float4x4 ViewRotProjectionMatrix_Previous;// Offset:  384 Size:    64 [unused]
//   float4 AmbientSHR;                 // Offset:  448 Size:    16 [unused]
//   float4 AmbientSHG;                 // Offset:  464 Size:    16 [unused]
//   float4 AmbientSHB;                 // Offset:  480 Size:    16 [unused]
//   float4 CameraDistances;            // Offset:  496 Size:    16
//   float4 CameraNearPlaneSize;        // Offset:  512 Size:    16 [unused]
//   float4 DepthScale;                 // Offset:  528 Size:    16 [unused]
//   float4 DepthTextureScaleOffset;    // Offset:  544 Size:    16 [unused]
//   float4 FogParams;                  // Offset:  560 Size:    16 [unused]
//   float4 FogSHB;                     // Offset:  576 Size:    16 [unused]
//   float4 FogSHG;                     // Offset:  592 Size:    16 [unused]
//   float4 FogSHR;                     // Offset:  608 Size:    16 [unused]
//   float4 HeightFogParams;            // Offset:  624 Size:    16 [unused]
//   float4 ViewportSize;               // Offset:  640 Size:    16 [unused]
//   float3 ViewPoint;                  // Offset:  656 Size:    12 [unused]
//   float3 CameraPosition;             // Offset:  672 Size:    12
//   float3 CameraPosition_Previous;    // Offset:  688 Size:    12 [unused]
//   float3 CameraPositionFractions;    // Offset:  704 Size:    12 [unused]
//   float3 CameraPositionFractions_Previous;// Offset:  720 Size:    12 [unused]
//   float3 CameraRight;                // Offset:  736 Size:    12 [unused]
//   float3 CameraUp;                   // Offset:  752 Size:    12 [unused]
//   float3 CameraDirection;            // Offset:  768 Size:    12 [unused]
//   float3 EnvironmentMapColorOffset;  // Offset:  784 Size:    12 [unused]
//   float3 EnvironmentMapColorScale;   // Offset:  800 Size:    12 [unused]
//   float3 AmbientOcclusionRanges;     // Offset:  816 Size:    12 [unused]
//   float3 DepthTextureRcpSize;        // Offset:  832 Size:    12 [unused]
//   float2 MotionVectorOffsets;        // Offset:  848 Size:     8 [unused]
//   float2 DepthRangeCompression;      // Offset:  856 Size:     8 [unused]
//   float ShadowProjDepthMinValue;     // Offset:  864 Size:     4 [unused]
//   float DistanceScale;               // Offset:  868 Size:     4 [unused]
//   float WorldSpaceZOffset;           // Offset:  872 Size:     4 [unused]
//   float WorldSpaceZOffset_Previous;  // Offset:  876 Size:     4 [unused]
//   float CameraFOVDeg;                // Offset:  880 Size:     4 [unused]
//   float EffectsEmissiveEVBias;       // Offset:  884 Size:     4 [unused]
//   float ShadowCSMLastSliceIndex;     // Offset:  888 Size:     4 [unused]
//   float UseNormalization;            // Offset:  892 Size:     4 [unused]
//   float FogUndergroundColorScale;    // Offset:  896 Size:     4 [unused]
//
// }
//
// cbuffer CGlobalShaderParameterProvider
// {
//
//   float4 BurnColor;                  // Offset:    0 Size:    16 [unused]
//   float4 BurnParams;                 // Offset:   16 Size:    16 [unused]
//   float4 BurnParams2;                // Offset:   32 Size:    16 [unused]
//   float4 BurnParams3;                // Offset:   48 Size:    16 [unused]
//   float4 CascadedShadowScaleOffsetTile0;// Offset:   64 Size:    16 [unused]
//   float4 CascadedShadowScaleOffsetTile1;// Offset:   80 Size:    16 [unused]
//   float4 WindSimParamsX;             // Offset:   96 Size:    16 [unused]
//   float4 WindSimParamsY;             // Offset:  112 Size:    16 [unused]
//   float VistaNoiseIntensity;         // Offset:  128 Size:     4 [unused]
//   float Time;                        // Offset:  132 Size:     4
//   float WindFactor;                  // Offset:  136 Size:     4 [unused]
//   float FireGlowEV;                  // Offset:  140 Size:     4 [unused]
//   float BurnSpeedScale;              // Offset:  144 Size:     4 [unused]
//   float BurnlineMaskScale;           // Offset:  148 Size:     4 [unused]
//   float BurnlineMaskInfluence;       // Offset:  152 Size:     4 [unused]
//   float WorldSpaceProgressionMaskScale;// Offset:  156 Size:     4 [unused]
//   float WorldSpaceProgressionMaskInfluence;// Offset:  160 Size:     4 [unused]
//   float MaskTransitionSpeedModifier; // Offset:  164 Size:     4 [unused]
//   float GlowMaskScale;               // Offset:  168 Size:     4 [unused]
//   float FireGlowMaskInfluence;       // Offset:  172 Size:     4 [unused]
//   float CenterBurnlineWidth;         // Offset:  176 Size:     4 [unused]
//   float TransitionToBurnlineWidth;   // Offset:  180 Size:     4 [unused]
//   float DissolveCutoffPoint;         // Offset:  184 Size:     4 [unused]
//   float DissolveBlendDistance;       // Offset:  188 Size:     4 [unused]
//   float EyeGlossinessScale;          // Offset:  192 Size:     4 [unused]
//   float EyeSpecIntensityScale;       // Offset:  196 Size:     4 [unused]
//   float EyeIrisGlossinessScale;      // Offset:  200 Size:     4 [unused]
//   float EyeIrisSpecIntensityScale;   // Offset:  204 Size:     4 [unused]
//   float EyeReflectionBoostScale;     // Offset:  208 Size:     4 [unused]
//   bool EyeReflectionMaskEnable;      // Offset:  212 Size:     4 [unused]
//   float4 BurnParams4;                // Offset:  224 Size:    16 [unused]
//   float4 BurnParams5;                // Offset:  240 Size:    16 [unused]
//
// }
//
// cbuffer CVolumetricFogProvider
// {
//
//   float4 VFSampleDistribution[4];    // Offset:    0 Size:    64 [unused]
//   float4x4 VPrevWorldToVolumetricShadowMatrix;// Offset:   64 Size:    64 [unused]
//   float4x4 VFInvViewMatrix;          // Offset:  128 Size:    64 [unused]
//   float4 VFDepthDistribution;        // Offset:  192 Size:    16
//   float4 VFDepthParams;              // Offset:  208 Size:    16 [unused]
//   float4 VFFogDensityBottom;         // Offset:  224 Size:    16 [unused]
//   float4 VFFogDensityTop;            // Offset:  240 Size:    16 [unused]
//   float4 VFFogParams0;               // Offset:  256 Size:    16
//   float4 VFFogParams1;               // Offset:  272 Size:    16 [unused]
//   float4 VFFogParams2;               // Offset:  288 Size:    16
//   float4 VFFogParams3;               // Offset:  304 Size:    16
//   float4 VFShadowParams;             // Offset:  320 Size:    16 [unused]
//   float4 VFViewDirReconstruction;    // Offset:  336 Size:    16
//   int4 VFCellParams;                 // Offset:  352 Size:    16
//   float3 VFCameraXAxis;              // Offset:  368 Size:    12
//   float3 VFCameraYAxis;              // Offset:  384 Size:    12
//   float3 VFCameraZAxis;              // Offset:  400 Size:    12
//   float4 VFTemporalParams;           // Offset:  416 Size:    16 [unused]
//
// }
//
// cbuffer CTileLightingBlendedParameterProvider
// {
//
//   float4 CSMSlice0_0;                // Offset:    0 Size:    16 [unused]
//   float4 CSMSlice0_1;                // Offset:   16 Size:    16 [unused]
//   float4 CSMSlice0_2;                // Offset:   32 Size:    16 [unused]
//   float4 CSMSlice1_0;                // Offset:   48 Size:    16 [unused]
//   float4 CSMSlice1_1;                // Offset:   64 Size:    16 [unused]
//   float4 CSMSlice1_2;                // Offset:   80 Size:    16 [unused]
//   float4 CSMSlice2_0;                // Offset:   96 Size:    16 [unused]
//   float4 CSMSlice2_1;                // Offset:  112 Size:    16 [unused]
//   float4 CSMSlice2_2;                // Offset:  128 Size:    16 [unused]
//   float4 CSMSliceFade;               // Offset:  144 Size:    16 [unused]
//   float4 ShadowMapSize;              // Offset:  160 Size:    16 [unused]
//   float4 SunColor;                   // Offset:  176 Size:    16 [unused]
//   float4 SunDirection;               // Offset:  192 Size:    16 [unused]
//   int2 NumTiles;                     // Offset:  208 Size:     8
//   int LightCount;                    // Offset:  216 Size:     4 [unused]
//   int ParticlesSmallBufferFactor;    // Offset:  220 Size:     4 [unused]
//
// }
//
// Resource bind info for LightsLightingData
// {
//
//   struct LightingData
//   {
//       
//       float4 pos;                    // Offset:    0
//       float4 color;                  // Offset:   16
//       float4 direction;              // Offset:   32
//       float attenuation;             // Offset:   48
//       float2 spotFactors;            // Offset:   52
//       uint flags;                    // Offset:   60
//       float4 clippingInfo;           // Offset:   64
//       float4 clipPlanes[3];          // Offset:   80
//
//   } $Element;                        // Offset:    0 Size:   128
//
// }
//
// Resource bind info for ShadowData
// {
//
//   struct ShadowProjTextureData
//   {
//       
//       float4 shadowMapSize;          // Offset:    0
//       float4x4 shadowProjectionMatrix;// Offset:   16
//       float4 spotScaleOffsetUVs;     // Offset:   80
//
//   } $Element;                        // Offset:    0 Size:    96
//
// }
//
// Resource bind info for LightIndicesPerTileForBlended
// {
//
//   uint $Element;                     // Offset:    0 Size:     4
//
// }
//
// Resource bind info for LightOutputPerTileForBlended
// {
//
//   uint $Element;                     // Offset:    0 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// ShadowCmpSampler                sampler_c      NA          NA    0        1
// ColorWrap                         sampler      NA          NA    1        1
// ProjectedTexture0__TexObj__       texture  float4          2d    0        1
// VFMaxDepthDiv2Texture             texture   float          2d    1        1
// LightsLightingData                texture  struct         r/o    2        1
// ShadowData                        texture  struct         r/o    3        1
// LightIndicesPerTileForBlended     texture  struct         r/o    4        1
// LightOutputPerTileForBlended      texture  struct         r/o    5        1
// VFOutputBufferRGB                     UAV  float3          3d    0        1
// CViewportShaderParameterProvider    cbuffer      NA          NA    0        1
// CGlobalShaderParameterProvider    cbuffer      NA          NA    1        1
// CVolumetricFogProvider            cbuffer      NA          NA    2        1
// CTileLightingBlendedParameterProvider    cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// no Input
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// no Output
cs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[43], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[26], immediateIndexed
dcl_constantbuffer cb3[14], immediateIndexed
dcl_sampler s0, mode_comparison
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_structured t2, 128 
dcl_resource_structured t3, 96 
dcl_resource_structured t4, 4 
dcl_resource_structured t5, 4 
dcl_uav_typed_texture3d (float,float,float,float) u0
dcl_input vThreadGroupID.xyz
dcl_input vThreadIDInGroup.xyz
dcl_temps 21
dcl_thread_group 2, 2, 64

// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125

ld_indexable(texture2d)(float,float,float,float) r18.xyzw, l(0, 0, 0, 0), t125.xyzw

imad r0.xy, vThreadGroupID.xyxx, l(2, 2, 0, 0), vThreadIDInGroup.xyxx
ult r1.xy, r0.xyxx, cb2[22].xyxx
and r1.x, r1.y, r1.x
if_nz r1.x
  imad r0.zw, vThreadGroupID.zzzz, l(0, 0, 64, 64), vThreadIDInGroup.zzzz
  iadd r1.xy, cb2[22].xyxx, l(-1, -1, 0, 0)
  umin r1.xy, r0.xyxx, r1.xyxx
  mov r1.zw, l(0,0,0,0)
  ld_indexable(texture2d)(float,float,float,float) r1.x, r1.xyzw, t1.xyzw
  mad r1.x, r1.x, cb0[31].y, -cb2[12].w
  div r1.x, r1.x, cb2[12].z
  log r1.x, r1.x
  mul r1.x, r1.x, l(0.250000)
  ushr r1.y, cb2[22].z, l(1)
  utof r1.y, r1.y
  mad r1.x, r1.x, r1.y, l(1.000000)
  ftou r1.x, r1.x
  uge r1.x, r1.x, r0.w
  if_nz r1.x
    utof r1.xzw, r0.xxyw
    add r1.xz, r1.xxzx, l(0.500000, 0.000000, 0.500000, 0.000000)
    itof r2.xy, cb2[22].xyxx
    div r1.xz, r1.xxzx, r2.xxyx
    mad r1.xz, r1.xxzx, l(2.000000, 0.000000, 2.000000, 0.000000), l(-1.000000, 0.000000, -1.000000, 0.000000)
    mul r1.xz, r1.zzxz, cb2[21].yyxy
    mul r1.x, r1.x, l(-1.000000)
    mul r2.xyz, r1.xxxx, cb2[24].xyzx
    mad r2.xyz, r1.zzzz, cb2[23].xyzx, r2.xyzx
    add r2.xyz, r2.xyzx, cb2[25].xyzx
    dp3 r1.x, r2.xyzx, r2.xyzx
    rsq r1.x, r1.x
    mul r3.xyz, r1.xxxx, r2.xyzx
    iadd r1.x, r0.w, l(1)
    utof r1.x, r1.x
    div r1.x, r1.x, r1.y
    mul r1.x, r1.x, l(4.000000)
    exp r1.x, r1.x
    mad r1.x, r1.x, cb2[12].z, cb2[12].w
    div r1.y, r1.w, r1.y
    mul r1.y, r1.y, l(4.000000)
    exp r1.y, r1.y
    mad r1.y, r1.y, cb2[12].z, cb2[12].w
    add r1.x, r1.y, r1.x
    mul r1.x, r1.x, l(0.500000)
    mad r1.yzw, r2.xxyz, r1.xxxx, cb0[42].xxyz

// Volumetric Fog fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -i --fix-fcprimal-volumetric-fog --only-autofixed -f 51cb4c1f75e34427-cs.txt

mov r19.xyz, r1.yzwx
mov r19.w, l(1.0)
dp4 r20.w, r19.xyzw, cb0[19].xyzw
add r20.x, r20.w, -r18.y
mul r20.x, r20.x, -r18.x
mul r20.x, r20.x, cb0[0].x
mov r20.yzw, l(0.0)
dp4 r19.x, r20.xyzw, cb0[4].xyzw
dp4 r19.y, r20.xyzw, cb0[5].xyzw
dp4 r19.z, r20.xyzw, cb0[6].xyzw
add r1.yzw, r1.xyzw, r19.xxyz

    imad r2.xyzw, r0.xyxy, cb2[22].wwww, l(4, 4, 12, 4)
    ushr r2.xyzw, r2.xyzw, l(3, 3, 3, 3)
    imad r2.xy, r2.ywyy, cb3[13].xxxx, r2.xzxx
    imad r4.xyzw, r0.xyxy, cb2[22].wwww, l(4, 12, 12, 12)
    ushr r4.xyzw, r4.xyzw, l(3, 3, 3, 3)
    imad r2.zw, r4.yyyw, cb3[13].xxxx, r4.xxxz
    ishl r4.xy, r2.xyxx, l(1, 1, 0, 0)
    ishl r2.yz, r2.zzwz, l(0, 1, 1, 0)
    mov r4.zw, l(0,0,0,0)
    mov r2.w, l(0)
    loop 
      uge r3.w, r2.w, l(2)
      breakc_nz r3.w
      iadd r5.xy, r4.xyxx, r2.wwww
      ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r3.w, r5.x, l(0), t4.xxxx
      ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r5.x, r5.y, l(0), t4.xxxx
      or r3.w, r3.w, r5.x
      iadd r5.xy, r2.yzyy, r2.wwww
      ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r5.x, r5.x, l(0), t4.xxxx
      or r3.w, r3.w, r5.x
      ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r5.x, r5.y, l(0), t4.xxxx
      or r3.w, r3.w, r5.x
      movc r4.z, r2.w, r4.z, r3.w
      ieq r5.x, r2.w, l(1)
      movc r4.w, r5.x, r3.w, r4.w
      iadd r2.w, r2.w, l(1)
    endloop 
    countbits r2.yz, r4.zzwz
    ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r2.x, r2.x, l(0), t5.xxxx
    mul_sat r1.x, r1.x, cb2[18].y
    mul r1.x, r1.x, r1.x
    mul r1.x, r1.x, r1.x
    and r2.xw, r2.xxxx, l(0x80000000, 0, 0, 0x60000000)
    ine r2.w, r2.w, l(0)
    mul r3.w, cb2[16].y, l(0.500000)
    add r5.xyz, r1.yzwy, cb1[8].yyyy
    mul r5.xyz, r5.xyzx, l(1.975000, 0.793000, 0.375000, 0.000000)
    frc r5.xyz, r5.xyzx
    mad r5.xyz, r5.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
    mul r5.xyz, r5.xyzx, cb2[19].xxxx
    mad r5.xyz, r5.xyzx, cb2[19].yyyy, l(0.500000, 0.500000, 0.500000, 0.000000)
    frc r5.xyz, r5.xyzx
    mad r5.xyz, r5.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
    mul r6.xyz, |r5.xyzx|, |r5.xyzx|
    mad r5.xyz, -|r5.xyzx|, l(2.000000, 2.000000, 2.000000, 0.000000), l(3.000000, 3.000000, 3.000000, 0.000000)
    mul r4.x, cb2[19].y, l(0.500000)
    mad r5.xyz, r6.xyzx, r5.xyzx, -r4.xxxx
    add r5.xyz, r1.yzwy, r5.xyzx
    mad r4.x, -r3.w, r3.w, l(1.000000)
    mad r3.w, r3.w, r3.w, l(1.000000)
    mov r5.w, l(1.000000)
    mov r4.y, r4.z
    mov r6.xyzw, l(0,0,0,0)
    loop 
      uge r7.x, r6.w, r2.y
      breakc_nz r7.x
      firstbit_lo r7.x, r4.y
      ishl r7.y, l(1), r7.x
      not r7.y, r7.y
      and r7.y, r4.y, r7.y
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r8.xyz, r7.x, l(0), t2.xyzx
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r9.xyzw, r7.x, l(16), t2.xyzw
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r10.xyz, r7.x, l(32), t2.xyzx
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r11.xyzw, r7.x, l(48), t2.xyzw
      and r7.z, r11.w, l(1)
      ult r7.z, l(0), r7.z
      add r8.xyz, -r1.yzwy, r8.xyzx
      dp3 r7.w, r8.xyzx, r8.xyzx
      max r7.w, r7.w, l(0.000010)
      rsq r8.w, r7.w
      div r10.w, l(1.000000, 1.000000, 1.000000, 1.000000), r7.w
      min r9.w, r9.w, r10.w
      mul r8.xyz, r8.wwww, r8.xyzx
      mul r7.w, r7.w, r7.w
      mad_sat r7.w, -r7.w, r11.x, l(1.000000)
      mul r7.w, r7.w, r7.w
      mul r7.w, r7.w, r9.w
      dp3 r8.w, r8.xyzx, -r10.xyzx
      mad_sat r8.w, r8.w, r11.y, r11.z
      movc r8.w, r7.z, r8.w, l(1.000000)
      mul r8.w, r8.w, r8.w
      mul r7.w, r7.w, r8.w
      if_nz r2.x
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r10.xyzw, r7.x, l(72), t2.xyzw
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r12.xyzw, r7.x, l(88), t2.zwxy
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r13.xyzw, r7.x, l(104), t2.xyzw
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r14.xy, r7.x, l(120), t2.xyxx
        ftoi r7.x, r10.y
        mov r11.xy, r10.zwzz
        mov r11.z, r12.z
        dp3 r8.w, r11.xyzx, r1.yzwy
        mad_sat r8.w, r8.w, r10.x, -r12.w
        mov r12.z, r13.x
        dp3 r9.w, r12.xyzx, r1.yzwy
        mad_sat r9.w, r9.w, r10.x, -r13.y
        mul r8.w, r8.w, r9.w
        mov r14.zw, r13.zzzw
        dp3 r9.w, r14.zwxz, r1.yzwy
        mad_sat r9.w, r9.w, r10.x, -r14.y
        mul r8.w, r8.w, r9.w
        mul r9.w, r8.w, r8.w
        mad r8.w, -r8.w, l(2.000000), l(3.000000)
        mul r8.w, r8.w, r9.w
        movc r7.x, r7.x, r8.w, l(1.000000)
        mul r7.w, r7.x, r7.w
      endif 
      mul r10.xyz, r1.xxxx, r7.wwww
      lt r7.x, r10.z, l(0.000100)
      iadd r7.w, r6.w, -r7.x
      mov r4.y, r7.y
      mov r6.w, r7.w
      continuec_nz r7.x
      and r7.x, r2.w, r7.z
      and r7.z, r11.w, l(8)
      ult r7.z, l(0), r7.z
      and r7.x, r7.z, r7.x
      if_nz r7.x
        and r7.xz, r11.wwww, l(32, 0, 16, 0)
        ult r7.zw, l(0, 0, 0, 0), r7.xxxz
        ushr r8.w, r11.w, l(5)
        and r8.w, r8.w, l(2)
        or r7.z, r7.w, r7.z
        and r7.z, r2.w, r7.z
        if_nz r7.z
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r11.xyzw, r8.w, l(0), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r12.xyzw, r8.w, l(16), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r13.xyzw, r8.w, l(32), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r14.xyzw, r8.w, l(48), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r15.xyzw, r8.w, l(64), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r16.xyzw, r8.w, l(80), t3.xyzw
        else 
          mov r11.xyzw, l(0,0,0,0)
          mov r12.xyzw, l(0,0,0,0)
          mov r13.xyzw, l(0,0,0,0)
          mov r14.xyzw, l(0,0,0,0)
          mov r15.xyzw, l(0,0,0,0)
          mov r16.xyzw, l(0,0,0,0)
        endif 
        dp4 r12.x, r5.xyzw, r12.xyzw
        dp4 r12.y, r5.xyzw, r13.xyzw
        dp4 r7.z, r5.xyzw, r14.xyzw
        dp4 r9.w, r5.xyzw, r15.xyzw
        max r9.w, r9.w, l(0.000010)
        div r12.xy, r12.xyxx, r9.wwww
        if_z r8.w
          mad r11.xy, r12.xyxx, r11.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
          round_ni r12.zw, r11.xxxy
          add r11.xy, r11.xyxx, -r12.zwzz
          add r12.zw, r12.zzzw, l(0.000000, 0.000000, -0.500000, -0.500000)
          mul r12.zw, r11.zzzw, r12.zzzw
          mad r13.xy, -r11.yxyy, l(2.000000, 2.000000, 0.000000, 0.000000), l(3.000000, 3.000000, 0.000000, 0.000000)
          mad r13.zw, r11.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 1.000000, 1.000000)
          add r14.xy, -r11.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000)
          div r14.xy, r14.xyxx, r13.yxyy
          div r11.xy, r11.xyxx, r13.zwzz
          add r14.zw, r14.xxxy, l(0.000000, 0.000000, -1.000000, -1.000000)
          add r14.xy, r11.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
          mul r9.w, r13.x, r13.y
          mad r15.xyzw, r14.zwxw, r11.zwzw, r12.zwzw
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r10.w, r15.xyxx, t0.xxxx, s0, r7.z
          mul r11.xy, r13.xyxx, r13.zwzz
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r13.x, r15.zwzz, t0.xxxx, s0, r7.z
          mul r11.x, r11.x, r13.x
          mad r9.w, r9.w, r10.w, r11.x
          mad r14.xyzw, r14.zyxy, r11.zwzw, r12.zwzw
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r10.w, r14.xyxx, t0.xxxx, s0, r7.z
          mad r9.w, r11.y, r10.w, r9.w
          mul r10.w, r13.w, r13.z
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r7.z, r14.zwzz, t0.xxxx, s0, r7.z
          mad r7.z, r10.w, r7.z, r9.w
          mul r7.z, r7.z, l(0.062500)
        else 
          mov r7.z, l(1.000000)
        endif 
        mul r7.z, r7.z, r10.z
        if_nz r7.x
          if_z r8.w
            mad r11.xy, r12.xyxx, r16.xyxx, r16.zwzz
            sample_l_indexable(texture2d)(float,float,float,float) r11.xyz, r11.xyxx, t0.xyzw, s1, l(0.000000)
          else 
            mov r11.xyz, l(1.000000,0,1.000000,0)
          endif 
          mul r11.xyz, r10.zzzz, r11.xyzx
        else 
          mov r11.xyz, r10.zzzz
        endif 
        movc r10.xyz, r7.wwww, r7.zzzz, r11.xyzx
      endif 
      dp3 r7.x, r8.xyzx, r3.xyzx
      mad r7.x, -cb2[16].y, r7.x, r3.w
      log r7.x, |r7.x|
      mul r7.x, r7.x, l(1.500000)
      exp r7.x, r7.x
      div r7.x, r4.x, r7.x
      mul r7.x, r7.x, l(0.785398185)
      mul r8.xyz, r9.xyzx, r10.xyzx
      mul r8.xyz, r8.xyzx, cb2[18].xxxx
      mad r6.xyz, r8.xyzx, r7.xxxx, r6.xyzx
      iadd r6.w, r6.w, l(1)
      mov r4.y, r7.y
    endloop 
    mov r5.w, l(1.000000)
    mov r7.xyz, r6.xyzx
    mov r2.y, r4.w
    mov r4.y, l(0)
    loop 
      uge r4.z, r4.y, r2.z
      breakc_nz r4.z
      firstbit_lo r4.z, r2.y
      ishl r6.w, l(1), r4.z
      not r6.w, r6.w
      and r6.w, r2.y, r6.w
      iadd r4.z, l(32), r4.z
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r8.xyz, r4.z, l(0), t2.xyzx
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r9.xyzw, r4.z, l(16), t2.xyzw
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r10.xyz, r4.z, l(32), t2.xyzx
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r11.xyzw, r4.z, l(48), t2.xyzw
      and r7.w, r11.w, l(1)
      ult r7.w, l(0), r7.w
      add r8.xyz, -r1.yzwy, r8.xyzx
      dp3 r8.w, r8.xyzx, r8.xyzx
      max r8.w, r8.w, l(0.000010)
      rsq r10.w, r8.w
      div r12.x, l(1.000000, 1.000000, 1.000000, 1.000000), r8.w
      min r9.w, r9.w, r12.x
      mul r8.xyz, r8.xyzx, r10.wwww
      mul r8.w, r8.w, r8.w
      mad_sat r8.w, -r8.w, r11.x, l(1.000000)
      mul r8.w, r8.w, r8.w
      mul r8.w, r8.w, r9.w
      dp3 r9.w, r8.xyzx, -r10.xyzx
      mad_sat r9.w, r9.w, r11.y, r11.z
      movc r9.w, r7.w, r9.w, l(1.000000)
      mul r9.w, r9.w, r9.w
      mul r8.w, r8.w, r9.w
      if_nz r2.x
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r10.xyzw, r4.z, l(72), t2.xyzw
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r12.xyzw, r4.z, l(88), t2.zwxy
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r13.xyzw, r4.z, l(104), t2.xyzw
        ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r14.xy, r4.z, l(120), t2.xyxx
        ftoi r4.z, r10.y
        mov r11.xy, r10.zwzz
        mov r11.z, r12.z
        dp3 r9.w, r11.xyzx, r1.yzwy
        mad_sat r9.w, r9.w, r10.x, -r12.w
        mov r12.z, r13.x
        dp3 r10.y, r12.xyzx, r1.yzwy
        mad_sat r10.y, r10.y, r10.x, -r13.y
        mul r9.w, r9.w, r10.y
        mov r14.zw, r13.zzzw
        dp3 r10.y, r14.zwxz, r1.yzwy
        mad_sat r10.x, r10.y, r10.x, -r14.y
        mul r9.w, r9.w, r10.x
        mul r10.x, r9.w, r9.w
        mad r9.w, -r9.w, l(2.000000), l(3.000000)
        mul r9.w, r9.w, r10.x
        movc r4.z, r4.z, r9.w, l(1.000000)
        mul r8.w, r4.z, r8.w
      endif 
      mul r10.xyz, r1.xxxx, r8.wwww
      lt r4.z, r10.z, l(0.000100)
      iadd r8.w, r4.y, -r4.z
      mov r2.y, r6.w
      mov r4.y, r8.w
      continuec_nz r4.z
      and r4.z, r2.w, r7.w
      and r7.w, r11.w, l(8)
      ult r7.w, l(0), r7.w
      and r4.z, r4.z, r7.w
      if_nz r4.z
        and r11.xy, r11.wwww, l(32, 16, 0, 0)
        ult r11.yz, l(0, 0, 0, 0), r11.xxyx
        ushr r4.z, r11.w, l(5)
        and r4.z, r4.z, l(2)
        or r7.w, r11.z, r11.y
        and r7.w, r2.w, r7.w
        if_nz r7.w
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r12.xyzw, r4.z, l(0), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r13.xyzw, r4.z, l(16), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r14.xyzw, r4.z, l(32), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r15.xyzw, r4.z, l(48), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r16.xyzw, r4.z, l(64), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r17.xyzw, r4.z, l(80), t3.xyzw
        else 
          mov r12.xyzw, l(0,0,0,0)
          mov r13.xyzw, l(0,0,0,0)
          mov r14.xyzw, l(0,0,0,0)
          mov r15.xyzw, l(0,0,0,0)
          mov r16.xyzw, l(0,0,0,0)
          mov r17.xyzw, l(0,0,0,0)
        endif 
        dp4 r13.x, r5.xyzw, r13.xyzw
        dp4 r13.y, r5.xyzw, r14.xyzw
        dp4 r7.w, r5.xyzw, r15.xyzw
        dp4 r8.w, r5.xyzw, r16.xyzw
        max r8.w, r8.w, l(0.000010)
        div r11.yw, r13.xxxy, r8.wwww
        if_z r4.z
          mad r12.xy, r11.ywyy, r12.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
          round_ni r13.xy, r12.xyxx
          add r12.xy, r12.xyxx, -r13.xyxx
          add r13.xy, r13.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
          mul r13.xy, r12.zwzz, r13.xyxx
          mad r13.zw, -r12.yyyx, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 3.000000, 3.000000)
          mad r14.xy, r12.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(1.000000, 1.000000, 0.000000, 0.000000)
          add r14.zw, -r12.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000)
          div r14.zw, r14.zzzw, r13.wwwz
          div r12.xy, r12.xyxx, r14.xyxx
          add r15.zw, r14.zzzw, l(0.000000, 0.000000, -1.000000, -1.000000)
          add r15.xy, r12.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
          mul r8.w, r13.z, r13.w
          mad r16.xyzw, r15.zwxw, r12.zwzw, r13.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r9.w, r16.xyxx, t0.xxxx, s0, r7.w
          mul r12.xy, r13.zwzz, r14.xyxx
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r10.w, r16.zwzz, t0.xxxx, s0, r7.w
          mul r10.w, r10.w, r12.x
          mad r8.w, r8.w, r9.w, r10.w
          mad r13.xyzw, r15.zyxy, r12.zwzw, r13.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r9.w, r13.xyxx, t0.xxxx, s0, r7.w
          mad r8.w, r12.y, r9.w, r8.w
          mul r9.w, r14.y, r14.x
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r7.w, r13.zwzz, t0.xxxx, s0, r7.w
          mad r7.w, r9.w, r7.w, r8.w
          mul r7.w, r7.w, l(0.062500)
        else 
          mov r7.w, l(1.000000)
        endif 
        mul r7.w, r7.w, r10.z
        if_nz r11.x
          if_z r4.z
            mad r11.xy, r11.ywyy, r17.xyxx, r17.zwzz
            sample_l_indexable(texture2d)(float,float,float,float) r11.xyw, r11.xyxx, t0.xywz, s1, l(0.000000)
          else 
            mov r11.xyw, l(1.000000,0,0,1.000000)
          endif 
          mul r11.xyw, r10.zzzz, r11.xyxw
        else 
          mov r11.xyw, r10.zzzz
        endif 
        movc r10.xyz, r11.zzzz, r7.wwww, r11.xywx
      endif 
      dp3 r4.z, r8.xyzx, r3.xyzx
      mad r4.z, -cb2[16].y, r4.z, r3.w
      log r4.z, |r4.z|
      mul r4.z, r4.z, l(1.500000)
      exp r4.z, r4.z
      div r4.z, r4.x, r4.z
      mul r4.z, r4.z, l(0.785398185)
      mul r8.xyz, r9.xyzx, r10.xyzx
      mul r8.xyz, r8.xyzx, cb2[18].xxxx
      mad r7.xyz, r8.xyzx, r4.zzzz, r7.xyzx
      iadd r4.y, r4.y, l(1)
      mov r2.y, r6.w
    endloop 
    mul r1.xyz, r7.xyzx, l(0.200000, 0.200000, 0.200000, 0.000000)
  else 
    mov r1.xyz, l(0,0,0,0)
  endif 
  store_uav_typed u0.xyzw, r0.xyzw, r1.xyzx
endif 
ret 
// Approximately 406 instruction slots used