// asmtool.py -i --fix-fcprimal-volumetric-fog --only-autofixed -f ad7a6a5c9182e26e-cs.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.31 on Wed Mar 02 08:07:09 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 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 [unused]
//   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
// CVolumetricFogProvider            cbuffer      NA          NA    1        1
// CTileLightingBlendedParameterProvider    cbuffer      NA          NA    2        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[26], immediateIndexed
dcl_constantbuffer cb2[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 24
dcl_thread_group 2, 2, 64

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

ld_indexable(texture2d)(float,float,float,float) r21.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, cb1[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, cb1[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, -cb1[12].w
  div r1.x, r1.x, cb1[12].z
  log r1.x, r1.x
  mul r1.x, r1.x, l(0.250000)
  ushr r1.y, cb1[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, cb1[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, cb1[21].yyxy
    mul r1.x, r1.x, l(-1.000000)
    mul r2.xyz, r1.xxxx, cb1[24].xyzx
    mad r2.xyz, r1.zzzz, cb1[23].xyzx, r2.xyzx
    add r2.xyz, r2.xyzx, cb1[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, cb1[12].z, cb1[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, cb1[12].z, cb1[12].w
    add r1.z, r1.y, r1.x
    mul r1.z, r1.z, l(0.500000)
    mad r4.xyz, r2.xyzx, r1.zzzz, cb0[42].xyzx

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

mov r22.xyz, r4.xyzx
mov r22.w, l(1.0)
dp4 r23.w, r22.xyzw, cb0[19].xyzw
add r23.x, r23.w, -r21.y
mul r23.x, r23.x, -r21.x
mul r23.x, r23.x, cb0[0].x
mov r23.yzw, l(0.0)
dp4 r22.x, r23.xyzw, cb0[4].xyzw
dp4 r22.y, r23.xyzw, cb0[5].xyzw
dp4 r22.z, r23.xyzw, cb0[6].xyzw
add r4.xyz, r4.xyzw, r22.xyzx

    imad r5.xyzw, r0.xyxy, cb1[22].wwww, l(4, 4, 12, 4)
    ushr r5.xyzw, r5.xyzw, l(3, 3, 3, 3)
    imad r5.xy, r5.ywyy, cb2[13].xxxx, r5.xzxx
    imad r6.xyzw, r0.xyxy, cb1[22].wwww, l(4, 12, 12, 12)
    ushr r6.xyzw, r6.xyzw, l(3, 3, 3, 3)
    imad r5.zw, r6.yyyw, cb2[13].xxxx, r6.xxxz
    ishl r6.xy, r5.xyxx, l(1, 1, 0, 0)
    ishl r5.yz, r5.zzwz, l(0, 1, 1, 0)
    mov r6.zw, l(0,0,0,0)
    mov r1.w, l(0)
    loop 
      uge r2.w, r1.w, l(2)
      breakc_nz r2.w
      iadd r7.xy, r6.xyxx, r1.wwww
      ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r2.w, r7.x, l(0), t4.xxxx
      ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r3.w, r7.y, l(0), t4.xxxx
      or r2.w, r2.w, r3.w
      iadd r7.xy, r5.yzyy, r1.wwww
      ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r3.w, r7.x, l(0), t4.xxxx
      or r2.w, r2.w, r3.w
      ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r3.w, r7.y, l(0), t4.xxxx
      or r2.w, r2.w, r3.w
      movc r6.z, r1.w, r6.z, r2.w
      ieq r3.w, r1.w, l(1)
      movc r6.w, r3.w, r2.w, r6.w
      iadd r1.w, r1.w, l(1)
    endloop 
    add r1.x, -r1.y, r1.x
    mad r1.xy, r1.xxxx, l(0.200000, 0.800000, 0.000000, 0.000000), r1.yyyy
    mad r7.xyz, r2.xyzx, r1.xxxx, cb0[42].xyzx
    mad r2.xyz, r2.xyzx, r1.yyyy, cb0[42].xyzx
    countbits r1.xy, r6.zwzz
    ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.w, r5.x, l(0), t5.xxxx
    mul_sat r1.z, r1.z, cb1[18].y
    mul r1.z, r1.z, r1.z
    mul r1.z, r1.z, r1.z
    and r1.w, r1.w, l(0x60000000)
    ine r1.w, r1.w, l(0)
    mul r3.w, cb1[16].y, l(0.500000)
    mad r5.x, -r3.w, r3.w, l(1.000000)
    mad r3.w, r3.w, r3.w, l(1.000000)
    mov r4.w, l(1.000000)
    mov r7.w, l(1.000000)
    mov r2.w, l(1.000000)
    mov r5.yzw, l(0,0,0,0)
    mov r6.x, r6.z
    mov r6.y, l(0)
    loop 
      uge r8.x, r6.y, r1.x
      breakc_nz r8.x
      firstbit_lo r8.x, r6.x
      ishl r8.y, l(1), r8.x
      not r8.y, r8.y
      and r8.y, r6.x, r8.y
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r9.xyz, r8.x, l(0), t2.xyzx
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r10.xyzw, r8.x, l(16), t2.xyzw
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r11.xyz, r8.x, l(32), t2.xyzx
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r12.xyzw, r8.x, l(48), t2.xyzw
      and r8.x, r12.w, l(1)
      ult r8.x, l(0), r8.x
      add r9.xyz, -r4.xyzx, r9.xyzx
      dp3 r8.z, r9.xyzx, r9.xyzx
      max r8.z, r8.z, l(0.000010)
      rsq r8.w, r8.z
      div r9.w, l(1.000000, 1.000000, 1.000000, 1.000000), r8.z
      min r9.w, r9.w, r10.w
      mul r9.xyz, r8.wwww, r9.xyzx
      mul r8.z, r8.z, r8.z
      mad_sat r8.z, -r8.z, r12.x, l(1.000000)
      mul r8.z, r8.z, r8.z
      mul r8.z, r8.z, r9.w
      dp3 r8.w, r9.xyzx, -r11.xyzx
      mad_sat r8.w, r8.w, r12.y, r12.z
      movc r8.w, r8.x, r8.w, l(1.000000)
      mul r8.w, r8.w, r8.w
      mul r8.z, r8.z, r8.w
      mul r11.xyz, r1.zzzz, r8.zzzz
      lt r8.z, r11.z, l(0.000100)
      iadd r8.w, r6.y, -r8.z
      mov r6.x, r8.y
      mov r6.xy, r8.ywyy
      continuec_nz r8.z
      and r8.x, r1.w, r8.x
      and r8.z, r12.w, l(8)
      ult r8.z, l(0), r8.z
      and r8.x, r8.z, r8.x
      if_nz r8.x
        and r8.xz, r12.wwww, l(32, 0, 16, 0)
        ult r8.zw, l(0, 0, 0, 0), r8.xxxz
        ushr r9.w, r12.w, l(5)
        and r9.w, r9.w, l(2)
        or r8.z, r8.w, r8.z
        and r8.z, r1.w, r8.z
        if_nz r8.z
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r12.xyzw, r9.w, l(0), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r13.xyzw, r9.w, l(16), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r14.xyzw, r9.w, l(32), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r15.xyzw, r9.w, l(48), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r16.xyzw, r9.w, l(64), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r17.xyzw, r9.w, 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 r18.x, r4.xyzw, r13.xyzw
        dp4 r18.y, r4.xyzw, r14.xyzw
        dp4 r8.z, r4.xyzw, r15.xyzw
        dp4 r10.w, r4.xyzw, r16.xyzw
        max r10.w, r10.w, l(0.000010)
        div r18.xy, r18.xyxx, r10.wwww
        dp4 r19.x, r7.xyzw, r13.xyzw
        dp4 r19.y, r7.xyzw, r14.xyzw
        dp4 r10.w, r7.xyzw, r15.xyzw
        dp4 r11.w, r7.xyzw, r16.xyzw
        max r11.w, r11.w, l(0.000010)
        div r18.zw, r19.xxxy, r11.wwww
        dp4 r13.x, r2.xyzw, r13.xyzw
        dp4 r13.y, r2.xyzw, r14.xyzw
        dp4 r11.w, r2.xyzw, r15.xyzw
        dp4 r13.z, r2.xyzw, r16.xyzw
        max r13.z, r13.z, l(0.000010)
        div r13.xy, r13.xyxx, r13.zzzz
        if_z r9.w
          mad r13.zw, r18.xxxy, r12.xxxy, l(0.000000, 0.000000, 0.500000, 0.500000)
          round_ni r14.xy, r13.zwzz
          add r13.zw, r13.zzzw, -r14.xxxy
          add r14.xy, r14.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
          mul r14.xy, r12.zwzz, r14.xyxx
          mad r14.zw, -r13.wwwz, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 3.000000, 3.000000)
          mad r15.xy, r13.zwzz, l(2.000000, 2.000000, 0.000000, 0.000000), l(1.000000, 1.000000, 0.000000, 0.000000)
          add r15.zw, -r13.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000)
          div r15.zw, r15.zzzw, r14.wwwz
          div r13.zw, r13.zzzw, r15.xxxy
          add r16.zw, r15.zzzw, l(0.000000, 0.000000, -1.000000, -1.000000)
          add r16.xy, r13.zwzz, l(1.000000, 1.000000, 0.000000, 0.000000)
          mul r13.z, r14.z, r14.w
          mad r19.xyzw, r16.zwxw, r12.zwzw, r14.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r13.w, r19.xyxx, t0.xxxx, s0, r8.z
          mul r14.zw, r14.zzzw, r15.xxxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r15.z, r19.zwzz, t0.xxxx, s0, r8.z
          mul r14.z, r14.z, r15.z
          mad r13.z, r13.z, r13.w, r14.z
          mad r16.xyzw, r16.zyxy, r12.zwzw, r14.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r13.w, r16.xyxx, t0.xxxx, s0, r8.z
          mad r13.z, r14.w, r13.w, r13.z
          mul r13.w, r15.y, r15.x
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r8.z, r16.zwzz, t0.xxxx, s0, r8.z
          mad r8.z, r13.w, r8.z, r13.z
          mad r13.zw, r18.zzzw, r12.xxxy, l(0.000000, 0.000000, 0.500000, 0.500000)
          round_ni r14.xy, r13.zwzz
          add r13.zw, r13.zzzw, -r14.xxxy
          add r14.xy, r14.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
          mul r14.xy, r12.zwzz, r14.xyxx
          mad r14.zw, -r13.wwwz, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 3.000000, 3.000000)
          mad r15.xy, r13.zwzz, l(2.000000, 2.000000, 0.000000, 0.000000), l(1.000000, 1.000000, 0.000000, 0.000000)
          add r15.zw, -r13.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000)
          div r15.zw, r15.zzzw, r14.wwwz
          div r13.zw, r13.zzzw, r15.xxxy
          add r16.zw, r15.zzzw, l(0.000000, 0.000000, -1.000000, -1.000000)
          add r16.xy, r13.zwzz, l(1.000000, 1.000000, 0.000000, 0.000000)
          mul r13.z, r14.z, r14.w
          mad r19.xyzw, r16.zwxw, r12.zwzw, r14.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r13.w, r19.xyxx, t0.xxxx, s0, r10.w
          mul r14.zw, r14.zzzw, r15.xxxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r15.z, r19.zwzz, t0.xxxx, s0, r10.w
          mul r14.z, r14.z, r15.z
          mad r13.z, r13.z, r13.w, r14.z
          mad r16.xyzw, r16.zyxy, r12.zwzw, r14.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r13.w, r16.xyxx, t0.xxxx, s0, r10.w
          mad r13.z, r14.w, r13.w, r13.z
          mul r13.w, r15.y, r15.x
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r10.w, r16.zwzz, t0.xxxx, s0, r10.w
          mad r10.w, r13.w, r10.w, r13.z
          mul r10.w, r10.w, l(0.062500)
          mad r8.z, r8.z, l(0.062500), r10.w
          mad r12.xy, r13.xyxx, 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 r10.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) r12.x, r16.xyxx, t0.xxxx, s0, r11.w
          mul r13.zw, r13.zzzw, r14.xxxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r12.y, r16.zwzz, t0.xxxx, s0, r11.w
          mul r12.y, r12.y, r13.z
          mad r10.w, r10.w, r12.x, r12.y
          mad r12.xyzw, r15.zyxy, r12.zwzw, r13.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r12.x, r12.xyxx, t0.xxxx, s0, r11.w
          mad r10.w, r13.w, r12.x, r10.w
          mul r12.x, r14.y, r14.x
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r11.w, r12.zwzz, t0.xxxx, s0, r11.w
          mad r10.w, r12.x, r11.w, r10.w
          mad r8.z, r10.w, l(0.062500), r8.z
        else 
          mov r8.z, l(1.000000)
        endif 
        mul r8.z, r11.z, r8.z
        mul r8.z, r8.z, l(0.333333343)
        if_nz r8.x
          if_z r9.w
            mad r12.xy, r18.xyxx, r17.xyxx, r17.zwzz
            sample_l_indexable(texture2d)(float,float,float,float) r12.xyz, r12.xyxx, t0.xyzw, s1, l(0.000000)
          else 
            mov r12.xyz, l(1.000000,0,1.000000,0)
          endif 
          mul r12.xyz, r11.zzzz, r12.xyzx
        else 
          mov r12.xyz, r11.zzzz
        endif 
        movc r11.xyz, r8.wwww, r8.zzzz, r12.xyzx
      endif 
      dp3 r8.x, r9.xyzx, r3.xyzx
      mad r8.x, -cb1[16].y, r8.x, r3.w
      log r8.x, |r8.x|
      mul r8.x, r8.x, l(1.500000)
      exp r8.x, r8.x
      div r8.x, r5.x, r8.x
      mul r8.x, r8.x, l(0.785398185)
      mul r9.xyz, r10.xyzx, r11.xyzx
      mul r9.xyz, r9.xyzx, cb1[18].xxxx
      mad r5.yzw, r9.xxyz, r8.xxxx, r5.yyzw
      iadd r6.y, r6.y, l(1)
    endloop 
    mov r8.xyz, r4.xyzx
    mov r8.w, l(1.000000)
    mov r7.w, l(1.000000)
    mov r2.w, l(1.000000)
    mov r6.xyz, r5.yzwy
    mov r1.x, r6.w
    mov r4.w, l(0)
    loop 
      uge r9.x, r4.w, r1.y
      breakc_nz r9.x
      firstbit_lo r9.x, r1.x
      ishl r9.y, l(1), r9.x
      not r9.y, r9.y
      and r9.y, r1.x, r9.y
      iadd r9.x, l(32), r9.x
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r10.xyz, r9.x, l(0), t2.xyzx
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r11.xyzw, r9.x, l(16), t2.xyzw
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r12.xyz, r9.x, l(32), t2.xyzx
      ld_structured_indexable(structured_buffer, stride=128)(mixed,mixed,mixed,mixed) r13.xyzw, r9.x, l(48), t2.xyzw
      and r9.x, r13.w, l(1)
      ult r9.x, l(0), r9.x
      add r10.xyz, -r4.xyzx, r10.xyzx
      dp3 r9.z, r10.xyzx, r10.xyzx
      max r9.z, r9.z, l(0.000010)
      rsq r9.w, r9.z
      div r10.w, l(1.000000, 1.000000, 1.000000, 1.000000), r9.z
      min r10.w, r10.w, r11.w
      mul r10.xyz, r9.wwww, r10.xyzx
      mul r9.z, r9.z, r9.z
      mad_sat r9.z, -r9.z, r13.x, l(1.000000)
      mul r9.z, r9.z, r9.z
      mul r9.z, r9.z, r10.w
      dp3 r9.w, r10.xyzx, -r12.xyzx
      mad_sat r9.w, r9.w, r13.y, r13.z
      movc r9.w, r9.x, r9.w, l(1.000000)
      mul r9.w, r9.w, r9.w
      mul r9.z, r9.z, r9.w
      mul r12.xyz, r1.zzzz, r9.zzzz
      lt r9.z, r12.z, l(0.000100)
      iadd r9.w, r4.w, -r9.z
      mov r1.x, r9.y
      mov r4.w, r9.w
      continuec_nz r9.z
      and r9.x, r1.w, r9.x
      and r9.z, r13.w, l(8)
      ult r9.z, l(0), r9.z
      and r9.x, r9.z, r9.x
      if_nz r9.x
        and r9.xz, r13.wwww, l(32, 0, 16, 0)
        ult r9.zw, l(0, 0, 0, 0), r9.xxxz
        ushr r10.w, r13.w, l(5)
        and r10.w, r10.w, l(2)
        or r9.z, r9.w, r9.z
        and r9.z, r1.w, r9.z
        if_nz r9.z
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r13.xyzw, r10.w, l(0), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r14.xyzw, r10.w, l(16), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r15.xyzw, r10.w, l(32), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r16.xyzw, r10.w, l(48), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r17.xyzw, r10.w, l(64), t3.xyzw
          ld_structured_indexable(structured_buffer, stride=96)(mixed,mixed,mixed,mixed) r18.xyzw, r10.w, l(80), t3.xyzw
        else 
          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)
          mov r18.xyzw, l(0,0,0,0)
        endif 
        dp4 r19.x, r8.xyzw, r14.xyzw
        dp4 r19.y, r8.xyzw, r15.xyzw
        dp4 r9.z, r8.xyzw, r16.xyzw
        dp4 r11.w, r8.xyzw, r17.xyzw
        max r11.w, r11.w, l(0.000010)
        div r19.xy, r19.xyxx, r11.wwww
        dp4 r20.x, r7.xyzw, r14.xyzw
        dp4 r20.y, r7.xyzw, r15.xyzw
        dp4 r11.w, r7.xyzw, r16.xyzw
        dp4 r12.w, r7.xyzw, r17.xyzw
        max r12.w, r12.w, l(0.000010)
        div r19.zw, r20.xxxy, r12.wwww
        dp4 r14.x, r2.xyzw, r14.xyzw
        dp4 r14.y, r2.xyzw, r15.xyzw
        dp4 r12.w, r2.xyzw, r16.xyzw
        dp4 r14.z, r2.xyzw, r17.xyzw
        max r14.z, r14.z, l(0.000010)
        div r14.xy, r14.xyxx, r14.zzzz
        if_z r10.w
          mad r14.zw, r19.xxxy, r13.xxxy, l(0.000000, 0.000000, 0.500000, 0.500000)
          round_ni r15.xy, r14.zwzz
          add r14.zw, r14.zzzw, -r15.xxxy
          add r15.xy, r15.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
          mul r15.xy, r13.zwzz, r15.xyxx
          mad r15.zw, -r14.wwwz, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 3.000000, 3.000000)
          mad r16.xy, r14.zwzz, l(2.000000, 2.000000, 0.000000, 0.000000), l(1.000000, 1.000000, 0.000000, 0.000000)
          add r16.zw, -r14.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000)
          div r16.zw, r16.zzzw, r15.wwwz
          div r14.zw, r14.zzzw, r16.xxxy
          add r17.zw, r16.zzzw, l(0.000000, 0.000000, -1.000000, -1.000000)
          add r17.xy, r14.zwzz, l(1.000000, 1.000000, 0.000000, 0.000000)
          mul r14.z, r15.z, r15.w
          mad r20.xyzw, r17.zwxw, r13.zwzw, r15.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r14.w, r20.xyxx, t0.xxxx, s0, r9.z
          mul r15.zw, r15.zzzw, r16.xxxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r16.z, r20.zwzz, t0.xxxx, s0, r9.z
          mul r15.z, r15.z, r16.z
          mad r14.z, r14.z, r14.w, r15.z
          mad r17.xyzw, r17.zyxy, r13.zwzw, r15.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r14.w, r17.xyxx, t0.xxxx, s0, r9.z
          mad r14.z, r15.w, r14.w, r14.z
          mul r14.w, r16.y, r16.x
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r9.z, r17.zwzz, t0.xxxx, s0, r9.z
          mad r9.z, r14.w, r9.z, r14.z
          mad r14.zw, r19.zzzw, r13.xxxy, l(0.000000, 0.000000, 0.500000, 0.500000)
          round_ni r15.xy, r14.zwzz
          add r14.zw, r14.zzzw, -r15.xxxy
          add r15.xy, r15.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
          mul r15.xy, r13.zwzz, r15.xyxx
          mad r15.zw, -r14.wwwz, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 3.000000, 3.000000)
          mad r16.xy, r14.zwzz, l(2.000000, 2.000000, 0.000000, 0.000000), l(1.000000, 1.000000, 0.000000, 0.000000)
          add r16.zw, -r14.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000)
          div r16.zw, r16.zzzw, r15.wwwz
          div r14.zw, r14.zzzw, r16.xxxy
          add r17.zw, r16.zzzw, l(0.000000, 0.000000, -1.000000, -1.000000)
          add r17.xy, r14.zwzz, l(1.000000, 1.000000, 0.000000, 0.000000)
          mul r14.z, r15.z, r15.w
          mad r20.xyzw, r17.zwxw, r13.zwzw, r15.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r14.w, r20.xyxx, t0.xxxx, s0, r11.w
          mul r15.zw, r15.zzzw, r16.xxxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r16.z, r20.zwzz, t0.xxxx, s0, r11.w
          mul r15.z, r15.z, r16.z
          mad r14.z, r14.z, r14.w, r15.z
          mad r17.xyzw, r17.zyxy, r13.zwzw, r15.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r14.w, r17.xyxx, t0.xxxx, s0, r11.w
          mad r14.z, r15.w, r14.w, r14.z
          mul r14.w, r16.y, r16.x
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r11.w, r17.zwzz, t0.xxxx, s0, r11.w
          mad r11.w, r14.w, r11.w, r14.z
          mul r11.w, r11.w, l(0.062500)
          mad r9.z, r9.z, l(0.062500), r11.w
          mad r13.xy, r14.xyxx, r13.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
          round_ni r14.xy, r13.xyxx
          add r13.xy, r13.xyxx, -r14.xyxx
          add r14.xy, r14.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
          mul r14.xy, r13.zwzz, r14.xyxx
          mad r14.zw, -r13.yyyx, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 3.000000, 3.000000)
          mad r15.xy, r13.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(1.000000, 1.000000, 0.000000, 0.000000)
          add r15.zw, -r13.xxxy, l(0.000000, 0.000000, 2.000000, 2.000000)
          div r15.zw, r15.zzzw, r14.wwwz
          div r13.xy, r13.xyxx, r15.xyxx
          add r16.zw, r15.zzzw, l(0.000000, 0.000000, -1.000000, -1.000000)
          add r16.xy, r13.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
          mul r11.w, r14.z, r14.w
          mad r17.xyzw, r16.zwxw, r13.zwzw, r14.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r13.x, r17.xyxx, t0.xxxx, s0, r12.w
          mul r14.zw, r14.zzzw, r15.xxxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r13.y, r17.zwzz, t0.xxxx, s0, r12.w
          mul r13.y, r13.y, r14.z
          mad r11.w, r11.w, r13.x, r13.y
          mad r13.xyzw, r16.zyxy, r13.zwzw, r14.xyxy
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r13.x, r13.xyxx, t0.xxxx, s0, r12.w
          mad r11.w, r14.w, r13.x, r11.w
          mul r13.x, r15.y, r15.x
          sample_c_lz_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r12.w, r13.zwzz, t0.xxxx, s0, r12.w
          mad r11.w, r13.x, r12.w, r11.w
          mad r9.z, r11.w, l(0.062500), r9.z
        else 
          mov r9.z, l(1.000000)
        endif 
        mul r9.z, r12.z, r9.z
        mul r9.z, r9.z, l(0.333333343)
        if_nz r9.x
          if_z r10.w
            mad r13.xy, r19.xyxx, r18.xyxx, r18.zwzz
            sample_l_indexable(texture2d)(float,float,float,float) r13.xyz, r13.xyxx, t0.xyzw, s1, l(0.000000)
          else 
            mov r13.xyz, l(1.000000,0,1.000000,0)
          endif 
          mul r13.xyz, r12.zzzz, r13.xyzx
        else 
          mov r13.xyz, r12.zzzz
        endif 
        movc r12.xyz, r9.wwww, r9.zzzz, r13.xyzx
      endif 
      dp3 r9.x, r10.xyzx, r3.xyzx
      mad r9.x, -cb1[16].y, r9.x, r3.w
      log r9.x, |r9.x|
      mul r9.x, r9.x, l(1.500000)
      exp r9.x, r9.x
      div r9.x, r5.x, r9.x
      mul r9.x, r9.x, l(0.785398185)
      mul r10.xyz, r11.xyzx, r12.xyzx
      mul r10.xyz, r10.xyzx, cb1[18].xxxx
      mad r6.xyz, r10.xyzx, r9.xxxx, r6.xyzx
      iadd r4.w, r4.w, l(1)
      mov r1.x, r9.y
    endloop 
    mul r1.xyz, r6.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 484 instruction slots used