FsRtlAddBaseMcbEntryEx

VOID __stdcall FsRtlAddBaseMcbEntryEx(_BASE_MCB *Mcb, INT64 LargeVbn, INT64 LargeLbn, INT64 LargeSectorCount){
  ULONG PairCount; 
  int v5; 
  int v6; 
  unsigned int v7; 
  unsigned int v8; 
  signed int v10; 
  signed int v11; 
  _DWORD *Mapping; 
  unsigned int v13; 
  unsigned int v14; 
  unsigned int v15; 
  char v16; 
  __int64 v17; 
  __int64 v18; 
  int v19; 
  unsigned int v20; 
  int v21; 
  int v22; 
  _DWORD *v23; 
  char v24; 
  unsigned int v25; 
  unsigned int v26; 
  UINT64 v27; 
  bool v28; 
  unsigned int *v29; 
  unsigned int v30; 
  unsigned int v31; 
  int v32; 
  unsigned int v33; 
  __int64 v34; 
  int v35; 
  int v36; 
  int v37; 
  unsigned int v38; 
  int v39; 
  int v40; 
  __int64 v41; 
  int v42; 
  unsigned int *v43; 
  int v44; 
  char v45; 
  __int64 v46; 
  _DWORD *v47; 
  __int64 v48; 
  int v49; 
  int v50; 
  int v51; 
  int v52; 
  char v53; 
  __int64 v54; 
  char v55; 
  UINT64 v56; 
  int v57; 
  __int64 v58; 
  __int64 v59; 
  int v60; 
  int v61; 
  int v62; 
  char v63; 
  UINT64 v64; 
  int v65; 
  char v66; 
  UINT64 v67; 
  int v68; 
  int v69; 
  int v70; 
  char v71; 
  UINT64 Index; 
  int v73; 
  PairCount = Mcb->PairCount;
  v5 = 0;
  v6 = LargeSectorCount;
  v7 = LargeLbn;
  v8 = LargeVbn;
  v10 = 0;
  v11 = PairCount - 1;
  if( (int)(PairCount - 1) < 0 )
    goto LABEL_7;
  while( 1 )
  {
    Mapping = Mcb->Mapping;
    v13 = (v11 + v10) / 2;
    v14 = v13;
    if( v13 && (unsigned int)LargeVbn < Mapping[2 * v13 - 2] )
    {
      v11 = v13 - 1;
      goto LABEL_6;
    }
    if( (unsigned int)LargeVbn <= Mapping[2 * v13] - 1 )
      break;
    v10 = v13 + 1;
LABEL_6:
    if( v10 > v11 )
      goto LABEL_7;
  }
  v19 = Mapping[2 * v13 + 1];
  LODWORD(Index) = 0;
  v20 = LargeVbn + LargeSectorCount - 1;
  if( v19 == -1 )
  {
    FsRtlFindLargeIndex(Mcb, v20, &Index);
    if( !v53 )
      goto LABEL_7;
    v54 = (unsigned int)(Index - 1);
    if( v14 != (_DWORD)v54 )
      goto LABEL_7;
    v69 = 0;
    if( (_DWORD)Index )
      v69 = Mapping[2 * v54];
    if( Mapping[2 * (unsigned int)Index + 1] == v7 + v69 - v8 )
    {
      if( (_DWORD)Index )
        v70 = Mapping[2 * v54];
      else
        v70 = 0;
      v6 = v70 - v8;
      goto LABEL_7;
    }
    return;
  }
  if( v13 )
    v21 = Mapping[2 * v13 - 2];
  else
    v21 = 0;
  if( v7 != (_DWORD)LargeVbn + v19 - v21 )
    return;
  v22 = Mapping[2 * v13];
  if( v20 <= v22 - 1 )
    return;
  if( v13 < PairCount )
  {
    v8 = Mapping[2 * v13];
    if( v13 == -1 )
      v8 = 0;
  }
  else
  {
    v8 = 0;
  }
  if( v13 )
    v68 = Mapping[2 * v13 - 2];
  else
    v68 = 0;
  v7 = v19 + v22 - v68;
  v6 = v20 - v8 + 1;
LABEL_7:
  v15 = PairCount;
  LODWORD(Index) = PairCount;
  if( !PairCount || (v23 = Mcb->Mapping, v23[2 * PairCount - 2] <= v8) )
  {
LABEL_8:
    if( v15
      && (v47 = Mcb->Mapping, v48 = v15 - 1, v49 = v47[2 * v48], v49 == v8)
      && ((v50 = v47[2 * v48 + 1], v50 == -1) ? (v52 = 0) : (v15 == 1 ? (v51 = 0) : (v51 = v47[2 * v15 - 4]),
                                                             v52 = v49 + v50 - v51),
          v52 == v7) )
    {
      v47[2 * PairCount - 2] += v6;
    }
    else
    {
      if( !v8 )
        goto LABEL_10;
      if( v15 )
        v5 = *((_DWORD *)Mcb->Mapping + 2 * v15 - 2);
      if( v5 == v8 )
      {
LABEL_10:
        FsRtlAddEntry(Mcb, v15, 1ui64);
        if( !v16 )
          return;
        v17 = v15;
      }
      else
      {
        FsRtlAddEntry(Mcb, v15, 2ui64);
        if( !v45 )
          return;
        v46 = 8i64 * v15;
        *(_DWORD *)((char *)Mcb->Mapping + v46 + 4) = -1;
        *(_DWORD *)((char *)Mcb->Mapping + v46) = v8;
        v17 = v15 + 1;
      }
      v18 = 8 * v17;
      *(_DWORD *)((char *)Mcb->Mapping + v18 + 4) = v7;
      *(_DWORD *)((char *)Mcb->Mapping + v18) = v6 + v8;
    }
    return;
  }
  FsRtlFindLargeIndex(Mcb, v8, &Index);
  if( !v24 )
  {
    v15 = Index;
    goto LABEL_8;
  }
  v25 = Index;
  v73 = v6 + v8;
  v26 = v6 + v8 - 1;
  v27 = 2i64 * (unsigned int)Index;
  v28 = v23[v27 + 1] == -1;
  v29 = &v23[v27];
  Index = v27 * 4;
  if( v28 && (!v25 || v23[2 * v25 - 2] <= v8) )
  {
    v30 = *v29 - 1;
    if( v26 <= v30 )
    {
      if( v25 )
        v31 = v23[2 * v25 - 2];
      else
        v31 = 0;
      if( v31 >= v8 || v26 >= v30 )
      {
        if( v25 )
          v32 = v23[2 * v25 - 2];
        else
          v32 = 0;
        if( v26 < v30 && v32 == v8 )
        {
          if( v25 )
          {
            v59 = v25 - 1;
            v60 = v23[2 * v59 + 1];
            if( v60 != -1 )
            {
              if( v25 == 1 )
                v61 = 0;
              else
                v61 = v23[2 * v25 - 4];
              v5 = v23[2 * v59] + v60 - v61;
            }
          }
          if( v5 == v7 )
          {
            if( v25 )
            {
              v23[2 * v25 - 2] += v6;
            }
            else
            {
              FsRtlAddEntry(Mcb, 0i64, 1ui64);
              if( v71 )
              {
                *((_DWORD *)Mcb->Mapping + 1) = v7;
                *(_DWORD *)Mcb->Mapping = v6;
              }
            }
          }
          else
          {
            FsRtlAddEntry(Mcb, v25, 1ui64);
            if( v63 )
            {
              v64 = Index;
              v65 = v73;
              *(_DWORD *)((char *)Mcb->Mapping + Index + 4) = v7;
              *(_DWORD *)((char *)Mcb->Mapping + v64) = v65;
            }
          }
        }
        else
        {
          if( v25 )
            v33 = v23[2 * v25 - 2];
          else
            v33 = 0;
          if( v33 < v8 && v26 == v30 )
          {
            if( v25 >= PairCount - 1 )
              v62 = -1;
            else
              v62 = v23[2 * v25 + 3];
            if( v62 == v6 + v7 )
            {
              *v29 = v8;
              *((_DWORD *)Mcb->Mapping + 2 * v25 + 3) = v7;
            }
            else
            {
              FsRtlAddEntry(Mcb, v25, 1ui64);
              if( v66 )
              {
                v67 = Index;
                *(_DWORD *)((char *)Mcb->Mapping + Index + 4) = -1;
                *(_DWORD *)((char *)Mcb->Mapping + v67) = v8;
                *((_DWORD *)Mcb->Mapping + 2 * v25 + 3) = v7;
              }
            }
          }
          else
          {
            if( v25 )
            {
              v34 = v25 - 1;
              v35 = v23[2 * v34 + 1];
              if( v35 == -1 )
              {
                v37 = 0;
              }
              else
              {
                if( v25 == 1 )
                  v36 = 0;
                else
                  v36 = v23[2 * v25 - 4];
                v37 = v23[2 * v34] + v35 - v36;
              }
            }
            else
            {
              v37 = 0;
            }
            v38 = PairCount - 1;
            if( v37 != v7 || (v25 >= v38 ? (v39 = -1) : (v39 = v23[2 * v25 + 3]), v39 != v6 + v7) )
            {
              if( v25 >= v38 )
                v40 = -1;
              else
                v40 = v23[2 * v25 + 3];
              if( v40 == v6 + v7 )
              {
                v23[2 * v25 + 3] = v7;
              }
              else
              {
                if( !v25 )
                  goto LABEL_88;
                v41 = v25 - 1;
                v42 = v23[2 * v41 + 1];
                v43 = &v23[2 * v41];
                if( v42 != -1 )
                {
                  if( v25 == 1 )
                    v44 = 0;
                  else
                    v44 = v23[2 * v25 - 4];
                  v5 = *v43 + v42 - v44;
                }
                if( v5 != v7 )
                {
LABEL_88:
                  v29[1] = v7;
                  return;
                }
                *v43 = *v29;
              }
              FsRtlRemoveLargeEntry(Mcb, v25, 1ui64);
              return;
            }
            if( v25 )
            {
              v23[2 * v25 - 2] = v23[2 * v25 + 2];
              FsRtlRemoveLargeEntry(Mcb, v25, 2ui64);
            }
            else
            {
              v23[3] = v7;
              FsRtlRemoveLargeEntry(Mcb, 0i64, 1ui64);
            }
          }
        }
      }
      else
      {
        FsRtlAddEntry(Mcb, v25, 2ui64);
        if( v55 )
        {
          v56 = Index;
          v57 = v73;
          *(_DWORD *)((char *)Mcb->Mapping + Index + 4) = -1;
          *(_DWORD *)((char *)Mcb->Mapping + v56) = v8;
          v58 = v25 + 1;
          *((_DWORD *)Mcb->Mapping + 2 * v58 + 1) = v7;
          *((_DWORD *)Mcb->Mapping + 2 * v58) = v57;
        }
      }
    }
  }
}

Referenced by:

FsRtlAddBaseMcbEntry
FsRtlAddLargeMcbEntry