PipIommuValidateDeviceId

INT64 __fastcall PipIommuValidateDeviceId(ULONG_PTR a1, INT64 a2, INT64 a3){
  ULONG_PTR v3; 
  ULONG_PTR v4; 
  INT64 result; 
  unsigned __int64 v6; 
  __int64 v7; 
  v3 = a2;
  v4 = a1;
  result = (unsigned int)(*(_DWORD *)a2 - 1);
  if( (unsigned int)result > 5 )
  {
    result = 3221225485i64;
  }
  else if( *(_DWORD *)a2 == 1 )
  {
    v6 = *(_QWORD *)(a2 + 16);
    if( v6 && (v7 = *(unsigned __int16 *)(v3 + 14), (_WORD)v7) )
    {
      if( v6 < v3 + 24 )
        result = 3221225793i64;
      else
        result = v3 + a3 < v6 + v7 ? 0x80000005 : 0;
    }
    else
    {
      result = 3221225990i64;
    }
  }
  else
  {
    if( *(_DWORD *)a2 != 2 )
      return result;
    result = IdpValidateAcpiName(a2, a3);
  }
  if( (int)result < 0 )
    KeBugCheckEx(0xCAu, 0x12ui64, v4, v3, (int)result);
  return result;
}

Referenced by:

PipIommuRetrieveDeviceId
PipIommuRetrieveSecondaryDeviceId