HalpInterruptRestoreController

__int64 __fastcall HalpInterruptRestoreController(__int64 a1, char a2){
  int v3; 
  __int64 v5; 
  _QWORD *v6; 
  int v7; 
  __int64 v8; 
  __int64 v9; 
  _QWORD *v10; 
  __int64 result; 
  __int64 v12; 
  v12 = 0i64;
  v3 = *(_DWORD *)(a1 + 224);
  if( (v3 & 2) != 0 )
    return 3221225473i64;
  if( (v3 & 1) == 0 )
    return 3221225860i64;
  v5 = a1 + 240;
  v6 = *(_QWORD **)(a1 + 240);
  while( 1 )
  {
LABEL_7:
    if( v6 == (_QWORD *)v5 )
      return 0i64;
    v10 = v6;
    v6 = (_QWORD *)*v6;
    if( v10[5] && (!a2 || ((*((_DWORD *)v10 + 8) - 3) & 0xFFFFFFFD) == 0) )
    {
      v7 = 0;
      if( *((_DWORD *)v10 + 6) - *((_DWORD *)v10 + 5) > 0 )
        break;
    }
  }
  v9 = 0i64;
  v8 = 0i64;
  while( 1 )
  {
    if( (*(_DWORD *)(v8 + v10[5] + 12) & 0x10) != 0 || *(_BYTE *)(v9 + v10[6]) )
    {
      LODWORD(v12) = *(_DWORD *)(a1 + 232);
      HIDWORD(v12) = v7 + *((_DWORD *)v10 + 5);
      result = HalpInterruptSetLineStateInternal(a1, (__int64)&v12, v10[5] + 56i64 * v7);
      if( (int)result < 0 )
        return result;
    }
    ++v7;
    v8 += 56i64;
    v9 += 16i64;
    if( v7 >= *((_DWORD *)v10 + 6) - *((_DWORD *)v10 + 5) )
      goto LABEL_7;
  }
}

Referenced by:

HalpInterruptInitializeLocalUnit
HalpInterruptPowerChange
HalpInterruptRestoreAllControllerState