CmpRunDownCmRM

void __fastcall CmpRunDownCmRM(__int64 *a1, char a2){
  _ETHREAD *CurrentThread; 
  __int64 *v5; 
  __int64 *v6; 
  __int64 *v7; 
  _ETHREAD *v8; 
  __int64 v9; 
  __int64 **v10; 
  __int64 v11; 
  UINT64 v12; 
  UINT64 v13; 
  __int64 *v14; 
  __int64 **v15; 
  __int64 ***v16; 
  __int64 **v17; 
  __int64 **v18; 
  __int64 **v19; 

  if( a1 && !*((_DWORD *)a1 + 16) )
  {
    v19 = (__int64 **)&v18;
    v18 = (__int64 **)&v18;
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    --CurrentThread->Tcb.KernelApcDisable;
    ExAcquireFastMutexUnsafe((PFAST_MUTEX)((char *)&CmpDummyThreadEvent + 64));
    v5 = (__int64 *)*(&CmpDummyThreadEvent + 32);
    while( v5 != (__int64 *)((char *)&CmpDummyThreadEvent + 256) )
    {
      v14 = v5;
      v15 = (__int64 **)v5;
      v5 = (__int64 *)*v5;
      if( (__int64 *)v14[4] == a1 )
      {
        if( (__int64 *)v5[1] != v14 )
          goto LABEL_26;
        v16 = (__int64 ***)v14[1];
        if( *v16 != v15 )
          goto LABEL_26;
        *v16 = (__int64 **)v5;
        v5[1] = (__int64)v16;
        v17 = v19;
        if( *v19 != (__int64 *)&v18 )
          goto LABEL_26;
        v15[1] = (__int64 *)v19;
        *v15 = (__int64 *)&v18;
        *v17 = (__int64 *)v15;
        v19 = v15;
      }
    }
    ExReleaseFastMutexUnsafe((PFAST_MUTEX)((char *)&CmpDummyThreadEvent + 64));
    KeLeaveCriticalRegionThread(KeGetCurrentThread());
    while( 1 )
    {
      v6 = (__int64 *)v18;
      if( v18[1] != (__int64 *)&v18 )
        goto LABEL_26;
      v7 = *v18;
      if( (__int64 **)(*v18)[1] != v18 )
        goto LABEL_26;
      v18 = (__int64 **)*v18;
      v7[1] = (__int64)&v18;
      if( v6 == (__int64 *)&v18 )
        break;
      CmpCleanupTransactionState(a1, v6 - 4, 4i64);
    }
    v8 = (_ETHREAD *)KeGetCurrentThread();
    --v8->Tcb.KernelApcDisable;
    ExAcquireFastMutexUnsafe(&CmpRmListLock);
    *((_DWORD *)a1 + 26) |= 8u;
    v9 = *a1;
    if( *(__int64 **)(*a1 + 8) != a1 || (v10 = (__int64 **)a1[1], *v10 != a1) )
LABEL_26:
      __fastfail(3u);
    *v10 = (__int64 *)v9;
    *(_QWORD *)(v9 + 8) = v10;
    v11 = a1[10];
    if( v11 )
    {
      *(_QWORD *)(v11 + 4192) = 0i64;
      a1[10] = 0i64;
    }
    ExReleaseFastMutexUnsafe(&CmpRmListLock);
    KeLeaveCriticalRegionThread(KeGetCurrentThread());
    v12 = a1[7];
    if( v12 )
    {
      ObDereferenceObjectDeferDelete(v12);
      a1[7] = 0i64;
    }
    v13 = a1[5];
    if( v13 )
    {
      ObDereferenceObjectDeferDelete(v13);
      a1[5] = 0i64;
    }
    if( a2 == 1 )
      CmpDelayFreeCmRm(a1);
  }
}

Referenced by:

CmShutdownCmRM