// asmtool.py --auto-fix-vertex-halo -i --only-autofixed 2bb472d1779a98f1-vs.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.4 on Mon Mar 05 05:00:59 2018
//
//
// Buffer Definitions:
//
// cbuffer bool_register_block
// {
//
//   bool gUseMultiUV;                  // Offset:    0 Size:     4
//   bool gPointLightEnable0;           // Offset:    4 Size:     4 [unused]
//   bool gPointLightEnable1;           // Offset:    8 Size:     4 [unused]
//   bool gPointLightEnable2;           // Offset:   12 Size:     4 [unused]
//   bool gPointLightEnable3;           // Offset:   16 Size:     4 [unused]
//   bool gEnvMappingEnable;            // Offset:   20 Size:     4 [unused]
//   bool gShadowEnable;                // Offset:   24 Size:     4 [unused]
//   bool gLightScatterEnable;          // Offset:   28 Size:     4 [unused]
//   bool gFogEnable;                   // Offset:   32 Size:     4 [unused]
//   bool gVertexBlendEnable2;          // Offset:   40 Size:     4
//   bool gVertexBlendEnable3;          // Offset:   44 Size:     4 [unused]
//   bool gVertexBlendEnable4;          // Offset:   48 Size:     4 [unused]
//   bool gUseInputVertexColor;         // Offset:   52 Size:     4
//   int2 bool_register_block_padding;  // Offset:   56 Size:     8 [unused]
//
// }
//
// cbuffer model_high_frequency_block
// {
//
//   row_major float4x4 gStaticTransformMatrix;// Offset:    0 Size:    64
//   float4 gUVOffset0;                 // Offset:   64 Size:    16
//   float4 gUVOffset1;                 // Offset:   80 Size:    16
//   float4 gUVOffset2;                 // Offset:   96 Size:    16
//   float4 gShadowVector;              // Offset:  112 Size:    16 [unused]
//   float4 gShadowOffset;              // Offset:  128 Size:    16 [unused]
//
// }
//
// cbuffer model_low_frequency_block
// {
//
//   row_major float4x4 gViewProjection;// Offset:    0 Size:    64
//   float4 gEyePosition;               // Offset:   64 Size:    16 [unused]
//   row_major float4x4 gViewMatrix;    // Offset:   80 Size:    64 [unused]
//   row_major float4x4 gShadowMatrix;  // Offset:  144 Size:    64 [unused]
//   float4 gClipPlane0;                // Offset:  208 Size:    16 [unused]
//   float4 gLScatterSunColor;          // Offset:  224 Size:    16 [unused]
//   float4 gLScatterSunDir;            // Offset:  240 Size:    16 [unused]
//   float4 gLScatterOutTmp;            // Offset:  256 Size:    16 [unused]
//   float4 gLScatterRayTmp;            // Offset:  272 Size:    16 [unused]
//   float4 gLScatterMieTmp;            // Offset:  288 Size:    16 [unused]
//   float4 gFogMiddle;                 // Offset:  304 Size:    16 [unused]
//   float4 gFogFarMiddle;              // Offset:  320 Size:    16 [unused]
//   float4 gFogDistance;               // Offset:  336 Size:    16 [unused]
//   float4 gFogDensity;                // Offset:  352 Size:    16 [unused]
//   float4 gHeightFogMiddle;           // Offset:  368 Size:    16 [unused]
//   float4 gHeightFogFarMiddle;        // Offset:  384 Size:    16 [unused]
//   float4 gHeightFogDistance;         // Offset:  400 Size:    16 [unused]
//   float4 gHeightFogDensity;          // Offset:  416 Size:    16 [unused]
//   row_major float4x4 gSecondShadowMatrix;// Offset:  432 Size:    64 [unused]
//
// }
//
// cbuffer skinning_matrix_block
// {
//
//   row_major float3x4 gSkinningMatrices[256];// Offset:    0 Size: 12288
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// bool_register_block               cbuffer      NA          NA    1        1
// skinning_matrix_block             cbuffer      NA          NA    2        1
// model_high_frequency_block        cbuffer      NA          NA    7        1
// model_low_frequency_block         cbuffer      NA          NA    9        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz
// COLOR                    0   xyzw        1     NONE   float   xyz
// TEXCOORD                 0   xyzw        2     NONE   float   xy
// TEXCOORD                 1   xyzw        3     NONE   float   xyzw
// TEXCOORD                 2   xyzw        4     NONE   float   xyzw
// NORMAL                   0   xyz         5     NONE   float   xyz
// TANGENT                  0   xyzw        6     NONE   float   xyzw
// BLENDWEIGHT              0   xyzw        7     NONE   float   xyzw
// BLENDWEIGHT              1   xyzw        8     NONE   float   xyzw
// BLENDWEIGHT              2   xyzw        9     NONE   float   xyzw
// BLENDINDICES             0   xyzw       10     NONE    uint   xyzw
// BLENDINDICES             1   xyzw       11     NONE    uint   xyzw
// BLENDINDICES             2   xyzw       12     NONE    uint   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// COLOR                    1   xyzw        1     NONE   float   xyzw
// COLOR                    0   xyz         2     NONE   float   xyz
// TEXCOORD                 0   xyzw        3     NONE   float   xyzw
// TEXCOORD                 1   xyzw        4     NONE   float   xyzw
// TEXCOORD                 2   xyzw        5     NONE   float   xyzw
// TEXCOORD                 3   xyzw        6     NONE   float   xyzw
// TEXCOORD                 4   xyzw        7     NONE   float   xyzw
// TEXCOORD                 5   xyzw        8     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_immediateConstantBuffer { { 1.000000, 0, 0, 0},
                              { 0, 1.000000, 0, 0},
                              { 0, 0, 1.000000, 0},
                              { 0, 0, 0, 1.000000} }
