ArbPruneOrdering

__int64 __fastcall ArbPruneOrdering(unsigned __int16 *a1, unsigned __int64 a2, unsigned __int64 a3){
  UINT8 *PoolWithTag; 
  UINT8 *v7; 
  char *v8; 
  __int64 v9; 
  unsigned __int64 *v10; 
  unsigned __int64 i; 
  unsigned __int64 v12; 
  unsigned __int64 v13; 
  unsigned __int64 v14; 
  __int64 v15; 
  UINT8 *v16; 
  __int64 result; 
  unsigned int v18; 
  void *v19; 
  if( a3 < a2 )
  {
    return(unsigned int)-1073741811;
  }
  else
  {
    PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, 32i64 * *a1 + 16, 0x4C627241ui64);
    v7 = PoolWithTag;
    if( PoolWithTag )
    {
      v8 = (char *)PoolWithTag;
      v9 = *a1;
      if( (_WORD)v9 )
      {
        v10 = (unsigned __int64 *)*((_QWORD *)a1 + 1);
        for( i = (unsigned __int64)&v10[2 * v9]; ; i = *((_QWORD *)a1 + 1) + 16i64 * *a1 )
        {
          if( (unsigned __int64)v10 >= i )
            goto LABEL_14;
          v12 = *v10;
          if( a3 < *v10 )
            break;
          v13 = v10[1];
          if( a2 > v13 )
            break;
          if( a2 <= v12 )
          {
            if( a3 < v13 )
            {
              *(_QWORD *)v8 = a3 + 1;
              *((_QWORD *)v8 + 1) = v10[1];
              goto LABEL_9;
            }
          }
          else
          {
            v14 = a2 - 1;
            if( a3 >= v13 )
            {
              *(_QWORD *)v8 = v12;
              *((_QWORD *)v8 + 1) = v14;
              goto LABEL_9;
            }
            *(_QWORD *)v8 = a3 + 1;
            *((_QWORD *)v8 + 1) = v10[1];
            *((_QWORD *)v8 + 2) = *v10;
            *((_QWORD *)v8 + 3) = v14;
            v8 += 32;
          }
LABEL_10:
          v10 += 2;
        }
        *(_OWORD *)v8 = *(_OWORD *)v10;
LABEL_9:
        v8 += 16;
        goto LABEL_10;
      }
LABEL_14:
      v15 = (v8 - (char *)v7) >> 4;
      if( !(_WORD)v15 )
        goto LABEL_18;
      if( (unsigned __int16)v15 <= a1[1] )
      {
        v16 = (UINT8 *)*((_QWORD *)a1 + 1);
LABEL_17:
        memmove(v16, v7, 16i64 * (unsigned __int16)v15);
LABEL_18:
        ExFreePoolWithTag(v7, 0);
        result = 0i64;
        *a1 = v15;
        return result;
      }
      v16 = (UINT8 *)ExAllocatePoolWithTag(PagedPool, 16i64 * (unsigned __int16)v15, 0x4C627241ui64);
      if( v16 )
      {
        v19 = (void *)*((_QWORD *)a1 + 1);
        if( v19 )
          ExFreePoolWithTag(v19, 0);
        *((_QWORD *)a1 + 1) = v16;
        a1[1] = v15;
        goto LABEL_17;
      }
      v18 = -1073741670;
      ExFreePoolWithTag(v7, 0);
    }
    else
    {
      return(unsigned int)-1073741670;
    }
  }
  return v18;
}

Referenced by:

ArbBuildAssignmentOrdering