RtlpCopyBitMapTailToHead

VOID __stdcall RtlpCopyBitMapTailToHead(
        _RTL_BITMAP *Source,
        _RTL_BITMAP *Destination,
        UINT64 TargetBit,
        UINT64 CopyLength){
  unsigned __int64 v4; 
  unsigned __int64 v6; 
  unsigned __int64 v7; 
  UINT64 v8; 
  UINT64 v9; 
  unsigned int *v10; 
  unsigned int *v11; 
  unsigned int *v12; 
  unsigned int v13; 
  char v14; 
  unsigned int *v15; 
  int v16; 
  int v17; 
  int v18; 
  unsigned __int64 v19; 

  v4 = (unsigned __int64)(unsigned int)TargetBit >> 3;
  v6 = (unsigned int)TargetBit;
  if( (TargetBit & 7) != 0 )
  {
    v7 = (unsigned __int64)(unsigned int)CopyLength >> 5;
    v8 = TargetBit & 0x1F;
    v9 = CopyLength & 0x1F;
    v10 = &Destination->Buffer[v7 + (v6 >> 5)];
    v11 = v10;
    v12 = &Source->Buffer[v7];
    if( v9 )
    {
      v13 = *v12;
      v14 = 32 - v8;
      if( v9 > 32 - v8 )
      {
        v10[1] = v10[1] & -(1 << (v8 + v9 - 32)) | ((v13 & (((1 << (v8 + v9 - 32)) - 1) << v14)) >> v14);
        *v10 = ((*v12 & ((1 << v14) - 1)) << v8) | *v10 & ((1 << v8) - 1);
      }
      else
      {
        *v10 = ((v13 & ((1 << v9) - 1)) << v8) | *v10 & ~(((1 << v9) - 1) << v8);
      }
    }
    v15 = v12 - 1;
    if( v7 )
    {
      v16 = *v10;
      v17 = 1 << (32 - v8);
      do
      {
        *v11-- = ((*v15 & ~(v17 - 1)) >> (32 - v8)) | v16 & ~((1 << v8) - 1);
        v18 = (*v15-- & (v17 - 1)) << v8;
        v16 = v18 | ((1 << v8) - 1) & *v11;
        *v11 = v16;
        --v7;
      }
      while( v7 );
    }
  }
  else
  {
    v19 = (unsigned __int64)(unsigned int)CopyLength >> 3;
    if( (CopyLength & 7) != 0 )
      *((_BYTE *)Destination->Buffer + v4 + v19) = ((1 << (CopyLength & 7)) - 1) & *((_BYTE *)Source->Buffer + v19) | *((_BYTE *)Destination->Buffer + v4 + v19) & ~((1 << (CopyLength & 7)) - 1);
    if( v19 )
      memmove((char *)Destination->Buffer + v4, Source->Buffer, v19);
  }
}

Referenced by:

RtlCopyBitMap