HalGetInterruptTargetInformation

NTSTATUS __fastcall HalGetInterruptTargetInformation(INT64 a1, INT64 a2, INT64 a3){
  int v4; 
  int v5; 
  bool v6; 
  int v7; 
  int v8; 
  NTSTATUS result; 
  char *i; 
  unsigned int ProcessorIndexFromNumber; 
  __int64 v12; 
  __int64 v13; 
  __int64 v14; 

  v4 = a2;
  v5 = a1;
  if( (_DWORD)a1 && (_DWORD)a1 != 2 )
  {
    *(&CmpDummyThreadEvent + 1789) = 19;
    return -1073741811;
  }
  *(_QWORD *)(a3 + 4) = 0i64;
  *(_QWORD *)(a3 + 12) = 0i64;
  v6 = *(&stru_140CF2E80 + 6616) == 0;
  *(_DWORD *)a3 = a1;
  if( v6 && *(&CmpDummyThreadEvent + 7152) )
    v7 = (*(&CmpDummyThreadEvent + 7160) != 0) + 2;
  else
    v7 = 1;
  *(_DWORD *)(a3 + 20) = v7;
  if( (unsigned __int8)HalpInterruptIsMsiSupported(0i64) )
    *(_DWORD *)(a3 + 8) = 1;
  if( (dword_140C4A10C & 0x80u) != 0 )
    *(_DWORD *)(a3 + 8) |= 8u;
  if( v5 != 2 )
  {
    v8 = 0;
    result = -1073741275;
    if( !(_DWORD)qword_140C50640 )
      return result;
    for( i = (char *)HalpInterruptProcessorState; !i[13] || *(_DWORD *)i != v4; i += 64 )
    {
      if( ++v8 >= (unsigned int)qword_140C50640 )
        return result;
    }
    *(_DWORD *)(a3 + 4) = *((_DWORD *)i + 4);
    ProcessorIndexFromNumber = KeGetProcessorIndexFromNumber((UINT16 *)i + 8);
    v12 = qword_140C50630;
    v13 = 3i64 * ProcessorIndexFromNumber;
    if( v7 == 1 || (v14 = qword_140C4B7A8[*((unsigned __int16 *)i + 8)], _bittest64(&v14, (unsigned __int8)i[18])) )
    {
      *(_DWORD *)(a3 + 12) = 0;
      *(_DWORD *)(a3 + 20) = 1;
    }
    else
    {
      *(_DWORD *)(a3 + 20) = v7;
      if( v7 == 2 )
      {
        *(_DWORD *)(a3 + 12) = *(_DWORD *)(v12 + 8 * v13 + 8);
      }
      else
      {
        *(_DWORD *)(a3 + 12) = *(_DWORD *)(v12 + 8 * v13 + 12);
        *(_DWORD *)(a3 + 16) = *(_DWORD *)(v12 + 8 * v13 + 8);
      }
    }
  }
  return 0;
}

Referenced by:

PoInitSystem