dcl_constantbuffer cb1[4], immediateIndexed
dcl_constantbuffer cb7[7], immediateIndexed
dcl_constantbuffer cb9[4], immediateIndexed
dcl_constantbuffer cb2[768], dynamicIndexed
dcl_input v0.xyz
dcl_input v1.xyz
dcl_input v2.xy
dcl_input v3.xyzw
dcl_input v4.xyzw
dcl_input v5.xyz
dcl_input v6.xyzw
dcl_input v7.xyzw
dcl_input v8.xyzw
dcl_input v9.xyzw
dcl_input v10.xyzw
dcl_input v11.xyzw
dcl_input v12.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyz
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_output o5.xyzw
dcl_output o6.xyzw
dcl_output o7.xyzw
dcl_output o8.xyzw
dcl_temps 12
// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125

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

if_nz cb1[2].z
  imul null, r0.x, v10.x, l(3)
  mul r0.yzw, v7.xxxx, cb2[r0.x + 0].xxyz
  mov r1.x, l(0)
  mul r1.yzw, v7.xxxx, cb2[r0.x + 1].xxyz
  mul r2.xyz, v7.xxxx, cb2[r0.x + 2].xyzx
  mov r3.w, l(0)
  mov r4.xyz, r0.yzwy
  mov r5.xyz, r1.yzwy
  mov r6.xyz, r2.xyzx
  mov r7.xyz, r1.xxxx
  mov r8.x, l(1)
  loop
    ige r2.w, r8.x, l(4)
    breakc_nz r2.w
    iadd r8.xyz, r8.xxxx, l(1, -1, -4, 0)
    ineg r2.w, r8.y
    ult r9.xy, r8.yyyy, l(1, 2, 0, 0)
    and r9.z, r2.w, r9.y
    movc r9.w, r9.y, l(0), r8.z
    and r3.xyz, r9.xzwx, v10.yzwy
    or r3.xy, r3.ywyy, r3.xzxx
    or r2.w, r3.y, r3.x
    imul null, r2.w, r2.w, l(3)
    add r3.x, -cb2[r0.x + 0].w, cb2[r2.w + 0].w
    add r3.y, -cb2[r0.x + 1].w, cb2[r2.w + 1].w
    add r3.z, -cb2[r0.x + 2].w, cb2[r2.w + 2].w
    dp3 r4.w, v7.yzwy, icb[r8.y + 0].xyzx
    mad r4.xyz, cb2[r2.w + 0].xyzx, r4.wwww, r4.xyzx
    mad r5.xyz, cb2[r2.w + 1].xyzx, r4.wwww, r5.xyzx
    mad r6.xyz, cb2[r2.w + 2].xyzx, r4.wwww, r6.xyzx
    mad r7.xyz, r3.xyzx, r4.wwww, r7.xyzx
  endloop
  lt r0.y, l(0.000000), v8.x
  if_nz r0.y
    mov r0.yzw, r4.xxyz
    mov r1.xyz, r5.xyzx
    mov r2.xyz, r6.xyzx
    mov r3.xyz, r7.xyzx
    mov r1.w, l(0)
    loop
      ige r2.w, r1.w, l(4)
      breakc_nz r2.w
      ineg r2.w, r1.w
      ult r8.xyz, r1.wwww, l(1, 2, 3, 0)
      and r9.y, r2.w, r8.y
      iadd r10.xy, r1.wwww, l(-3, 1, 0, 0)
      movc r9.z, r8.y, l(0), r10.x
      ieq r9.w, r8.z, l(0)
      mov r9.x, r8.x
      and r8.xyzw, r9.xyzw, v11.xyzw
      or r8.xy, r8.ywyy, r8.xzxx
      or r2.w, r8.y, r8.x
      imul null, r2.w, r2.w, l(3)
      add r8.x, -cb2[r0.x + 0].w, cb2[r2.w + 0].w
      add r8.y, -cb2[r0.x + 1].w, cb2[r2.w + 1].w
      add r8.z, -cb2[r0.x + 2].w, cb2[r2.w + 2].w
      dp4 r3.w, v8.xyzw, icb[r1.w + 0].xyzw
      mad r0.yzw, cb2[r2.w + 0].xxyz, r3.wwww, r0.yyzw
      mad r1.xyz, cb2[r2.w + 1].xyzx, r3.wwww, r1.xyzx
      mad r2.xyz, cb2[r2.w + 2].xyzx, r3.wwww, r2.xyzx
      mad r3.xyz, r8.xyzx, r3.wwww, r3.xyzx
      mov r1.w, r10.y
    endloop
    mov r4.xyz, r0.yzwy
    mov r5.xyz, r1.xyzx
    mov r6.xyz, r2.xyzx
    mov r7.xyz, r3.xyzx
    lt r0.y, l(0.000000), v9.x
    if_nz r0.y
      mov r0.yzw, r4.xxyz
      mov r1.xyz, r5.xyzx
      mov r2.xyz, r6.xyzx
      mov r3.xyz, r7.xyzx
      mov r1.w, l(0)
      loop
        ige r2.w, r1.w, l(4)
        breakc_nz r2.w
        ineg r2.w, r1.w
        ult r8.xyz, r1.wwww, l(1, 2, 3, 0)
        and r9.y, r2.w, r8.y
        iadd r10.xy, r1.wwww, l(-3, 1, 0, 0)
        movc r9.z, r8.y, l(0), r10.x
        ieq r9.w, r8.z, l(0)
        mov r9.x, r8.x
        and r8.xyzw, r9.xyzw, v12.xyzw
        or r8.xy, r8.ywyy, r8.xzxx
        or r2.w, r8.y, r8.x
        imul null, r2.w, r2.w, l(3)
        add r8.x, -cb2[r0.x + 0].w, cb2[r2.w + 0].w
        add r8.y, -cb2[r0.x + 1].w, cb2[r2.w + 1].w
        add r8.z, -cb2[r0.x + 2].w, cb2[r2.w + 2].w
        dp4 r3.w, v9.xyzw, icb[r1.w + 0].xyzw
        mad r0.yzw, cb2[r2.w + 0].xxyz, r3.wwww, r0.yyzw
        mad r1.xyz, cb2[r2.w + 1].xyzx, r3.wwww, r1.xyzx
        mad r2.xyz, cb2[r2.w + 2].xyzx, r3.wwww, r2.xyzx
        mad r3.xyz, r8.xyzx, r3.wwww, r3.xyzx
        mov r1.w, r10.y
      endloop
      mov r4.xyz, r0.yzwy
      mov r5.xyz, r1.xyzx
      mov r6.xyz, r2.xyzx
      mov r7.xyz, r3.xyzx
    endif
  endif
  dp3 r0.y, v0.xyzx, r4.xyzx
  add r1.x, r7.x, r0.y
  dp3 r0.y, v0.xyzx, r5.xyzx
  add r1.y, r7.y, r0.y
  dp3 r0.y, v0.xyzx, r6.xyzx
  add r1.z, r7.z, r0.y
  mov r2.x, cb2[r0.x + 0].w
  mov r2.y, cb2[r0.x + 1].w
  mov r2.z, cb2[r0.x + 2].w
  add r0.xyw, r1.xzxy, r2.xzxy
  mul r1.xyzw, r0.wwww, cb9[1].xyzw
  mad r1.xyzw, r0.xxxx, cb9[0].xyzw, r1.xyzw
  mad r1.xyzw, r0.yyyy, cb9[2].xyzw, r1.xyzw
  add r1.xyzw, r1.xyzw, cb9[3].xyzw
  dp3 r2.x, r4.xyzx, v5.xyzx
  dp3 r2.y, r5.xyzx, v5.xyzx
  dp3 r2.z, r6.xyzx, v5.xyzx
  dp3 r2.w, r2.xyzx, r2.xyzx
  rsq r2.w, r2.w
  mul r2.xyz, r2.wwww, r2.xyzx
  dp3 r3.x, r4.xyzx, v6.xyzx
  dp3 r3.y, r5.xyzx, v6.xyzx
  dp3 r3.z, r6.xyzx, v6.xyzx
  dp3 r3.w, r3.xyzx, r3.xyzx
  rsq r3.w, r3.w
  mul r3.xyz, r3.wwww, r3.xyzx
  mov r3.w, r0.x
  mov r2.w, r0.y
