ArbpUpdatePriority

__int64 __fastcall ArbpUpdatePriority(__int64 a1, __int64 *a2){
  int v4; 
  __int64 result; 
  char v6; 
  unsigned __int64 *v7; 
  unsigned __int64 *v8; 
  unsigned __int64 v9; 
  unsigned __int64 v10; 
  unsigned __int64 v11; 
  bool v12; 
  unsigned __int64 v13; 
  __int64 v14; 
  int v15; 
  v4 = *((_DWORD *)a2 + 8);
  result = (unsigned int)(v4 - 2147483645);
  if( (unsigned int)result <= 1 )
    goto LABEL_22;
  v6 = *(_BYTE *)a2[5] & 1;
  if( v4 )
  {
    result = *((unsigned int *)a2 + 9);
    if( (result & 2) == 0 )
    {
      v7 = *(unsigned __int64 **)(a1 + 64);
      v15 = v4 - 1;
      if( v4 <= 0 )
        v15 = ~v4;
      v8 = &v7[2 * (unsigned int)(v15 + 1)];
      goto LABEL_4;
    }
LABEL_22:
    *((_DWORD *)a2 + 8) = 0x7FFFFFFF;
    return result;
  }
  v7 = *(unsigned __int64 **)(a1 + 64);
  v8 = v7;
LABEL_4:
  v9 = (unsigned __int64)&v7[2 * *(unsigned __int16 *)(a1 + 56)];
  if( (unsigned __int64)v8 >= v9 )
  {
LABEL_10:
    result = 2147483646 - (unsigned int)(v6 != 0);
    *((_DWORD *)a2 + 8) = result;
    return result;
  }
  v10 = *a2;
  while( 1 )
  {
    v11 = *v8;
    v12 = *v8 < v10;
    if( *v8 <= v10 )
      break;
    if( a2[1] >= v11 )
    {
      v12 = v11 < v10;
      break;
    }
LABEL_9:
    v8 += 2;
    if( (unsigned __int64)v8 >= v9 )
      goto LABEL_10;
  }
  if( v12 && v8[1] < v10 )
    goto LABEL_9;
  v13 = a2[1];
  if( v13 >= v8[1] )
    v13 = v8[1];
  v14 = *a2;
  if( v10 <= v11 )
    v14 = *v8;
  if( v13 - v14 + 1 < a2[2] )
    goto LABEL_9;
  result = (unsigned int)(((char *)v8 - (char *)v7) >> 4) + 1;
  *((_DWORD *)a2 + 8) = result;
  if( v6 )
    *((_DWORD *)a2 + 8) = -((((char *)v8 - (char *)v7) >> 4) + 1);
  return result;
}

Referenced by:

ArbGetNextAllocationRange