// asmtool.py --auto-fix-vertex-halo -i --only-autofixed 41d20c3971827464-vs.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.4 on Mon Mar 05 05:00:57 2018
//
//
// Buffer Definitions:
//
// cbuffer vector_register_block
// {
//
//   float4 gPosOffsetScale;            // Offset:    0 Size:    16
//
// }
//
// cbuffer bool_register_block
// {
//
//   bool gUseMultiUV;                  // Offset:    0 Size:     4 [unused]
//   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 [unused]
//   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 [unused]
//
// }
//
// cbuffer model_low_frequency_block
// {
//
//   row_major float4x4 gViewProjection;// Offset:    0 Size:    64
//
// }
//
// cbuffer skinning_matrix_block
// {
//
//   row_major float3x4 gSkinningMatrices[256];// Offset:    0 Size: 12288
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// vector_register_block             cbuffer      NA          NA    0        1
// 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
// NORMAL                   0   xyz         1     NONE   float   xyz
// BLENDWEIGHT              0   xyzw        2     NONE   float   xyzw
// BLENDWEIGHT              1   xyzw        3     NONE   float   xyzw
// BLENDWEIGHT              2   xyzw        4     NONE   float   xyzw
// BLENDINDICES             0   xyzw        5     NONE    uint   xyzw
// BLENDINDICES             1   xyzw        6     NONE    uint   xyzw
// BLENDINDICES             2   xyzw        7     NONE    uint   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 1   xyzw        1     NONE   float   xyzw
// TEXCOORD                 2   xyzw        2     NONE   float   xyzw
// POSITION                 0   xyzw        3     NONE   float
//
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 cb0[1], immediateIndexed
dcl_constantbuffer cb1[3], immediateIndexed
dcl_constantbuffer cb7[4], immediateIndexed
dcl_constantbuffer cb9[4], immediateIndexed
dcl_constantbuffer cb2[768], dynamicIndexed
dcl_input v0.xyz
dcl_input v1.xyz
dcl_input v2.xyzw
dcl_input v3.xyzw
dcl_input v4.xyzw
dcl_input v5.xyzw
dcl_input v6.xyzw
dcl_input v7.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.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, v5.x, l(3)
  mul r0.yzw, v2.xxxx, cb2[r0.x + 0].xxyz
  mov r1.x, l(0)
  mul r1.yzw, v2.xxxx, cb2[r0.x + 1].xxyz
  mul r2.xyz, v2.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, v5.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, v2.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), v3.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, v6.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, v3.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), v4.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, v7.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, v4.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.xyz, r1.xyzx, r2.xyzx
  mul r1.xyzw, r0.yyyy, cb9[1].xyzw
  mad r1.xyzw, r0.xxxx, cb9[0].xyzw, r1.xyzw
  mad r1.xyzw, r0.zzzz, cb9[2].xyzw, r1.xyzw
  add r1.xyzw, r1.xyzw, cb9[3].xyzw
  dp3 r2.x, r4.xyzx, v1.xyzx
  dp3 r2.y, r5.xyzx, v1.xyzx
  dp3 r2.z, r6.xyzx, v1.xyzx
  dp3 r0.w, r2.xyzx, r2.xyzx
  rsq r0.w, r0.w
  mul r2.xyz, r0.wwww, r2.xyzx
else
  mul r3.xyz, v0.yyyy, cb7[1].xyzx
  mad r3.xyz, v0.xxxx, cb7[0].xyzx, r3.xyzx
  mad r3.xyz, v0.zzzz, cb7[2].xyzx, r3.xyzx
  add r0.xyz, r3.xyzx, cb7[3].xyzx
  mul r3.xyzw, r0.yyyy, cb9[1].xyzw
  mad r3.xyzw, r0.xxxx, cb9[0].xyzw, r3.xyzw
  mad r3.xyzw, r0.zzzz, cb9[2].xyzw, r3.xyzw
  add r1.xyzw, r3.xyzw, cb9[3].xyzw
  mul r3.xyz, v1.yyyy, cb7[1].xyzx
  mad r3.xyz, v1.xxxx, cb7[0].xyzx, r3.xyzx
  mad r3.xyz, v1.zzzz, cb7[2].xyzx, r3.xyzx
  dp3 r0.w, r3.xyzx, r3.xyzx
  rsq r0.w, r0.w
  mul r2.xyz, r0.wwww, r3.xyzx
endif
mad r0.xyz, r2.xyzx, cb0[0].xxxx, r0.xyzx
mul r2.xyzw, r0.yyyy, cb9[1].xyzw
mad r2.xyzw, r0.xxxx, cb9[0].xyzw, r2.xyzw
mad r0.xyzw, r0.zzzz, cb9[2].xyzw, r2.xyzw
add o1.xyzw, r0.xyzw, cb9[3].xyzw

// 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 41d20c3971827464-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

mov o2.xyw, r1.xyxw
add o2.z, r1.z, cb0[0].y

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

ret
// Approximately 150 instruction slots used