else
  mul r4.xyz, v0.yyyy, cb7[1].xyzx
  mad r4.xyz, v0.xxxx, cb7[0].xyzx, r4.xyzx
  mad r4.xyz, v0.zzzz, cb7[2].xyzx, r4.xyzx
  add r0.xyw, r4.xzxy, cb7[3].xzxy
  mul r4.xyzw, r0.wwww, cb9[1].xyzw
  mad r4.xyzw, r0.xxxx, cb9[0].xyzw, r4.xyzw
  mad r4.xyzw, r0.yyyy, cb9[2].xyzw, r4.xyzw
  add r1.xyzw, r4.xyzw, cb9[3].xyzw
  mul r4.xyz, v5.yyyy, cb7[1].xyzx
  mad r4.xyz, v5.xxxx, cb7[0].xyzx, r4.xyzx
  mad r4.xyz, v5.zzzz, cb7[2].xyzx, r4.xyzx
  dp3 r4.w, r4.xyzx, r4.xyzx
  rsq r4.w, r4.w
  mul r2.xyz, r4.wwww, r4.xyzx
  mul r4.xyz, v6.yyyy, cb7[1].xyzx
  mad r4.xyz, v6.xxxx, cb7[0].xyzx, r4.xyzx
  mad r4.xyz, v6.zzzz, cb7[2].xyzx, r4.xyzx
  dp3 r4.w, r4.xyzx, r4.xyzx
  rsq r4.w, r4.w
  mul r3.xyz, r4.wwww, r4.xyzx
  mov r3.w, r0.x
  mov r2.w, r0.y
