CmpUndoDeleteKeyForTrans

INT64 __fastcall CmpUndoDeleteKeyForTrans(INT64 a1, INT64 a2, INT64 a3){
  LIST_ENTRY *v4; 
  CM_KCB_UOW **v5; 
  int v6; 
  LIST_ENTRY *v7; 
  __int64 v8; 
  __int64 v9; 
  __int64 v10; 
  __int64 v11; 
  unsigned int v12; 
  __int64 v13; 
  __int64 v14; 
  __int64 v15; 
  __int64 v16; 
  __int64 v17; 
  __int64 v18; 
  VOID **PoolWithTag; 
  __int64 v20; 
  CM_KCB_UOW **v21; 
  _CM_KCB_UOW *UnitOfWork; 
  unsigned int v23; 
  CM_KCB_UOW *v24; 
  CM_TRANS *v25; 
  __int64 v26; 
  PVOID *v28; 
  unsigned int *v29; 
  LIST_ENTRY *ListIterator; 
  CM_TRANS *CmTrans; 
  __int64 v32; 
  int v33; 
  int v34; 

  CmTrans = (CM_TRANS *)a2;
  ListIterator = 0i64;
  v4 = *(LIST_ENTRY **)(a1 + 72);
  v5 = 0i64;
  v6 = 0;
  v33 = -1;
  v7 = v4 + 13;
  v34 = 0;
  do
  {
    LODWORD(v8) = CmListGetPrevElement(v7, &ListIterator, a3);
    v9 = v8;
    if( !v8 )
      return 3221225524i64;
  }
  while( *(_DWORD *)(v8 + 68) != 3 || *(_QWORD *)(v8 + 88) != a1 );
  ListIterator = 0i64;
  LODWORD(v10) = CmListGetPrevElement((LIST_ENTRY *)(a1 + 208), &ListIterator, a3);
  v13 = v10;
  if( !v10 || *(_DWORD *)(v10 + 68) != 2 )
    return 3221225524i64;
  if( *(_QWORD *)(a1 + 288) == v11 )
  {
    v17 = *(unsigned int *)(a1 + 280);
    LODWORD(ListIterator) = *(_DWORD *)(a1 + 284);
  }
  else
  {
    v14 = *(_QWORD *)(a1 + 32);
    v15 = *(unsigned int *)(a1 + 40);
    v32 = v12;
    v16 = (*(__int64(__fastcall **)(__int64, __int64, __int64 *))(v14 + 8))(v14, v15, &v32);
    if( !v16 )
      return 3221225626i64;
    v17 = *(unsigned int *)(v16 + 36);
    v18 = *(_QWORD *)(a1 + 32);
    LODWORD(ListIterator) = *(_DWORD *)(v16 + 40);
    (*(void(__fastcall **)(__int64, __int64 *))(v18 + 16))(v18, &v32);
  }
  if( (_DWORD)v17 )
  {
    PoolWithTag = ExAllocatePoolWithTag(1ui64, 8i64 * (unsigned int)v17, 926174531i64);
    v5 = (CM_KCB_UOW **)PoolWithTag;
    if( PoolWithTag )
    {
      memset(PoolWithTag, 0i64, 8 * v17);
      v20 = (*(__int64(__fastcall **)(_QWORD, _QWORD, int *))(*(_QWORD *)(a1 + 32) + 8i64))(
              *(_QWORD *)(a1 + 32),
              (unsigned int)ListIterator,
              &v33);
      v32 = v20;
      if( v20 )
      {
        LODWORD(ListIterator) = 0;
        v21 = v5;
        v29 = (unsigned int *)v20;
        while( 1 )
        {
          UnitOfWork = CmpAllocateUnitOfWork();
          *v21 = UnitOfWork;
          if( !UnitOfWork )
            break;
          CmpTransEnlistUowInKcb((_CM_KCB_UOW *__ptr32)UnitOfWork, (_CM_KEY_CONTROL_BLOCK *__ptr32)a1);
          v6 = CmpTransEnlistUowInCmTrans(*v21, CmTrans);
          if( v6 < 0 )
            goto LABEL_31;
          if( !CmpLockIXLockIntent((UINT64 *)(a1 + 248), (INT64)*v21)
            || !CmpLockIXLockExclusive(a1 + 264, (INT64)*v21, 1i64) )
          {
            v6 = -1072103423;
            goto LABEL_31;
          }
          (*v21)->ActionType = UoWDeleteValue;
          v23 = *v29;
          v24 = *v21++;
          ++v29;
          v24->VolatileKeyCell = v23;
          LODWORD(ListIterator) = (_DWORD)ListIterator + 1;
          if( (unsigned int)ListIterator >= (unsigned int)v17 )
          {
            (*(void(__fastcall **)(_QWORD, int *))(*(_QWORD *)(a1 + 32) + 16i64))(*(_QWORD *)(a1 + 32), &v33);
            goto LABEL_20;
          }
        }
        v6 = -1073741670;
LABEL_31:
        v26 = v32;
      }
      else
      {
        v6 = -1073741670;
        v26 = 0i64;
      }
      goto LABEL_21;
    }
    return 3221225626i64;
  }
LABEL_20:
  *(_DWORD *)(v9 + 68) = 13;
  *(_DWORD *)(v13 + 68) = 13;
  v25 = CmTrans;
  *(_DWORD *)(a1 + 280) = 0;
  *(_DWORD *)(a1 + 284) = -1;
  *(_QWORD *)(a1 + 288) = v25;
  v26 = 0i64;
LABEL_21:
  if( v5 )
  {
    if( v6 < 0 && (_DWORD)v17 )
    {
      v28 = (PVOID *)v5;
      do
      {
        if( *v28 )
        {
          CmpRundownUnitOfWork(*v28);
          ExFreePoolWithTag(*v28, 0x77554D43u);
        }
        ++v28;
        --v17;
      }
      while( v17 );
    }
    ExFreePoolWithTag(v5, 0x37344D43u);
  }
  if( v26 )
    (*(void(__fastcall **)(_QWORD, int *))(*(_QWORD *)(a1 + 32) + 16i64))(*(_QWORD *)(a1 + 32), &v33);
  return(unsigned int)v6;
}

Referenced by:

CmpCreateChild