CmpTransMgrFreeVolatileData

void __fastcall CmpTransMgrFreeVolatileData(__int64 a1, int a2){
  ULONG_PTR v4; 
  int v5; 
  UINT64 v6; 
  UINT64 v7; 
  UINT64 v8; 
  unsigned int v9; 
  UINT64 v10; 
  __int64 v11; 
  int v12; 
  UINT64 v13; 
  UINT64 v14; 
  INT64 a1a[2]; 
  int v16; 
  int v17; 
  *(_OWORD *)a1a = 0i64;
  CmpInitializeDelayDerefContext(a1a);
  while( *(_QWORD *)(a1 + 16) != a1 + 16 )
  {
    v4 = *(_QWORD *)(a1 + 24);
    if( !*(_QWORD *)(*(_QWORD *)(v4 + 48) + 32i64) )
      goto LABEL_10;
    CmpLockRegistryExclusive();
    v5 = *(_DWORD *)(v4 + 68);
    if( !v5 )
    {
      v8 = *(unsigned int *)(v4 + 88);
      if( (unsigned int)(v8 - 1) <= 0xFFFFFFFD )
        CmpFreeKeyByCell(*(_HHIVE **)(*(_QWORD *)(v4 + 48) + 32i64), v8, 0);
      goto LABEL_9;
    }
    if( v5 > 3 )
    {
      if( v5 <= 5 )
      {
        CmpFreeValue(*(_QWORD *)(*(_QWORD *)(v4 + 48) + 32i64), *(unsigned int *)(v4 + 92));
      }
      else
      {
        if( v5 != 9 )
        {
          if( v5 != 12 )
            goto LABEL_9;
          v13 = *(unsigned int *)(v4 + 96);
          if( (unsigned int)(v13 - 1) > 0xFFFFFFFD )
            goto LABEL_9;
          v14 = *(_QWORD *)(*(_QWORD *)(v4 + 48) + 32i64);
LABEL_27:
          HvFreeCell(v14, v13);
          goto LABEL_9;
        }
        v16 = -1;
        v9 = *(_DWORD *)(v4 + 96);
        v17 = 0;
        v10 = *(_QWORD *)(*(_QWORD *)(v4 + 48) + 32i64);
        v11 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(v10 + 8))(v10, v9, &v16);
        if( v11 )
        {
          if( !HvMarkCellDirty(v10, v9, 1) )
            goto LABEL_31;
          v12 = *(_DWORD *)(v11 + 12);
          if( v12 != 1 )
          {
            *(_DWORD *)(v11 + 12) = v12 - 1;
LABEL_31:
            (*(void(__fastcall **)(UINT64, int *))(v10 + 16))(v10, &v16);
            goto LABEL_9;
          }
          (*(void(__fastcall **)(UINT64, int *))(v10 + 16))(v10, &v16);
          CmpRemoveSecurityCellList((_HHIVE *)v10, v9);
          v13 = v9;
          v14 = v10;
          goto LABEL_27;
        }
      }
    }
LABEL_9:
    CmpUnlockRegistry();
LABEL_10:
    CmpLockRegistry();
    v6 = *(_QWORD *)(v4 + 48);
    CmpLockHashEntryExclusiveByKcb((_CM_KEY_CONTROL_BLOCK *)v6);
    CmpLockKcbExclusive(v6);
    if( *(_QWORD *)(v6 + 288) == a1 )
    {
      v7 = *(unsigned int *)(v6 + 284);
      if( (_DWORD)v7 != -1 )
      {
        HvFreeCell(*(_QWORD *)(v6 + 32), v7);
        *(_DWORD *)(v6 + 280) = 0;
        *(_DWORD *)(v6 + 284) = -1;
      }
      *(_QWORD *)(v6 + 288) = 0i64;
    }
    if( CmEqualTrans(*(_QWORD *)(v6 + 240), a1) )
    {
      if( a2 == 8 )
      {
        CmpFlushNotifiesOnKeyBodyList(v6, 8i64, (INT64)a1a, 0);
        *(_WORD *)(v6 + 8) |= 0x20u;
        CmpMarkKeyUnbacked((_CM_KEY_CONTROL_BLOCK *)v6);
        if( (*(_DWORD *)(v6 + 8) & 0x20000) == 0 )
          CmpDiscardKcb(v6, (INT64)a1a);
      }
      *(_QWORD *)(v6 + 240) = 0i64;
    }
    if( *(_DWORD *)(v6 + 40) != -1 )
    {
      if( *(_QWORD *)(v6 + 32) )
        CmpRebuildKcbCache((_CM_KEY_CONTROL_BLOCK *)v6);
    }
    CmpReferenceKeyControlBlockUnsafe((volatile INT64 *)v6);
    CmpRundownUnitOfWork(v4);
    CmpFreeUnitOfWork((void *)v4);
    CmpUnlockKcb(v6);
    CmpUnlockHashEntryByKcb(v6);
    CmpDereferenceKeyControlBlock(v6);
    CmpDrainDelayDerefContext((UINT64 **)a1a);
    CmpUnlockRegistry();
  }
}

Referenced by:

CmRmFinalizeRecovery
CmpCleanupLightWeightTransaction
CmpRmUnDoPhase