endif
mul r4.xyz, r2.zxyz, r3.yzxy
mad r4.xyz, r2.yzxy, r3.zxyz, -r4.xyzx
mul r0.xyz, r4.xyzx, v6.wwww
add r4.xyzw, v3.xyzw, cb7[5].xyzw
add r5.xyzw, v4.xyzw, cb7[6].xyzw
add r6.xyzw, v2.xyxy, cb7[4].xyxy
movc o4.xyzw, cb1[0].xxxx, r4.xyzw, r6.xyzw
movc o5.xyzw, cb1[0].xxxx, r5.xyzw, r6.xyzw
movc o2.xyz, cb1[3].yyyy, v1.xyzx, l(1.000000,1.000000,1.000000,0)

// Relocated to here with asmtool.py
mov o0.xyzw, r1.xyzw

// Automatic vertex shader halo fix inserted with DarkStarSword's asmtool.py:
// asmtool.py --auto-fix-vertex-halo -i --only-autofixed 2bb472d1779a98f1-vs.txt
ne r11.w, r1.w, l(1.0)
if_nz r11.w
  add r11.w, r1.w, -r11.y
  mad r1.x, r11.w, r11.x, r1.x
endif

mul r4.xyz, r1.xywx, l(0.500000, 0.500000, 0.500000, 0.000000)
add o3.xy, r4.zzzz, r4.xyxx

// mov o0.xyzw, r1.xyzw // Relocated from here with asmtool.py

mov o1.xyzw, l(0,0,0,0)
mov o3.zw, r1.zzzw
mov o6.xyzw, r3.xyzw
mov o7.xyzw, r0.xyzw
mov o8.xyzw, r2.xyzw
ret
// Approximately 175 instruction slots used