ConsumerGetBuffer

UINT64 __stdcall ConsumerGetBuffer(INT64 a1, UINT64 *a2, CHAR a3){
  int v6; 
  unsigned int v7; 
  unsigned int v8; 
  UINT64 result; 
  int v10; 
  unsigned int v11; 
  unsigned int v12; 
  unsigned int v13; 

  while( _InterlockedCompareExchange((volatile signed __int32 *)(a1 + 24), 1, 0) )
  {
    do
    {
      _mm_pause();
      PopHiberCheckForDebugBreak();
    }
    while( *(_DWORD *)(a1 + 24) );
  }
  while( 1 )
  {
    v6 = *(_DWORD *)(a1 + 48);
    v7 = *(_DWORD *)(a1 + 40) - v6;
    v8 = *(_DWORD *)a2;
    if( !*(_QWORD *)(a1 + 16) )
    {
      if( v8 >= *(_DWORD *)(a1 + 32) - v6 )
        v8 = *(_DWORD *)(a1 + 32) - v6;
      *(_DWORD *)a2 = v8;
    }
    if( v8 <= v7 )
      break;
    if( (a3 & 1) != 0 )
      goto LABEL_5;
    *(_DWORD *)(a1 + 24) = 0;
    do
    {
      _mm_pause();
      PopHiberCheckForDebugBreak();
      v10 = *(_DWORD *)(a1 + 48);
      v11 = *(_DWORD *)(a1 + 40) - v10;
      if( !*(_QWORD *)(a1 + 16) )
      {
        v12 = *(_DWORD *)(a1 + 32) - v10;
        v13 = *(_DWORD *)a2;
        if( *(_DWORD *)a2 >= v12 )
          v13 = v12;
        *(_DWORD *)a2 = v13;
      }
    }
    while( *(_DWORD *)a2 > v11 );
    while( _InterlockedCompareExchange((volatile signed __int32 *)(a1 + 24), 1, 0) )
    {
      do
      {
        _mm_pause();
        PopHiberCheckForDebugBreak();
      }
      while( *(_DWORD *)(a1 + 24) );
    }
  }
  if( !v8 )
  {
LABEL_5:
    result = 0i64;
    goto LABEL_6;
  }
  result = *(_QWORD *)a1 + *(_QWORD *)(a1 + 48) % (unsigned __int64)*(unsigned int *)(a1 + 8);
  *(_QWORD *)(a1 + 48) += v8;
LABEL_6:
  *(_DWORD *)(a1 + 24) = 0;
  return result;
}

Referenced by:

PopRequestWrite