// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:30:56 2016

Buffer<uint3> rUavCounter : register(t0);


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


void main()
{
// Needs manual fix for instruction: 
// unknown dcl_: dcl_uav_structured_opc u0, 16
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

// Needs manual fix for instruction: 
// unknown dcl_: dcl_thread_group 16, 1, 1
  r0.x = rUavCounter.Load(float4(0,0,0,0)).x;
  r0.x = (int)r0.x + 15;
  r0.x = (uint)r0.x >> 4;
  r0.yz = float2(0,0);
  [0].0 = u0.xyz;
  r0.y = vThreadIDInGroupFlattened.x;
  while (true) {
    r0.z = cmp((uint)r0.y >= (uint)r0.x);
    if (r0.z != 0) break;
    // Needs manual fix for instruction:
    imm_atomic_alloc r1.x, u0
    InterlockedExchange ?(dest, value, orig_value);
    r0.y = (int)r0.y + 16;
  }
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// Resource bind info for wUavCounter
// {
//
//   uint4 $Element;                    // Offset:    0 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// rUavCounter                       texture   uint3         buf    0        1
// wUavCounter                           UAV  struct     r/w+cnt    0        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_resource_buffer (uint,uint,uint,uint) t0
dcl_uav_structured_opc u0, 16
dcl_input vThreadIDInGroupFlattened
dcl_temps 2
dcl_thread_group 16, 1, 1
ld_indexable(buffer)(uint,uint,uint,uint) r0.x, l(0, 0, 0, 0), t0.xyzw
iadd r0.x, r0.x, l(15)
ushr r0.x, r0.x, l(4)
mov r0.yz, l(0,1,1,0)
store_structured u0.xyz, l(0), l(0), r0.xyzx
mov r0.y, vThreadIDInGroupFlattened.x
loop 
  uge r0.z, r0.y, r0.x
  breakc_nz r0.z
  imm_atomic_alloc r1.x, u0
  iadd r0.y, r0.y, l(16)
endloop 
ret 
// Approximately 13 instruction slots used

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