HalpDmaDequeueAdapter

__int64 *__fastcall HalpDmaDequeueAdapter(__int64 a1, char a2){
  __int64 **v4; 
  __int64 *v5; 
  __int64 *result; 
  __int64 v7; 
  __int64 *v8; 
  struct _KLOCK_QUEUE_HANDLE LockHandle; 
  memset(&LockHandle, 0, sizeof(LockHandle));
  KeAcquireInStackQueuedSpinLock((UINT64 *)(a1 + 120), &LockHandle);
  v4 = (__int64 **)(a1 + 168);
  if( !a2 )
    v4 = (__int64 **)(a1 + 152);
  v5 = *v4;
  if( *v4 == (__int64 *)v4 )
  {
    KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
    result = 0i64;
    __writecr8(LockHandle.OldIrql);
  }
  else
  {
    v7 = *v5;
    if( (__int64 **)v5[1] != v4 || *(__int64 **)(v7 + 8) != v5 )
      __fastfail(3u);
    *v4 = (__int64 *)v7;
    v8 = v5 - 20;
    *(_QWORD *)(v7 + 8) = v4;
    KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
    __writecr8(LockHandle.OldIrql);
    return v8;
  }
  return result;
}

Referenced by:

HalpDmaProcessMapRegisterQueueV2
HalpDmaProcessMapRegisterQueueV3