IopFreeIrp

VOID __stdcall IopFreeIrp(_IRP *Irp){
  CHAR v1; 
  unsigned __int8 AllocationFlags; 
  __int64 AllocationProcessorNumber; 
  struct _KPRCB *CurrentPrcb; 
  unsigned __int8 v6; 
  unsigned __int16 v7; 
  unsigned __int64 Size; 
  __int64 v9; 
  __int64 v10; 
  __int64 v11; 
  unsigned __int8 v12; 

  if( Irp->Type != 6 )
    KeBugCheckEx(0x44u, Irp, (PVOID)0x257C, 0i64, 0i64);
  Irp->Type = 0;
  AllocationFlags = Irp->AllocationFlags;
  if( (AllocationFlags & 0x40) != 0 )
  {
    IopFreeIrpExtension(Irp, IopAllExtensions, 1u);
    AllocationFlags = Irp->AllocationFlags;
  }
  if( (AllocationFlags & 0x21) == 33 )
  {
    IopFreeReserveIrp(Irp, v1);
  }
  else
  {
    AllocationProcessorNumber = Irp->AllocationProcessorNumber;
    if( (unsigned int)AllocationProcessorNumber >= (unsigned int)KeNumberProcessors_0 )
    {
      CurrentPrcb = KeGetCurrentPrcb();
    }
    else
    {
      _mm_lfence();
      CurrentPrcb = *(&KiProcessorBlock + AllocationProcessorNumber);
    }
    v6 = Irp->AllocationFlags;
    if( (v6 & 8) != 0 )
    {
      Irp->AllocationFlags = v6 ^ 8;
      _InterlockedIncrement(&CurrentPrcb->LookasideIrpFloat);
      v6 = Irp->AllocationFlags;
    }
    if( (v6 & 4) != 0
      && ((*(&stru_140C452E0 + 1144) & 3) == 0
       || (v7 = Irp->Size, v7 == 72 * *(&stru_140C452E0 + 2844) + 208)
       || v7 == 72 * *(&stru_140C452E0 + 2840) + 208
       || v7 == 280) )
    {
      Size = Irp->Size;
      if( (unsigned __int16)Size < (unsigned __int16)(72 * *(&stru_140C452E0 + 2844) + 208) )
      {
        if( (unsigned __int16)Size >= (unsigned __int16)(72 * *(&stru_140C452E0 + 2840) + 208) )
        {
          v9 = 2064i64;
          v10 = 2072i64;
        }
        else
        {
          v9 = 2048i64;
          v10 = 2056i64;
        }
      }
      else
      {
        v9 = 2080i64;
        v10 = 2088i64;
      }
      Irp->IoStatus.Information = Size;
      v11 = *(_QWORD *)((char *)&CurrentPrcb->_MxCsr + v9);
      ++*(_DWORD *)(v11 + 28);
      if( *(_WORD *)v11 < *(_WORD *)(v11 + 16)
        || (++*(_DWORD *)(v11 + 32),
            v11 = *(_QWORD *)((char *)&CurrentPrcb->_MxCsr + v10),
            ++*(_DWORD *)(v11 + 28),
            *(_WORD *)v11 < *(_WORD *)(v11 + 16)) )
      {
        v12 = Irp->AllocationFlags;
        if( (v12 & 1) != 0 )
        {
          Irp->AllocationFlags = v12 ^ 1;
          ExReturnPoolQuota(Irp);
        }
        RtlpInterlockedPushEntrySList((PSLIST_HEADER)v11, (PSLIST_ENTRY)Irp);
      }
      else
      {
        ++*(_DWORD *)(v11 + 32);
        ExFreePoolWithTag(Irp, 0);
      }
    }
    else
    {
      ExFreePoolWithTag(Irp, 0);
    }
  }
}

Referenced by:

IoFreeIrp
IopCompleteRequest
IopfCompleteRequest
IovFreeIrpPrivate