

// === Function at 0xffd7f7a1 ===
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  int v2; // eax
  int v3; // ecx
  void *v4; // ecx
  int v5; // ecx
  int v6; // eax
  int v7; // eax
  int v8; // eax
  unsigned __int64 v10; // [esp-Ch] [ebp-10h]

  if ( (sub_FFD9165B(1024068) & 0x80u) == 0 ) /*0xffd7f7b0*/
  {
    sub_FFD9168B(); /*0xffd7f7b2*/
    v2 = sub_FFD9164F(); /*0xffd7f7b7*/
    *(_BYTE *)(v2 + 1024068) |= 0x80u; /*0xffd7f7c3*/
  }
  sub_FFD7F9AF(64, (int)"SiInitPrePolicy() Start\n"); /*0xffd7f88f*/
  sub_FFD7FD72(0); /*0xffd7f898*/
  sub_FFD7FBC7(v3, __rdtsc()); /*0xffd7f8a3*/
  sub_FFD816C4(); /*0xffd7f8a8*/
  sub_FFD7F9AF(64, (int)"PchInitPrePolicy() - Start\n"); /*0xffd7f8b4*/
  sub_FFD87EED(); /*0xffd7f8b9*/
  sub_FFD880D2(); /*0xffd7f8be*/
  sub_FFD87D42(); /*0xffd7f8c3*/
  sub_FFD8155F(); /*0xffd7f8c8*/
  sub_FFD8B940(v4); /*0xffd7f8cd*/
  sub_FFD7F9AF(64, (int)"PchInitPrePolicy() - End\n"); /*0xffd7f8d9*/
  v10 = __rdtsc(); /*0xffd7f8e5*/
  sub_FFD7FC48(v5, v10, HIDWORD(v10)); /*0xffd7f8e7*/
  v6 = sub_FFD8AD54(); /*0xffd7f8ec*/
  v7 = (*(int (__cdecl **)(int, void *))(*(_DWORD *)v6 + 36))(v6, &unk_FFD97FEC); /*0xffd7f8f9*/
  if ( v7 < 0 ) /*0xffd7f901*/
  {
    sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v7); /*0xffd7f90e*/
    v8 = sub_FFD7F97E(); /*0xffd7f916*/
    if ( v8 ) /*0xffd7f91d*/
      (*(void (__cdecl **)(const char *, int, const char *))(v8 + 4))( /*0xffd7f92e*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\SiInit\\Pei\\SiInitPreMem.c",
        155,
        "!EFI_ERROR (Status)");
  }
  sub_FFD7F9AF(64, (int)"SiInitPrePolicy() - End\n"); /*0xffd7f93b*/
  return 0; /*0xffd7f947*/
}

// === Function at 0xffd7f97e ===
int sub_FFD7F97E()
{
  int v0; // eax
  _BYTE v2[4]; // [esp+0h] [ebp-8h] BYREF
  int v3; // [esp+4h] [ebp-4h] BYREF

  v0 = sub_FFD8AD54(); /*0xffd7f983*/
  if ( (*(int (__cdecl **)(int, void *, _DWORD, _BYTE *, int *))(*(_DWORD *)v0 + 32))(v0, &unk_FFD97EAC, 0, v2, &v3) >= 0 ) /*0xffd7f9a2*/
    return v3; /*0xffd7f9a8*/
  else
    return 0; /*0xffd7f9a4*/
}

// === Function at 0xffd7f9af ===
int sub_FFD7F9AF(int a1, int a2, ...)
{
  int result; // eax
  int (__cdecl **v3)(int, int, char *); // esi
  va_list va; // [esp+10h] [ebp+Ch] BYREF

  va_start(va, a2);
  result = sub_FFD7F97E(); /*0xffd7f9b0*/
  v3 = (int (__cdecl **)(int, int, char *))result; /*0xffd7f9b5*/
  if ( result ) /*0xffd7f9b9*/
  {
    result = sub_FFD8AD05(); /*0xffd7f9bb*/
    if ( (result & a1) != 0 ) /*0xffd7f9c6*/
      return (*v3)(a1, a2, (char *)va); /*0xffd7f9d2*/
  }
  return result; /*0xffd7f9d7*/
}

// === Function at 0xffd7f9d9 ===
int __fastcall sub_FFD7F9D9(int a1, int a2, const char *PeiServices____((void__)_0))
{
  int result; // eax

  result = sub_FFD7F97E(); /*0xffd7f9df*/
  if ( result ) /*0xffd7f9e6*/
    return (*(int (__cdecl **)(int, int, const char *))(result + 4))(a1, a2, PeiServices____((void__)_0)); /*0xffd7f9ee*/
  return result; /*0xffd7f9f4*/
}

// === Function at 0xffd7fa46 ===
unsigned int __fastcall sub_FFD7FA46(unsigned int a1)
{
  unsigned int v2; // eax
  unsigned __int64 v3; // rtt

  v2 = (3579545 * (unsigned __int64)a1) >> 32; /*0xffd7fa6c*/
  LODWORD(v3) = 3579545 * a1; /*0xffd7fa7c*/
  HIDWORD(v3) = v2 % 0xF4240; /*0xffd7fa7c*/
  sub_FFD7F9F7(v3 / 0xF4240, v2 / 0xF4240); /*0xffd7fa81*/
  return a1; /*0xffd7fa88*/
}

// === Function at 0xffd7fa8d ===
int __fastcall sub_FFD7FA8D(int *a1, int *a2)
{
  int v4; // eax
  int v5; // eax
  int v6; // eax
  int v7; // edi
  int v8; // eax
  int result; // eax
  int v10; // eax
  int v11; // eax

  if ( !a1 ) /*0xffd7fa9d*/
  {
    v4 = sub_FFD7F97E(); /*0xffd7fa9f*/
    if ( v4 ) /*0xffd7faa6*/
      (*(void (__cdecl **)(const char *, int, const char *))(v4 + 4))( /*0xffd7fab0*/
        "e:\\hs\\MdeModulePkg\\Library\\PeiPerformanceLib\\PeiPerformanceLib.c",
        57,
        "PeiPerformanceLog != ((void *) 0)");
  }
  if ( !a2 ) /*0xffd7fab8*/
  {
    v5 = sub_FFD7F97E(); /*0xffd7faba*/
    if ( v5 ) /*0xffd7fac1*/
      (*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffd7facb*/
        "e:\\hs\\MdeModulePkg\\Library\\PeiPerformanceLib\\PeiPerformanceLib.c",
        58,
        "PeiPerformanceIdArray != ((void *) 0)");
  }
  v6 = sub_FFD8CE7C(&unk_FFD97F9C); /*0xffd7fad8*/
  if ( v6 ) /*0xffd7fadf*/
  {
    *a1 = v6 + 24; /*0xffd7fae9*/
    v7 = sub_FFD8CE7C(&unk_FFD97ECC); /*0xffd7faf0*/
    if ( !v7 ) /*0xffd7faf4*/
    {
      v8 = sub_FFD7F97E(); /*0xffd7faf6*/
      if ( v8 ) /*0xffd7fafd*/
        (*(void (__cdecl **)(const char *, int, const char *))(v8 + 4))( /*0xffd7fb07*/
          "e:\\hs\\MdeModulePkg\\Library\\PeiPerformanceLib\\PeiPerformanceLib.c",
          72,
          "GuidHob != ((void *) 0)");
    }
    result = v7 + 24; /*0xffd7fb0d*/
  }
  else
  {
    v10 = sub_FFD8CF46(&unk_FFD97F9C, 40008); /*0xffd7fb1b*/
    *a1 = v10; /*0xffd7fb22*/
    *a1 = sub_FFD8D4C8(v10, 40008); /*0xffd7fb2b*/
    v11 = sub_FFD8CF46(&unk_FFD97ECC, 4000); /*0xffd7fb39*/
    *a2 = v11; /*0xffd7fb40*/
    result = sub_FFD8D4C8(v11, 4000); /*0xffd7fb44*/
  }
  *a2 = result; /*0xffd7fb4a*/
  return result; /*0xffd7fb49*/
}

// === Function at 0xffd7fb51 ===
int __thiscall sub_FFD7FB51(unsigned int *this)
{
  int v2; // esi
  unsigned int v3; // eax
  int v4; // ebx
  int v5; // ebp
  unsigned int v7; // [esp+8h] [ebp-4h]

  v2 = 0; /*0xffd7fb56*/
  v3 = *this; /*0xffd7fb58*/
  v7 = *this; /*0xffd7fb5a*/
  if ( *this ) /*0xffd7fb58*/
  {
    while ( 1 ) /*0xffd7fb68*/
    {
      v4 = v3 - v2 - 1; /*0xffd7fb68*/
      v5 = 40 * v4; /*0xffd7fb69*/
      if ( !*((_QWORD *)this + 5 * v4 + 5) /*0xffd7fba8*/
        && *(_UNKNOWN **)((char *)this + v5 + 8) == &unk_FFD97F8C
        && *(unsigned int *)((char *)this + v5 + 12) == (*(this + 10 * v4 + 11) | *(this + 10 * v4 + 10))
        && !sub_FFD8D0FF(7)
        && !sub_FFD8D0FF(7) )
      {
        break; /*0xffd7fba8*/
      }
      v3 = v7; /*0xffd7fbb2*/
      if ( ++v2 >= v7 ) /*0xffd7fbb9*/
        return v2; /*0xffd7fbb9*/
    }
    return v4; /*0xffd7fbbd*/
  }
  return v2; /*0xffd7fbc1*/
}

// === Function at 0xffd7fbc7 ===
int __cdecl sub_FFD7FBC7(int a1, __int64 a2)
{
  _DWORD *v2; // ecx
  int v3; // edx
  int v5; // edi
  int v6; // esi
  int v7; // eax
  int v8; // edx
  unsigned __int64 v9; // rax
  int v10; // [esp+8h] [ebp-8h] BYREF
  _DWORD *v11; // [esp+Ch] [ebp-4h] BYREF

  sub_FFD7FA8D((int *)&v11, &v10); /*0xffd7fbd4*/
  v2 = v11; /*0xffd7fbd9*/
  v3 = *v11; /*0xffd7fbdc*/
  if ( *v11 < 0x3E8u ) /*0xffd7fbe4*/
  {
    v5 = HIDWORD(a2); /*0xffd7fbfe*/
    v6 = 10 * v3; /*0xffd7fc04*/
    *v11 = v3 + 1; /*0xffd7fc07*/
    v2[v6 + 3] = 0; /*0xffd7fc0b*/
    v2[v6 + 10] = 0; /*0xffd7fc0f*/
    v2[v6 + 11] = 0; /*0xffd7fc13*/
    v7 = v10; /*0xffd7fc17*/
    v2[v6 + 2] = &unk_FFD97F8C; /*0xffd7fc1a*/
    *(_DWORD *)(v7 + 4 * v3) = 20704; /*0xffd7fc22*/
    v8 = a2; /*0xffd7fc29*/
    if ( !a2 ) /*0xffd7fc30*/
    {
      v9 = __rdtsc(); /*0xffd7fc32*/
      v5 = HIDWORD(v9); /*0xffd7fc34*/
      v8 = v9; /*0xffd7fc36*/
    }
    v2[v6 + 8] = v8; /*0xffd7fc38*/
    v2[v6 + 9] = v5; /*0xffd7fc3e*/
    return 0; /*0xffd7fc3c*/
  }
  else
  {
    sub_FFD7F9AF(0x80000000, (int)"PEI performance log array out of resources\n"); /*0xffd7fbf0*/
    return -2147483639; /*0xffd7fbf7*/
  }
}

// === Function at 0xffd7fc48 ===
int __cdecl sub_FFD7FC48(int a1, unsigned __int64 a2)
{
  unsigned __int64 v2; // kr00_8
  unsigned int *v3; // ebx
  unsigned int v4; // eax
  int v6; // [esp+Ch] [ebp-4h] BYREF

  v2 = a2; /*0xffd7fc54*/
  if ( !a2 ) /*0xffd7fc59*/
    v2 = __rdtsc(); /*0xffd7fc5f*/
  sub_FFD7FA8D((int *)&a2 + 1, &v6); /*0xffd7fc67*/
  v3 = (unsigned int *)HIDWORD(a2); /*0xffd7fc6c*/
  v4 = sub_FFD7FB51((unsigned int *)HIDWORD(a2)); /*0xffd7fc74*/
  if ( v4 >= *v3 ) /*0xffd7fc7e*/
    return -2147483634; /*0xffd7fc80*/
  *(_QWORD *)&v3[10 * v4 + 10] = v2; /*0xffd7fc8b*/
  return 0; /*0xffd7fc94*/
}

// === Function at 0xffd7fc9b ===
int sub_FFD7FC9B()
{
  int v0; // eax
  int v2; // esi
  int v3; // eax
  int v4; // [esp+4h] [ebp-4h] BYREF

  sub_FFD8C2A0(0xEFu, 0x2234u, 4, &v4); /*0xffd7fcb0*/
  if ( v4 < 0 ) /*0xffd7fcbf*/
  {
    sub_FFD7F9AF(0x80000000, (int)"TraceHubBaseSet Error. DMIC.SRL is set.\n"); /*0xffd7fcc7*/
    v0 = sub_FFD7F97E(); /*0xffd7fcce*/
    if ( v0 ) /*0xffd7fcd5*/
      (*(void (__cdecl **)(const char *, int, const char *))(v0 + 4))( /*0xffd7fce3*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmTraceHubInitLib\\PeiDxeSmmTraceHubInitLib.c",
        64,
        "((BOOLEAN)(0==1))");
    return -2147483645; /*0xffd7fcee*/
  }
  v2 = sub_FFD8CBBA(0, 31, 7); /*0xffd7fcfd*/
  if ( (unsigned __int16)sub_FFD8CCA5((unsigned __int16 *)v2) == 0xFFFF ) /*0xffd7fd0e*/
  {
    v3 = sub_FFD7F97E(); /*0xffd7fd10*/
    if ( v3 ) /*0xffd7fd17*/
      (*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffd7fd20*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmTraceHubInitLib\\PeiDxeSmmTraceHubInitLib.c",
        74,
        "((BOOLEAN)(0==1))");
    return -2147483645; /*0xffd7fd20*/
  }
  *(_DWORD *)(v2 + 112) = -32768000; /*0xffd7fd2c*/
  *(_DWORD *)(v2 + 116) = 0; /*0xffd7fd2f*/
  sub_FFD8C497(4, -32768000); /*0xffd7fd40*/
  sub_FFD8C497(4, 0); /*0xffd7fd50*/
  sub_FFD8C5F6(255, 2); /*0xffd7fd63*/
  return 0; /*0xffd7fd6d*/
}

// === Function at 0xffd7fd72 ===
int __fastcall sub_FFD7FD72(char a1)
{
  int v2; // esi
  int result; // eax
  unsigned int v4; // [esp+Ch] [ebp-4h] BYREF

  sub_FFD7F9AF(64, (int)"TraceHubInitialize() - Start\n"); /*0xffd7fd84*/
  sub_FFD8C909(&v4); /*0xffd7fd8c*/
  *(_BYTE *)(v4 + 1488) = 0; /*0xffd7fd9b*/
  v2 = sub_FFD8CBBA(0, 31, 7); /*0xffd7fdb0*/
  if ( (unsigned __int16)sub_FFD8CCA5((unsigned __int16 *)v2) == 0xFFFF ) /*0xffd7fdc1*/
    return sub_FFD7F9AF(64, (int)"TraceHubInitialize() - End. TraceHub device is not present \n"); /*0xffd7fdc8*/
  if ( (*(_DWORD *)(v2 + 4) & 2) != 0 ) /*0xffd7fdd2*/
  {
    sub_FFD7F9AF(64, (int)"TraceHubInitialize() - End. Early init done already \n"); /*0xffd7fdda*/
    sub_FFD7F9AF(64, (int)"TraceHubInitialize() - FW_LBAR  = 0x%08x\n", *(_DWORD *)(v2 + 112)); /*0xffd7fde9*/
    sub_FFD7F9AF(64, (int)"TraceHubInitialize() - MTB_LBAR = 0x%08x\n", *(_DWORD *)(v2 + 16)); /*0xffd7fdfb*/
    sub_FFD7F9AF(64, (int)"TraceHubInitialize() - SW_LBAR  = 0x%08x\n", *(_DWORD *)(v2 + 24)); /*0xffd7fe0d*/
    result = MEMORY[0xFE1000E0]; /*0xffd7fe1a*/
    if ( (MEMORY[0xFE1000E0] & 0x1000000) != 0 ) /*0xffd7fe21*/
      return sub_FFD7F9AF(64, (int)"TraceHubInitialize() - Trace Hub enabled due to SCRPD0.24\n"); /*0xffd7fe2c*/
  }
  else
  {
    sub_FFD7F9AF(64, (int)"TraceHubInitialize() - Setting MTB_BAR\n"); /*0xffd7fe37*/
    *(_DWORD *)(v2 + 16) = -32505856; /*0xffd7fe3e*/
    *(_DWORD *)(v2 + 20) = 0; /*0xffd7fe47*/
    *(_BYTE *)(v2 + 4) |= 2u; /*0xffd7fe4f*/
    if ( (MEMORY[0xFE1000E0] & 0x1000000) != 0 || a1 ) /*0xffd7fe62*/
    {
      MEMORY[0xFE1000CC] = 357000000; /*0xffd7fe91*/
      *(_BYTE *)(v2 + 4) = 0; /*0xffd7fe9c*/
      sub_FFD7F9AF(64, (int)"TraceHubInitialize() - Setting SW_BAR\n"); /*0xffd7fe9f*/
      *(_DWORD *)(v2 + 24) = -31457280; /*0xffd7fea9*/
      *(_DWORD *)(v2 + 28) = 0; /*0xffd7feb1*/
      sub_FFD7F9AF(64, (int)"TraceHubInitialize() - Setting FW_BAR\n"); /*0xffd7feb8*/
      sub_FFD7FC9B(); /*0xffd7febd*/
      sub_FFD7F9AF(64, (int)"TraceHubInitialize() - Enabling MSE and BME\n"); /*0xffd7fec8*/
      *(_BYTE *)(v2 + 4) |= 6u; /*0xffd7fed8*/
      sub_FFD7F9AF(64, (int)"TraceHubInitialize () Assigned BARs:\n"); /*0xffd7fedb*/
      sub_FFD7F9AF(64, (int)"TraceHubInitialize () FW_LBAR  = 0x%08x\n", *(_DWORD *)(v2 + 112)); /*0xffd7feea*/
      sub_FFD7F9AF(64, (int)"TraceHubInitialize () MTB_LBAR = 0x%08x\n", *(_DWORD *)(v2 + 16)); /*0xffd7fefc*/
      sub_FFD7F9AF(64, (int)"TraceHubInitialize () SW_LBAR  = 0x%08x\n", *(_DWORD *)(v2 + 24)); /*0xffd7ff0e*/
      return sub_FFD7F9AF(64, (int)"TraceHubInitialize () - End\n"); /*0xffd7ff1c*/
    }
    else
    {
      *(_BYTE *)(v2 + 4) = 0; /*0xffd7fe6a*/
      sub_FFD7F9AF(64, (int)"TraceHubInitialize() - Clearing MTB_BAR\n"); /*0xffd7fe6d*/
      *(_DWORD *)(v2 + 16) = 0; /*0xffd7fe78*/
      return sub_FFD7F9AF( /*0xffd7fe7f*/
               64,
               (int)"TraceHubInitialize() - End. STT disconnected and Trace Hub requested to be disable\n");
    }
  }
  return result; /*0xffd7ff23*/
}

// === Function at 0xffd80210 ===
int sub_FFD80210()
{
  int v0; // eax
  int v1; // eax
  unsigned __int8 *v2; // esi
  int v3; // edi
  unsigned int i; // ebp
  unsigned int v5; // ecx
  unsigned int v6; // edx
  unsigned int v7; // ebx
  unsigned __int8 v8; // cl
  unsigned int v9; // ebx
  int v10; // ebx
  unsigned int v11; // eax
  int result; // eax
  int v13; // [esp+0h] [ebp-24h] BYREF
  int v14; // [esp+4h] [ebp-20h]
  int v15; // [esp+8h] [ebp-1Ch]
  _DWORD *v16; // [esp+Ch] [ebp-18h] BYREF
  int n10; // [esp+10h] [ebp-14h]
  int v18; // [esp+14h] [ebp-10h] BYREF
  int v19; // [esp+18h] [ebp-Ch] BYREF
  unsigned int v20; // [esp+1Ch] [ebp-8h]
  unsigned int v21; // [esp+20h] [ebp-4h]

  v13 = 0; /*0xffd80213*/
  v0 = sub_FFD8AD54(); /*0xffd80217*/
  if ( (*(int (__cdecl **)(int, int, _DWORD **))(*(_DWORD *)v0 + 76))(v0, 4, &v16) ) /*0xffd80226*/
  {
    v1 = sub_FFD7F97E(); /*0xffd80230*/
    if ( v1 ) /*0xffd80237*/
      (*(void (__cdecl **)(const char *, int, const char *))(v1 + 4))( /*0xffd80248*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchInitPreMem.c",
        456,
        "Status == 0");
  }
  *v16 = 0; /*0xffd80255*/
  v2 = (unsigned __int8 *)&unk_FFD980CC; /*0xffd80258*/
  v15 = 0; /*0xffd8025d*/
  n10 = 10; /*0xffd80263*/
  do
  {
    v3 = 0; /*0xffd8026b*/
    for ( i = 0; i < 0xC00; i += 512 )
    {
      v5 = 0; /*0xffd80272*/
      v6 = i + *((_DWORD *)v2 + 2); /*0xffd80274*/
      v14 = 0; /*0xffd80276*/
      v21 = v6; /*0xffd8027a*/
      if ( v2[v3 + 1] )
      {
        while ( 1 ) /*0xffd80288*/
        {
          v7 = v5; /*0xffd80288*/
          v8 = *v2; /*0xffd8028e*/
          v9 = v6 + 32 * v7; /*0xffd80294*/
          v20 = v9; /*0xffd8029b*/
          sub_FFD8C2A0(v8, v9, 4, &v18); /*0xffd8029f*/
          sub_FFD8C2A0(*v2, v9, 4, &v19); /*0xffd802b0*/
          v10 = v18; /*0xffd802b5*/
          if ( v18 == v19 ) /*0xffd802c0*/
          {
            v13 = v18; /*0xffd802dd*/
          }
          else
          {
            sub_FFD8C2A0(*v2, v20, 4, &v13); /*0xffd802d0*/
            v10 = v13; /*0xffd802d5*/
          }
          if ( v10 ) /*0xffd802e3*/
            break; /*0xffd802e3*/
          v11 = v2[v3 + 1]; /*0xffd802e9*/
          v5 = v14 + 1; /*0xffd802ee*/
          v6 = v21; /*0xffd802ef*/
          v14 = v5; /*0xffd802f3*/
          if ( v5 >= v11 ) /*0xffd802f9*/
            goto LABEL_14; /*0xffd802f9*/
        }
        *v16 |= (v10 & 7) << v15; /*0xffd80311*/
        sub_FFD7F9AF(0x80000000, (int)"ERROR: Internal fabric error detected!! ");
        sub_FFD7F9AF( /*0xffd80331*/
          0x80000000,
          (int)"PSF PID:0x%x, RSx/PortGroup:0x%x, Port:0x%x, Channel:0, error bits:0x%x\n",
          *v2,
          v3,
          v14,
          v10);
      }
LABEL_14:
      ++v3; /*0xffd8033f*/
    }
    v15 += 3; /*0xffd8034c*/
    v2 += 12; /*0xffd80351*/
    --n10; /*0xffd80354*/
  }
  while ( n10 );
  result = sub_FFD8CFB4(&unk_FFD97F6C, 4); /*0xffd8036a*/
  if ( !result ) /*0xffd80376*/
  {
    result = sub_FFD7F97E(); /*0xffd80378*/
    if ( result ) /*0xffd8037f*/
      return (*(int (__cdecl **)(const char *, int, const char *))(result + 4))( /*0xffd80390*/
               "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchInitPreMem.c",
               504,
               "HobPtr != 0");
  }
  return result; /*0xffd80396*/
}

// === Function at 0xffd8040b ===
int __thiscall sub_FFD8040B(_BYTE *this)
{
  int v3; // [esp+8h] [ebp-8h] BYREF

  sub_FFD8C578(-983041, 0); /*0xffd80425*/
  if ( (*(this + 3504) & 1) != 0 ) /*0xffd80434*/
  {
    sub_FFD8C578(-1, 16); /*0xffd8047a*/
LABEL_6:
    MEMORY[0xFE0005D0] = 0x80000000; /*0xffd80481*/
    return sub_FFD8C578(-1, 1); /*0xffd80481*/
  }
  if ( (*(this + 3504) & 2) != 0 ) /*0xffd8043d*/
  {
    sub_FFD8C2A0(0xB8u, 4u, 4, &v3); /*0xffd8044a*/
    if ( (v3 & 0x600) != 0 ) /*0xffd8045d*/
      goto LABEL_6; /*0xffd8045d*/
  }
  sub_FFD8C578(-17, 1); /*0xffd80468*/
  return sub_FFD8C578(-1, 1); /*0xffd8049b*/
}

// === Function at 0xffd804a1 ===
int __thiscall sub_FFD804A1(_BYTE *this)
{
  int v2; // eax

  if ( (unsigned __int8)sub_FFD8D59A() )
  {
    sub_FFD7F9AF(64, (int)"DWR: PchMiscInit() End\n");
  }
  else
  {
    sub_FFD8BE68(); /*0xffd804c0*/
    v2 = sub_FFD8CBBA(0, 31, 2); /*0xffd804ce*/
    *(_DWORD *)(v2 + 172) &= ~0x100000u; /*0xffd804e5*/
    if ( *(this + 1) ) /*0xffd804f0*/
      sub_FFD8C5F6(255, 8); /*0xffd80506*/
    else
      sub_FFD8C5F6(247, 0); /*0xffd804fd*/
    sub_FFD8C578(-1793, 8207); /*0xffd80521*/
    sub_FFD8C578(-1, 0x80000000); /*0xffd80535*/
    sub_FFD8C5F6(223, 0); /*0xffd80556*/
  }
  return 0; /*0xffd8055d*/
}

// === Function at 0xffd80563 ===
int __thiscall sub_FFD80563(int this)
{
  int v2; // ebx
  unsigned int v3; // esi

  v2 = sub_FFD8CBBA(0, 31, 1); /*0xffd80574*/
  if ( (*(_DWORD *)(this + 2727) & 2) != 0 ) /*0xffd8057f*/
    sub_FFD8CCD3( /*0xffd805aa*/
      v2 + 112,
      (*(_DWORD *)(this + 2727) >> 21) & 7
    | (unsigned __int16)(8 * ((32 * *(unsigned __int8 *)(this + 2728)) | HIWORD(*(_DWORD *)(this + 2727)) & 0x1F)));
  v3 = *(_DWORD *)(this + 2731); /*0xffd805af*/
  if ( !v3 ) /*0xffd805b7*/
    v3 = -19922944; /*0xffd805b9*/
  *(_BYTE *)(v2 + 96) = *(_BYTE *)(v2 + 96) & 0xFC | (v3 >> 12) & 3 | 0x80; /*0xffd805d0*/
  if ( (*(_BYTE *)(this + 2727) & 1) != 0 ) /*0xffd805dd*/
    *(_DWORD *)(v3 + 16) |= 1u; /*0xffd805e5*/
  sub_FFD8CF04(v3, 0); /*0xffd805ed*/
  return sub_FFD8D005(v3, 0); /*0xffd805ff*/
}

// === Function at 0xffd80603 ===
int __thiscall sub_FFD80603(int this)
{
  unsigned __int8 n0x2C; // bl
  int v3; // ecx
  unsigned __int16 *v4; // edi
  unsigned __int8 v6; // [esp+Fh] [ebp-1h]

  sub_FFD7F9AF(64, (int)"ProgramSvidSid() Start\n"); /*0xffd80613*/
  sub_FFD8BE68(); /*0xffd8061a*/
  if ( (unsigned __int8)sub_FFD8D59A() )
  {
    sub_FFD7F9AF(64, (int)"DWR: ProgramSvidSid() End\n");
  }
  else
  {
    n0x2C = 0; /*0xffd8062f*/
    if ( *(_WORD *)(this + 8) || *(_WORD *)(this + 10) ) /*0xffd80637*/
    {
      do /*0xffd80693*/
      {
        v3 = 3 * n0x2C; /*0xffd80640*/
        v6 = byte_FFD97FFE[v3]; /*0xffd80658*/
        v4 = (unsigned __int16 *)sub_FFD8CBBA(0, byte_FFD97FFC[v3], byte_FFD97FFD[v3]); /*0xffd80667*/
        if ( (unsigned __int16)sub_FFD8CCA5(v4) == 0x8086 ) /*0xffd80678*/
          *(_DWORD *)((char *)v4 + v6) = *(_DWORD *)(this + 8); /*0xffd8068b*/
        ++n0x2C; /*0xffd8068e*/
      }
      while ( n0x2C < 0x2Cu ); /*0xffd80693*/
    }
    sub_FFD7F9AF(64, (int)"ProgramSvidSid() End\n"); /*0xffd8069c*/
  }
  return 0; /*0xffd806a3*/
}

// === Function at 0xffd806ac ===
int __thiscall sub_FFD806AC(char *this)
{
  char *this_1; // ebx
  unsigned int v2; // ebp
  int v3; // eax
  unsigned int n3; // esi
  unsigned int v5; // edi
  _DWORD *v6; // ebx
  int v7; // edx
  int v10; // [esp+18h] [ebp-Ch]
  int v11; // [esp+1Ch] [ebp-8h]
  int v12; // [esp+20h] [ebp-4h]

  v10 = 0; /*0xffd806b9*/
  this_1 = this; /*0xffd806ba*/
  v11 = 0; /*0xffd806c0*/
  v12 = 0; /*0xffd806c1*/
  v2 = (unsigned __int8)sub_FFD8BFFD(); /*0xffd806c7*/
  if ( (v2 & 0xFFFFFFF8) > 0x18 ) /*0xffd806d2*/
  {
    v3 = sub_FFD7F97E(); /*0xffd806d4*/
    if ( v3 ) /*0xffd806db*/
      (*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffd806ec*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchInitPreMem.c",
        958,
        "(MaxPciePortNum / 8) <= 3");
  }
  n3 = 0; /*0xffd806f2*/
  v5 = 0; /*0xffd806f4*/
  if ( v2 ) /*0xffd806f8*/
  {
    v6 = this_1 + 28; /*0xffd806fa*/
    do /*0xffd8072a*/
    {
      if ( (*v6 & 0x800) != 0 ) /*0xffd80705*/
        v7 = (unsigned __int16)*v6 >> 12; /*0xffd8070a*/
      else
        v7 = 0; /*0xffd8070f*/
      v6 += 25; /*0xffd8071e*/
      *(&v10 + (v5 >> 3)) |= v7 << (4 * (v5 & 7)); /*0xffd80723*/
      ++v5; /*0xffd80727*/
    }
    while ( v5 < v2 ); /*0xffd8072a*/
    this_1 = this; /*0xffd8072c*/
  }
  v12 |= (*(_DWORD *)(this_1 + 2755) & 0xFFFFFF80) << 21; /*0xffd80747*/
  sub_FFD7F9AF(64, (int)"DRCRM: 0x%08x 0x%08x 0x%08x\n", v10, v11, v12);
  do /*0xffd80779*/
    sub_FFD8C497(4, *(&v10 + n3++)); /*0xffd8076e*/
  while ( n3 < 3 ); /*0xffd80779*/
  return sub_FFD8C578(-1, -2147254272); /*0xffd8078e*/
}

// === 0xffd80796 ===
{"addr":"0xffd80796","code":"// positive sp value has been detected, the output may be wrong!\nint __thiscall sub_FFD80796(int this)\n{\n  int v2; // ebx\n  int v3; // esi\n  int v4; // ebp\n  int v5; // eax\n  int v6; // eax\n  int v7; // eax\n  int v8; // eax\n  int v9; // eax\n  int v10; // eax\n  int v11; // eax\n  int v12; // eax\n  bool v13; // zf\n  char v14; // bl\n  _BYTE *v15; // eax\n  int n3; // ecx\n  int v17; // edx\n  int v18; // eax\n  int v19; // edx\n  int v20; // eax\n  int v21; // eax\n  int v22; // eax\n  int v23; // eax\n  int v24; // eax\n  int v25; // eax\n  int v26; // eax\n  int v27; // eax\n  int v28; // ecx\n  _DWORD v30[3]; // [esp+4h] [ebp-14h] BYREF\n  int v31; // [esp+10h] [ebp-8h] BYREF\n\n  sub_FFD7F9AF(64, (int)\"PchOnPolicyInstalled() - Start\\n\"); /*0xffd807ab*/\n  v2 = sub_FFD8CBBA(0, 31, 0); /*0xffd807c1*/\n  v3 = sub_FFD8CBBA(0, 31, 2); /*0xffd807d5*/\n  v4 = sub_FFD8CBBA(0, 31, 5); /*0xffd807e1*/\n  v5 = sub_FFD8C632(*(_WORD *)(this + 2)); /*0xffd807e3*/\n  if ( v5 < 0 ) /*0xffd807ea*/\n  {\n    sub_FFD7F9AF(0x8000... [6904 chars total]","refs":[{"addr":"0xffd7f9af","name":"sub_FFD7F9AF"},{"addr":"0xffd921d4","name":"aPchonpolicyins","string":"PchOnPolicyInstalled() - Start\n"},{"addr":"0xffd8cbba","name":"sub_FFD8CBBA"},{"addr":"0xffd8c632","name":"sub_FFD8C632"},{"addr":"0xffd9192c","name":"aAssertEfiError","string":"\nASSERT_EFI_ERROR (Status = %r)\n"},{"addr":"0xffd7f97e","name":"sub_FFD7F97E"},{"addr":"0xffd91f24","name":"aEHsPurleysktpk_1","string":"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchInitPreMem.c"},{"addr":"0xffd91950","name":"aEfiErrorStatus","string":"!EFI_ERROR (Status)"},{"addr":"0xffd8c80a","name":"sub_FFD8C80A"},{"addr":"0xffd94584","name":"aWdtUsageMismat","string":"(WDT) Usage mismatched with policy\n"}]}Output truncated. Run: curl -o .ida-mcp/8ab907f0-29ca-41a0-9d6b-fa48fe5810b5.json http://127.0.0.1:13432/output/8ab907f0-29ca-41a0-9d6b-fa48fe5810b5.json

// === 0xffd80ba6 ===
{"addr":"0xffd80ba6","code":"int __thiscall sub_FFD80BA6(int *this)\n{\n  int v2; // esi\n  int v3; // edi\n  int v4; // ebx\n  int v5; // ebp\n  int n2_1; // ebx\n  int v7; // ebx\n  __int16 v8; // si\n  int v9; // ebx\n  int v10; // eax\n  int v11; // eax\n  int v12; // eax\n  int v14; // [esp+10h] [ebp-54h] BYREF\n  int v15; // [esp+14h] [ebp-50h] BYREF\n  int v16; // [esp+18h] [ebp-4Ch] BYREF\n  int n2; // [esp+1Ch] [ebp-48h]\n  int v18; // [esp+20h] [ebp-44h] BYREF\n  int v19; // [esp+24h] [ebp-40h] BYREF\n  int v20; // [esp+28h] [ebp-3Ch] BYREF\n  int v21; // [esp+2Ch] [ebp-38h] BYREF\n  int v22; // [esp+30h] [ebp-34h]\n  int v23; // [esp+34h] [ebp-30h] BYREF\n  int n704654080; // [esp+38h] [ebp-2Ch]\n  int n671099136; // [esp+3Ch] [ebp-28h]\n  int n637544192; // [esp+40h] [ebp-24h]\n  int n603989248; // [esp+44h] [ebp-20h]\n  int n570434304; // [esp+48h] [ebp-1Ch]\n  int n536879360; // [esp+4Ch] [ebp-18h]\n  int n637544192_1; // [esp+50h] [ebp-14h]\n  int n603989248_1; // [esp+54h] [ebp-10h]\n  int n570434304_1; // [esp+58h] [ebp-Ch]\n  i... [12460 chars total]","refs":[{"addr":"0xffd8be68","name":"sub_FFD8BE68"},{"addr":"0xffd7f9af","name":"sub_FFD7F9AF"},{"addr":"0xffd92214","name":"aPchearlydisabl","string":"PchEarlyDisabledDeviceHandling() - Start\n"},{"addr":"0xffd92240","name":"aPchpwrmbaseRPc","string":"PchPwrmBase + R_PCH_PWRM_FUSE_DIS_RD_2 = %x\n"},{"addr":"0xffd8c2a0","name":"sub_FFD8C2A0"},{"addr":"0xffd92270","name":"aSpaControllerP","string":"SPA Controller PCD Value = %x\n"},{"addr":"0xffd92290","name":"aSpbControllerP","string":"SPB Controller PCD Value = %x\n"},{"addr":"0xffd922b0","name":"aSpcControllerP","string":"SPC Controller PCD Value = %x\n"},{"addr":"0xffd922d0","name":"aSpdControllerP","string":"SPD Controller PCD Value = %x\n"},{"addr":"0xffd922f0","name":"aSpeControllerP","string":"SPE Controller PCD Value = %x\n"}]}Output truncated. Run: curl -o .ida-mcp/7508e8c4-5a63-42fa-96dc-a63404b02de7.json http://127.0.0.1:13432/output/7508e8c4-5a63-42fa-96dc-a63404b02de7.json

// === Function at 0xffd813d1 ===
int __thiscall sub_FFD813D1(int *this)
{
  int v2; // eax
  int v3; // edi
  unsigned __int8 v4; // al
  unsigned __int8 v5; // al
  unsigned __int8 v6; // al
  unsigned __int8 v7; // al

  sub_FFD7F9AF(64, (int)"PchEarlyInit() - Start\n"); /*0xffd813df*/
  sub_FFD82723(); /*0xffd813e4*/
  sub_FFD81769(); /*0xffd813e9*/
  sub_FFD8C497(2, 1); /*0xffd813fc*/
  sub_FFD8C5F6(255, 3); /*0xffd81414*/
  sub_FFD8C578(-2, 0); /*0xffd81425*/
  v2 = sub_FFD8CBBA(0, 31, 1); /*0xffd81431*/
  *(_DWORD *)(v2 + 128) = 0; /*0xffd8143b*/
  *(_DWORD *)(v2 + 132) = 0; /*0xffd81441*/
  *(_DWORD *)(v2 + 136) = 0; /*0xffd81447*/
  *(_DWORD *)(v2 + 140) = 0; /*0xffd8144d*/
  *(_DWORD *)(v2 + 144) = 0; /*0xffd81453*/
  *(_DWORD *)(v2 + 148) = 61440; /*0xffd81459*/
  *(_DWORD *)(v2 + 152) = 16; /*0xffd81463*/
  *(_DWORD *)(v2 + 156) = 0; /*0xffd8146d*/
  *(_BYTE *)(v2 + 244) |= 1u; /*0xffd8147d*/
  v3 = sub_FFD8CBBA(0, 31, 2); /*0xffd8148d*/
  if ( (*(_BYTE *)(v3 + 164) & 4) != 0 ) /*0xffd81499*/
  {
    __outbyte(0x74u, 0xAu); /*0xffd814a3*/
    v4 = __inbyte(0x74u); /*0xffd814a4*/
    __outbyte(0x75u, v4 & 0x8F | 0x60); /*0xffd814af*/
    __outbyte(0x74u, 0xBu); /*0xffd814b5*/
    v5 = __inbyte(0x75u); /*0xffd814b9*/
    __outbyte(0x75u, v5 | 0x80); /*0xffd814bc*/
    __outbyte(0x74u, 0xAu); /*0xffd814c2*/
    v6 = __inbyte(0x75u); /*0xffd814c6*/
    __outbyte(0x75u, v6 & 0x8F | 0x20); /*0xffd814cb*/
    __outbyte(0x74u, 0xBu); /*0xffd814d1*/
    v7 = __inbyte(0x75u); /*0xffd814d5*/
    __outbyte(0x75u, v7 & 0x7F); /*0xffd814d8*/
  }
  *(this + 4) = 16; /*0xffd814d9*/
  *(_DWORD *)(v3 + 172) &= ~0x100000u; /*0xffd814ed*/
  *(this + 53) = 0; /*0xffd814f3*/
  *(this + 61) = 0; /*0xffd814f9*/
  sub_FFD80BA6(this); /*0xffd814ff*/
  sub_FFD905CC(); /*0xffd81504*/
  sub_FFD8C497(4, 0); /*0xffd81518*/
  sub_FFD8C497(4, 18875648); /*0xffd8152c*/
  sub_FFD8C497(4, 0); /*0xffd81539*/
  sub_FFD8C497(4, 18875648); /*0xffd81545*/
  return sub_FFD7F9AF(64, (int)"PchEarlyInit() - End\n"); /*0xffd81559*/
}

// === Function at 0xffd8155f ===
int sub_FFD8155F()
{
  int v0; // eax
  int v1; // esi
  int v2; // eax
  int v3; // eax
  int v4; // esi
  int v5; // eax
  int *v7; // [esp+10h] [ebp-4h] BYREF

  sub_FFD7F9AF(64, (int)"PchInitPreMem() - Start\n"); /*0xffd8156b*/
  if ( !(unsigned __int8)sub_FFD8BDC8() ) /*0xffd81572*/
  {
    sub_FFD7F9AF(0x80000000, (int)"PCH SKU is not supported due to no proper PCH LPC found!\n"); /*0xffd8158b*/
    v0 = sub_FFD7F97E(); /*0xffd81592*/
    if ( v0 ) /*0xffd81599*/
      (*(void (__cdecl **)(const char *, int, const char *))(v0 + 4))( /*0xffd815a6*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchInitPreMem.c",
        1948,
        "((BOOLEAN)(0==1))");
  }
  v1 = sub_FFD8CBBA(0, 31, 1); /*0xffd815b8*/
  if ( (*(_DWORD *)(v1 + 16) & 0xFF000000) == 0 ) /*0xffd815c4*/
  {
    sub_FFD7F9AF(64, (int)"SBREG should be programmed before here\n"); /*0xffd815cd*/
    *(_DWORD *)(v1 + 16) = -50331648; /*0xffd815d2*/
    *(_BYTE *)(v1 + 4) |= 2u; /*0xffd815e0*/
  }
  sub_FFD8C632(0x500u); /*0xffd815e8*/
  sub_FFD8C80A(); /*0xffd815ed*/
  sub_FFD8C99B(); /*0xffd815f2*/
  sub_FFD8C909((unsigned int *)&v7); /*0xffd815fb*/
  sub_FFD7F9AF(64, (int)"PCH PWRM Base needs to be programmed before here\n"); /*0xffd81607*/
  if ( !v7 ) /*0xffd81613*/
  {
    v2 = sub_FFD7F97E(); /*0xffd81615*/
    if ( v2 ) /*0xffd8161c*/
      (*(void (__cdecl **)(const char *, int, const char *))(v2 + 4))( /*0xffd81629*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchInitPreMem.c",
        1993,
        "PchPwrmBase != 0");
  }
  if ( (unsigned __int8)sub_FFD8D59A() )
  {
    sub_FFD7F9AF(0x80000000, (int)"DWR: DWR detected - install PPI\n");
    if ( sub_FFD7F948(&unk_FFD98084) >= 0 )
      sub_FFD7F9AF(0x80000000, (int)"DWR: DWR PPI has been installed\n");
    else
      sub_FFD7F9AF(0x80000000, (int)"ERROR: Can't install DWR PPI\n");
  }
  sub_FFD80210(); /*0xffd81667*/
  sub_FFD813D1(v7); /*0xffd81670*/
  v3 = sub_FFD7F948(&unk_FFD980AC); /*0xffd8167a*/
  v4 = v3; /*0xffd8167f*/
  if ( v3 < 0 ) /*0xffd81683*/
  {
    sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v3); /*0xffd8168c*/
    v5 = sub_FFD7F97E(); /*0xffd81694*/
    if ( v5 ) /*0xffd8169b*/
      (*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffd816a8*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchInitPreMem.c",
        2007,
        "!EFI_ERROR (Status)");
  }
  sub_FFD7F9AF(64, (int)"PchInitPreMem() - End\n"); /*0xffd816b5*/
  return v4; /*0xffd816bc*/
}

// === Function at 0xffd816c4 ===
int sub_FFD816C4()
{
  int v0; // esi
  int v1; // ecx
  __int16 v2; // ax
  double v4; // [esp-4h] [ebp-34h]
  double v5; // [esp-4h] [ebp-34h]
  double v6; // [esp-4h] [ebp-34h]
  _BYTE v7[32]; // [esp+Ch] [ebp-24h] BYREF
  int p_n32; // [esp+2Ch] [ebp-4h] BYREF

  v0 = sub_FFD8CBBA(0, 31, 0); /*0xffd816db*/
  p_n32 = 32; /*0xffd816e3*/
  sub_FFD8BE68(); /*0xffd816e6*/
  sub_FFD8C111(&p_n32); /*0xffd816f1*/
  LODWORD(v4) = v7; /*0xffd816fa*/
  sub_FFD7F9AF(64, (int)"PCH Series   : %a\n", v4);
  p_n32 = 32; /*0xffd8170a*/
  sub_FFD8BB3A(v1); /*0xffd81712*/
  sub_FFD8C06D(&p_n32); /*0xffd8171d*/
  LODWORD(v5) = v7; /*0xffd81726*/
  sub_FFD7F9AF(64, (int)"PCH Stepping : %a\n", v5);
  p_n32 = 32; /*0xffd81736*/
  v2 = sub_FFD8CCA5((unsigned __int16 *)(v0 + 2)); /*0xffd81740*/
  sub_FFD8C1B5(v2, v7, &p_n32); /*0xffd8174a*/
  LODWORD(v6) = v7; /*0xffd81753*/
  return sub_FFD7F9AF(64, (int)"PCH SKU      : %a\n", v6);
}

// === Function at 0xffd821b8 ===
int __fastcall sub_FFD821B8(int a1, char a2, int a3, unsigned __int8 n2)
{
  unsigned __int8 n2_1; // bh
  char v5; // bl
  int v7; // edi
  int v8; // eax
  __int16 v9; // si
  int v10; // edx
  unsigned __int8 v11; // bl
  char v12; // al
  char v13; // al
  char n2_2; // [esp+11h] [ebp-3h] BYREF
  char v16; // [esp+12h] [ebp-2h]
  char v17; // [esp+13h] [ebp-1h] BYREF

  n2_1 = n2; /*0xffd821ba*/
  v5 = 0; /*0xffd821be*/
  v16 = a2; /*0xffd821c0*/
  if ( n2 == 1 )
  {
    sub_FFD7F9AF(64, (int)"EarlyConfigurePchHSata() - First Controller - Start\n"); /*0xffd821d5*/
    v7 = sub_FFD8CBBA(0, 23, 0); /*0xffd821e9*/
    sub_FFD8C019(); /*0xffd821eb*/
  }
  else
  {
    if ( n2 != 2 )
    {
      sub_FFD7F9AF(0x80000000, (int)"Error: Invalid SATA controller!\n");
      return -2147483646; /*0xffd8244e*/
    }
    sub_FFD7F9AF(64, (int)"EarlyConfigurePchHSata() - Second Controller - Start\n"); /*0xffd82202*/
    v7 = sub_FFD8CBBA(0, 17, 5); /*0xffd82216*/
  }
  v8 = sub_FFD8CBBA(0, 31, 0); /*0xffd8221f*/
  v9 = sub_FFD8CCA5((unsigned __int16 *)(v8 + 2)); /*0xffd8222d*/
  if ( !(unsigned __int8)sub_FFD8D58A() ) /*0xffd82230*/
  {
    if ( n2_1 == 1 ) /*0xffd8223c*/
      v5 = sub_FFD81814(); /*0xffd82243*/
    if ( n2_1 != 2 ) /*0xffd82248*/
      goto LABEL_14; /*0xffd82248*/
    v11 = 0; /*0xffd8224a*/
    while ( 1 ) /*0xffd82253*/
    {
      sub_FFD8E7BA(v11, &n2); /*0xffd82253*/
      sub_FFD8E062(n2, &v17, &n2_2); /*0xffd82266*/
      if ( n2_2 == 2 ) /*0xffd82271*/
        break; /*0xffd82271*/
      if ( ++v11 >= 6u ) /*0xffd82278*/
      {
        v5 = 0; /*0xffd8227a*/
        goto LABEL_14; /*0xffd8227c*/
      }
    }
  }
  v5 = 1; /*0xffd8227e*/
LABEL_14:
  if ( (*(_BYTE *)a1 & 1) != 0 && (v5 || *(_DWORD *)(a1 + 4)) ) /*0xffd8228e*/
  {
    *(_BYTE *)(v7 + 160) = -104; /*0xffd82298*/
    *(_DWORD *)(v7 + 164) = *(_DWORD *)(v7 + 164) & 0xFFFFFE00 | 0x183; /*0xffd822ad*/
    *(_BYTE *)(v7 + 160) = -104; /*0xffd822b3*/
    *(_DWORD *)(v7 + 164) |= 0x8000u; /*0xffd822c5*/
    *(_BYTE *)(v7 + 160) = -92; /*0xffd822cb*/
    *(_DWORD *)(v7 + 164) |= 0x40u; /*0xffd822db*/
    if ( v9 == -24254 /*0xffd8237d*/
      || v9 == -24253
      || v9 == -24252
      || v9 == -24251
      || v9 == -24250
      || v9 == -24249
      || v9 == -24248
      || v9 == -24256
      || v9 == -24255
      || v9 == -24243
      || v9 == -24242
      || v9 == -24241
      || v9 == -25280
      || v9 == -25279
      || v9 == -25278
      || v9 == -25277
      || v9 == -25274
      || v9 == -25272 )
    {
      *(_BYTE *)(v7 + 160) = -100; /*0xffd8237f*/
      *(_DWORD *)(v7 + 164) |= 0x400000u; /*0xffd82391*/
    }
    *(_BYTE *)(v7 + 160) = -100; /*0xffd82397*/
    *(_DWORD *)(v7 + 164) = *(_DWORD *)(v7 + 164) & 0xDF63E013 | 0x209C0224; /*0xffd823ae*/
    if ( n2_1 == 1 ) /*0xffd823b7*/
    {
      *(_BYTE *)(v7 + 160) = -100; /*0xffd823b9*/
      *(_DWORD *)(v7 + 164) |= 0x40000000u; /*0xffd823cb*/
    }
    v12 = *(_BYTE *)(v7 + 156) | 0x20; /*0xffd823d7*/
    if ( *(_DWORD *)(a1 + 4) == 1 ) /*0xffd823dd*/
    {
      if ( (*(_BYTE *)(a1 + 76) & 1) != 0 ) /*0xffd823e5*/
        v12 = *(_BYTE *)(v7 + 156) & 0x1F | 0xA0; /*0xffd823e7*/
      else
        v12 = *(_BYTE *)(v7 + 156) & 0x1F | 0x60; /*0xffd823eb*/
    }
    if ( v16 ) /*0xffd823f2*/
      v13 = v12 & 0xE1 | 6; /*0xffd823f6*/
    else
      v13 = v12 & 0xE8 | 0x10; /*0xffd823fc*/
    *(_BYTE *)(v7 + 156) = v13 & 0xF8 | 6; /*0xffd8240d*/
    sub_FFD8CC4F(v7 + 148, 255); /*0xffd82413*/
    sub_FFD7FA46(2u); /*0xffd8241b*/
    sub_FFD7F9AF(64, (int)"EarlyConfigurePchHSata() End\n"); /*0xffd82427*/
    return 0; /*0xffd8242c*/
  }
  else
  {
    LOBYTE(v10) = n2_1; /*0xffd82434*/
    sub_FFD81FF5(a3, v10); /*0xffd82436*/
    return 0; /*0xffd8243b*/
  }
}

// === Function at 0xffd8245b ===
int __cdecl sub_FFD8245B(int n2)
{
  int v1; // ecx
  int v2; // ebx
  int v3; // edi
  int v4; // esi
  unsigned int n6; // ebp
  int v6; // eax
  unsigned __int8 n6_1; // cl
  int v8; // eax

  v2 = 0; /*0xffd82460*/
  v3 = v1; /*0xffd8246c*/
  if ( (_BYTE)n2 == 1 ) /*0xffd8246e*/
  {
    sub_FFD7F9AF(64, (int)"ConfigurePchHSata() - First Controller - Start\n"); /*0xffd82477*/
    v4 = sub_FFD8CBBA(0, 23, 0); /*0xffd8248a*/
    n6 = (unsigned __int8)sub_FFD8C019(); /*0xffd82491*/
  }
  else
  {
    sub_FFD7F9AF(64, (int)"ConfigurePchHSata() - Second Controller - Start\n"); /*0xffd8249d*/
    v4 = sub_FFD8CBBA(0, 17, 5); /*0xffd824b1*/
    n6 = 6; /*0xffd824b5*/
  }
  v6 = sub_FFD8CBBA(0, 31, 0); /*0xffd824bc*/
  sub_FFD8CCA5((unsigned __int16 *)(v6 + 2)); /*0xffd824c5*/
  sub_FFD81B92(n2); /*0xffd824d4*/
  if ( (*(_BYTE *)v3 & 8) != 0 ) /*0xffd824dd*/
  {
    n6_1 = 0; /*0xffd824e3*/
    if ( n6 ) /*0xffd824e7*/
    {
      v8 = 0; /*0xffd824e9*/
      do /*0xffd82506*/
      {
        if ( (*(_BYTE *)(v3 + 8 * v8 + 12) & 1) != 0 && (*(_DWORD *)(v3 + 8 * v8 + 12) & 0x40000A) != 0 ) /*0xffd824fa*/
          v2 |= 1 << v8; /*0xffd824fc*/
        v8 = ++n6_1; /*0xffd82501*/
      }
      while ( n6_1 < n6 ); /*0xffd82506*/
    }
    *(_BYTE *)(v4 + 160) = -112; /*0xffd82508*/
    *(_DWORD *)(v4 + 164) |= (unsigned __int8)~(_BYTE)v2; /*0xffd82521*/
    *(_BYTE *)(v4 + 160) = 0x80; /*0xffd8252c*/
    *(_DWORD *)(v4 + 164) |= v2 << 16; /*0xffd8253b*/
    *(_BYTE *)(v4 + 160) = -116; /*0xffd82541*/
    *(_DWORD *)(v4 + 164) |= 0xFF00FFu; /*0xffd82550*/
    *(_BYTE *)(v4 + 160) = -96; /*0xffd82556*/
    *(_DWORD *)(v4 + 164) = *(_DWORD *)(v4 + 164) & 0xFF037FFF | 0x588000; /*0xffd8256d*/
    *(_BYTE *)(v4 + 160) = -124; /*0xffd82573*/
    *(_DWORD *)(v4 + 164) |= 0xFF00FFu; /*0xffd82582*/
    *(_BYTE *)(v4 + 160) = -92; /*0xffd82588*/
    *(_DWORD *)(v4 + 164) |= 0x4000u; /*0xffd8259a*/
    *(_BYTE *)(v4 + 160) = -52; /*0xffd825a0*/
    *(_DWORD *)(v4 + 164) = -2009296895; /*0xffd825a7*/
    *(_BYTE *)(v4 + 160) = -48; /*0xffd825b1*/
    *(_DWORD *)(v4 + 164) = *(_DWORD *)(v4 + 164) & 0xFFFF0000 | 0x8828; /*0xffd825c8*/
    *(_BYTE *)(v4 + 160) = -56; /*0xffd825ce*/
    *(_DWORD *)(v4 + 164) |= 8u; /*0xffd825de*/
    *(_BYTE *)(v4 + 160) = -56; /*0xffd825e4*/
    *(_DWORD *)(v4 + 164) |= 1u; /*0xffd825f4*/
    *(_BYTE *)(v4 + 160) = -56; /*0xffd825fa*/
    *(_DWORD *)(v4 + 164) |= 2u; /*0xffd8260a*/
  }
  *(_BYTE *)(v4 + 160) = -88; /*0xffd82610*/
  *(_DWORD *)(v4 + 164) &= 0xFFF0FFFF; /*0xffd82622*/
  *(_BYTE *)(v4 + 160) = -44; /*0xffd82628*/
  *(_DWORD *)(v4 + 164) = *(_DWORD *)(v4 + 164) & 0xC0C0E0E0 | 0x2C1E1108; /*0xffd8263f*/
  *(_BYTE *)(v4 + 158) &= ~1u; /*0xffd8264d*/
  if ( *(_DWORD *)(v3 + 4) == 1 ) /*0xffd82657*/
    *(_BYTE *)(v4 + 158) |= 1u; /*0xffd82661*/
  if ( (_BYTE)n2 == 1 ) /*0xffd8266c*/
    return sub_FFD7F9AF(64, (int)"ConfigurePchHSata() - First Controller - End\n"); /*0xffd82673*/
  else
    return sub_FFD7F9AF(64, (int)"ConfigurePchHSata() - Second Controller - End\n"); /*0xffd8267c*/
}

// === Function at 0xffd826ae ===
bool __fastcall sub_FFD826AE(int a1, int a2, char a3)
{
  int v5; // eax
  int v6; // ecx
  int n17; // [esp+Ch] [ebp-10h] BYREF
  int v9; // [esp+10h] [ebp-Ch]
  int v10; // [esp+14h] [ebp-8h] BYREF
  char n2; // [esp+1Bh] [ebp-1h]

  v5 = sub_FFD8AD54(); /*0xffd826bb*/
  (*(void (__cdecl **)(int, int *))(*(_DWORD *)v5 + 40))(v5, &n17); /*0xffd826c7*/
  n2 = *(_BYTE *)(100 * a2 + a1 + 5); /*0xffd826d6*/
  sub_FFD8D75C(&v10); /*0xffd826dd*/
  v6 = sub_FFD8CBBA(0, v9, v10); /*0xffd826f3*/
  return (!n2 || n2 == 2) && n17 == 17 && (*(_BYTE *)(v6 + 76) & 0xFu) >= 3 && a3 == 1; /*0xffd8271c*/
}

// === Function at 0xffd82c71 ===
int sub_FFD82C71()
{
  unsigned int i; // edi
  int v1; // ebx
  unsigned __int16 v2; // ax
  char v4; // [esp+10h] [ebp-8h]
  int v5; // [esp+14h] [ebp-4h] BYREF

  sub_FFD7F9AF(64, (int)"PciERWORegInit() Start\n"); /*0xffd82c81*/
  if ( (unsigned __int8)sub_FFD8D59A() )
  {
    sub_FFD7F9AF(64, (int)"DWR: PciERWORegInit() End\n");
  }
  else
  {
    sub_FFD8BE68(); /*0xffd82c9b*/
    for ( i = 0; i < (unsigned __int8)sub_FFD8BFFD(); ++i ) /*0xffd82ca2*/
    {
      sub_FFD8D75C(&v5); /*0xffd82cb4*/
      v1 = sub_FFD8CBBA(0, v4, v5); /*0xffd82cc8*/
      if ( (unsigned __int16)sub_FFD8CCA5((unsigned __int16 *)v1) != 0xFFFF ) /*0xffd82cd9*/
      {
        v2 = sub_FFD8CCA5((unsigned __int16 *)(v1 + 68)); /*0xffd82cde*/
        sub_FFD8CCD3(v1 + 68, v2); /*0xffd82ce9*/
        *(_DWORD *)(v1 + 76) = *(_DWORD *)(v1 + 76); /*0xffd82cf1*/
        *(_DWORD *)(v1 + 84) = *(_DWORD *)(v1 + 84); /*0xffd82cf7*/
        *(_DWORD *)(v1 + 216) |= 0x800000u; /*0xffd82d05*/
      }
    }
    sub_FFD7F9AF(64, (int)"PciERWORegInit() End\n"); /*0xffd82d1f*/
  }
  return 0; /*0xffd82d26*/
}

// === Function at 0xffd82d2f ===
int __fastcall sub_FFD82D2F(int a1, int a2)
{
  unsigned __int8 i_1; // al
  unsigned int i_2; // esi
  unsigned int i; // ebx
  int v5; // eax
  int v6; // edi
  unsigned int j; // esi
  int v8; // ebp
  unsigned int n0x96; // ebp
  unsigned int i_3; // esi
  unsigned int k; // ebp
  int v12; // esi
  unsigned int n0x96_2; // ebp
  unsigned int i_4; // esi
  unsigned int n0x96_1; // [esp+14h] [ebp-60h] BYREF
  unsigned int v17; // [esp+18h] [ebp-5Ch]
  int v18; // [esp+1Ch] [ebp-58h]
  int v19; // [esp+20h] [ebp-54h]
  _DWORD v20[20]; // [esp+24h] [ebp-50h]

  v18 = a2; /*0xffd82d36*/
  v19 = a1; /*0xffd82d3a*/
  if ( (unsigned __int8)sub_FFD8D59A() )
  {
    sub_FFD7F9AF(64, (int)"DWR: PchPcieRpSpeedChange() End\n");
  }
  else
  {
    i_1 = sub_FFD8BFFD(); /*0xffd82d5a*/
    i_2 = 0; /*0xffd82d5f*/
    for ( i = i_1; i_2 < i; ++i_2 ) /*0xffd82d66*/
    {
      v20[i_2] = 0; /*0xffd82d68*/
      if ( sub_FFD8D75C(&n0x96_1) >= 0 ) /*0xffd82d80*/
      {
        v20[i_2] = sub_FFD8CBBA(0, v17, n0x96_1); /*0xffd82db2*/
      }
      else
      {
        v5 = sub_FFD7F97E(); /*0xffd82d82*/
        if ( v5 ) /*0xffd82d89*/
          (*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffd82d9a*/
            "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchRootPorts.c",
            822,
            "((BOOLEAN)(0==1))");
      }
    }
    v6 = 0; /*0xffd82dbb*/
    for ( j = 0; j < i; ++j ) /*0xffd82dc1*/
    {
      v8 = v20[j]; /*0xffd82dc3*/
      if ( v8 ) /*0xffd82dc9*/
      {
        if ( (unsigned __int16)sub_FFD8CCA5((unsigned __int16 *)v20[j]) != 0xFFFF ) /*0xffd82dda*/
        {
          v17 = *(_DWORD *)(v8 + 76) & 0xF; /*0xffd82de2*/
          if ( v17 > 1 && !sub_FFD826AE(v19 + 28, j, *(_BYTE *)(j + v18)) ) /*0xffd82dfd*/
          {
            sub_FFD8CC85(v17); /*0xffd82e13*/
            if ( (sub_FFD8CCA5((unsigned __int16 *)(v8 + 90)) & 0x40) != 0 ) /*0xffd82e23*/
            {
              sub_FFD8CC4F(v8 + 80, 32); /*0xffd82e2b*/
              v6 |= 1 << j; /*0xffd82e30*/
            }
          }
        }
      }
    }
    n0x96 = 0; /*0xffd82e38*/
    n0x96_1 = 0; /*0xffd82e3a*/
    if ( v6 ) /*0xffd82e40*/
    {
      do /*0xffd82e90*/
      {
        if ( n0x96 >= 0x96 ) /*0xffd82e4c*/
          break; /*0xffd82e4c*/
        sub_FFD7FA46(0x64u); /*0xffd82e51*/
        i_3 = 0; /*0xffd82e56*/
        if ( i ) /*0xffd82e5a*/
        {
          do /*0xffd82e83*/
          {
            if ( ((1 << i_3) & v6) != 0 && (sub_FFD8CCA5((unsigned __int16 *)(v20[i_3] + 82)) & 0x2000) != 0 ) /*0xffd82e7b*/
              v6 &= ~(1 << i_3); /*0xffd82e7d*/
            ++i_3; /*0xffd82e80*/
          }
          while ( i_3 < i ); /*0xffd82e83*/
          n0x96 = n0x96_1; /*0xffd82e85*/
        }
        n0x96_1 = ++n0x96; /*0xffd82e8a*/
      }
      while ( v6 ); /*0xffd82e90*/
      if ( v6 ) /*0xffd82e94*/
      {
        for ( k = 0; k < i; ++k ) /*0xffd82e9e*/
        {
          if ( ((1 << k) & v6) != 0 ) /*0xffd82ea9*/
          {
            v12 = v20[k]; /*0xffd82eab*/
            sub_FFD8CC85(1); /*0xffd82eb9*/
            sub_FFD8CC4F(v12 + 80, 32); /*0xffd82ec5*/
          }
        }
        n0x96_2 = 0; /*0xffd82ecf*/
        n0x96_1 = 0; /*0xffd82ed1*/
        do /*0xffd82f1f*/
        {
          if ( n0x96_2 >= 0x96 ) /*0xffd82edb*/
            break; /*0xffd82edb*/
          sub_FFD7FA46(0x64u); /*0xffd82ee0*/
          i_4 = 0; /*0xffd82ee5*/
          if ( i ) /*0xffd82ee9*/
          {
            do /*0xffd82f12*/
            {
              if ( ((1 << i_4) & v6) != 0 && (sub_FFD8CCA5((unsigned __int16 *)(v20[i_4] + 82)) & 0x2000) != 0 ) /*0xffd82f0a*/
                v6 &= ~(1 << i_4); /*0xffd82f0c*/
              ++i_4; /*0xffd82f0f*/
            }
            while ( i_4 < i ); /*0xffd82f12*/
            n0x96_2 = n0x96_1; /*0xffd82f14*/
          }
          n0x96_1 = ++n0x96_2; /*0xffd82f19*/
        }
        while ( v6 ); /*0xffd82f1f*/
      }
    }
  }
  return 0; /*0xffd82f21*/
}

// === Function at 0xffd82f2b ===
bool __fastcall sub_FFD82F2B(int a1, unsigned __int8 a2, unsigned __int16 *a3)
{
  char v5; // bl
  unsigned int v7; // ebp
  unsigned __int8 v8; // al
  unsigned __int16 *v9; // ecx
  unsigned int *v11; // [esp+1Ch] [ebp+4h]

  v5 = 0; /*0xffd82f40*/
  *(_DWORD *)(a3 + 1) = 0xFFFF; /*0xffd82f42*/
  *a3 = -1; /*0xffd82f49*/
  if ( (sub_FFD8CCA5((unsigned __int16 *)(a1 + 90)) & 0x40) == 0 ) /*0xffd82f56*/
    return 0; /*0xffd82f58*/
  *(_DWORD *)(a1 + 24) = *(_DWORD *)(a1 + 24) & 0xFF0000FF | ((a2 | (a2 << 8)) << 8); /*0xffd82f7c*/
  v11 = (unsigned int *)sub_FFD8CBBA(a2, 0, 0); /*0xffd82f8b*/
  sub_FFD8CCD3(v11, 0); /*0xffd82f8f*/
  v7 = *v11; /*0xffd82f94*/
  *(_DWORD *)a3 = *v11; /*0xffd82f9c*/
  if ( v7 != -1 ) /*0xffd82fa6*/
  {
    v8 = sub_FFD90A71(0, HIWORD(v7)); /*0xffd82fb0*/
    if ( v8 ) /*0xffd82fb9*/
    {
      v9 = (unsigned __int16 *)((char *)v11 + v8 + 12); /*0xffd82fc5*/
      v5 = *(_BYTE *)v9 & 0xF; /*0xffd82fc9*/
      *((_BYTE *)a3 + 5) = ((unsigned __int16)sub_FFD8CCA5(v9) >> 4) & 0x3F; /*0xffd82fd7*/
    }
    *((_BYTE *)a3 + 4) = v5; /*0xffd82fda*/
  }
  *(_DWORD *)(a1 + 24) &= 0xFF0000FF; /*0xffd82fe5*/
  sub_FFD7F9AF(
    64,
    (int)"VID: %04X DID: %04X  MLS: %d MLW: %d\n",
    *a3,
    a3[1],
    *((unsigned __int8 *)a3 + 4),
    *((unsigned __int8 *)a3 + 5));
  return v7 != -1; /*0xffd83012*/
}

// === Function at 0xffd83019 ===
int sub_FFD83019()
{
  int result; // eax
  int v1; // eax
  int v2; // esi
  int v3; // eax
  int *v4; // eax
  int *v5; // esi
  int v6; // ecx
  int v7; // eax
  int v8; // esi
  int v9; // eax
  _DWORD v10[2]; // [esp+0h] [ebp-10h] BYREF
  char v11[8]; // [esp+8h] [ebp-8h] BYREF

  result = sub_FFD8D59A(); /*0xffd8301c*/
  if ( (_BYTE)result )
  {
    sub_FFD7F9AF(0x80000000, (int)"\nDirtyWarmResetExecute() - Start\n"); /*0xffd83037*/
    v1 = sub_FFD85F37(); /*0xffd8303c*/
    v2 = sub_FFD8D921(v1); /*0xffd83048*/
    if ( sub_FFD82F2B(v2, 2u, (unsigned __int16 *)v11) )
    {
      *(_DWORD *)(v2 + 24) = *(_DWORD *)(v2 + 24) & 0xFF0000FF | 0x20200; /*0xffd83083*/
      v3 = sub_FFD8CBBA(2u, 0, 0); /*0xffd83086*/
      sub_FFD8CCD3(v3, 0); /*0xffd83090*/
    }
    else
    {
      sub_FFD7F9AF(0x80000000, (int)"ERROR: DirtyWarmReset: can't get end point device available...\n");
    }
    v4 = (int *)sub_FFD8CC10(); /*0xffd83099*/
    v5 = v4; /*0xffd8309e*/
    v6 = *v4; /*0xffd830a8*/
    if ( (*v4 & 0x2000000) != 0 && v6 != -1 ) /*0xffd830b5*/
      *v4 = v6 | 0x4000000; /*0xffd830b9*/
    sub_FFD7F9AF(64, (int)"DWR: Sending DirtyWarmReset Notification ...\n");
    sub_FFD7F948(&unk_FFD93FB4); /*0xffd830cc*/
    sub_FFD7F9AF(64, (int)"DWR: DirtyWarmReset Notification completed\n");
    if ( (*v5 & 0x2000000) != 0 && *v5 != -1 )
    {
      sub_FFD7F9AF(64, (int)"\nDWR: Stalling in DWR flow to allow error collection.\n");
      while ( (*v5 & 0x4000000) != 0 ) /*0xffd83100*/
        ; /*0xffd830fc*/
    }
    v7 = sub_FFD8AD54(); /*0xffd83102*/
    v8 = (*(int (__cdecl **)(int, void *, _DWORD, _DWORD, _DWORD *))(*(_DWORD *)v7 + 32))(v7, &unk_FFD97FAC, 0, 0, v10); /*0xffd8311c*/
    if ( v8 < 0 )
    {
      sub_FFD7F9AF(0x80000000, (int)"\nDWR: ERROR: Can't get reset PPI\n");
      sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v8); /*0xffd83142*/
      v9 = sub_FFD7F97E(); /*0xffd8314a*/
      if ( v9 ) /*0xffd83151*/
        (*(void (__cdecl **)(const char *, int, const char *))(v9 + 4))( /*0xffd83162*/
          "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchRootPorts.c",
          1104,
          "!EFI_ERROR (Status)");
    }
    else
    {
      (*(void (__cdecl **)(_DWORD, int))v10[0])(v10[0], 5); /*0xffd8312a*/
    }
    sub_FFD7F9AF(0x80000000, (int)"\nDWR: Waiting for reset.\n");
    v10[1] = 0; /*0xffd83175*/
    while ( 1 ) /*0xffd83179*/
      ; /*0xffd83179*/
  }
  return result; /*0xffd83182*/
}

// === Function at 0xffd83186 ===
int __thiscall sub_FFD83186(char *this)
{
  int v2; // eax
  int v3; // eax
  int v4; // eax
  int v5; // eax
  int v6; // esi
  double v8; // [esp-4h] [ebp-20h]
  int v9; // [esp+14h] [ebp-8h] BYREF

  v2 = sub_FFD8D75C(&v9); /*0xffd8319f*/
  if ( v2 < 0 ) /*0xffd831b1*/
  {
    sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v2); /*0xffd831be*/
    v3 = sub_FFD7F97E(); /*0xffd831c6*/
    if ( v3 ) /*0xffd831cd*/
      (*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffd831d6*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchRootPorts.c",
        1132,
        "!EFI_ERROR (Status)");
  }
  v4 = sub_FFD9041E(&v9); /*0xffd831e8*/
  if ( v4 < 0 ) /*0xffd831f0*/
  {
    sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0xffd831fd*/
    v5 = sub_FFD7F97E(); /*0xffd83205*/
    if ( v5 ) /*0xffd8320c*/
      (*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffd83215*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchRootPorts.c",
        1135,
        "!EFI_ERROR (Status)");
  }
  v6 = (unsigned __int16)v9 >> 14; /*0xffd83225*/
  LODWORD(v8) = off_FFD93F7C[v6]; // "4x1" /*0xffd83228*/
  sub_FFD7F9AF(64, (int)"PCIe SP%c is %a\n", this + 65, v8); /*0xffd83237*/
  return v6; /*0xffd83241*/
}

// === Function at 0xffd83249 ===
int sub_FFD83249()
{
  int n2; // esi
  char *n3_1; // edi
  int v2; // ebx
  int v3; // eax
  int v4; // eax
  int v5; // eax
  int v6; // eax
  unsigned int i; // ebp
  int v8; // eax
  int v9; // ecx
  int v10; // esi
  int v12; // [esp+14h] [ebp-30h]
  int v13; // [esp+1Ch] [ebp-28h]
  int n2_2; // [esp+28h] [ebp-1Ch]
  int v15; // [esp+2Ch] [ebp-18h]
  unsigned int n3; // [esp+30h] [ebp-14h]
  int n2_1; // [esp+34h] [ebp-10h]
  int n4; // [esp+38h] [ebp-Ch]
  int n4_1; // [esp+3Ch] [ebp-8h]
  int n4_2; // [esp+40h] [ebp-4h]

  sub_FFD7F9AF(64, (int)"PchConfigurePsfGrantCountsForPcie() Start\n"); /*0xffd83257*/
  n2 = sub_FFD8BE68(); /*0xffd83263*/
  n2_2 = n2; /*0xffd83265*/
  if ( n2 == 2 ) /*0xffd8326c*/
    n3 = 3; /*0xffd8326e*/
  else
    n3 = 5; /*0xffd83288*/
  n3_1 = 0; /*0xffd832a0*/
  v2 = 0; /*0xffd832a2*/
  v15 = 0; /*0xffd832a6*/
  do /*0xffd8341f*/
  {
    v3 = sub_FFD83186(n3_1); /*0xffd832ad*/
    if ( !v3 ) /*0xffd832b5*/
    {
      n2_1 = 1; /*0xffd83325*/
      n4 = 1; /*0xffd83329*/
      goto LABEL_16; /*0xffd83329*/
    }
    v4 = v3 - 1; /*0xffd832b7*/
    if ( !v4 ) /*0xffd832ba*/
    {
      n2_1 = 2; /*0xffd83313*/
      n4 = 4; /*0xffd8331b*/
LABEL_16:
      n4_2 = 1; /*0xffd8332d*/
      n4_1 = 1; /*0xffd83331*/
      goto LABEL_17; /*0xffd83331*/
    }
    v5 = v4 - 1; /*0xffd832bc*/
    if ( v5 ) /*0xffd832bf*/
    {
      if ( v5 != 1 ) /*0xffd832c4*/
      {
        v6 = sub_FFD7F97E(); /*0xffd832c6*/
        if ( v6 ) /*0xffd832cd*/
          (*(void (__cdecl **)(const char *, int, const char *))(v6 + 4))( /*0xffd832e2*/
            "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchRootPorts.c",
            1230,
            "((BOOLEAN)(0==1))");
        goto LABEL_23; /*0xffd832e8*/
      }
      n2_1 = 4; /*0xffd832ed*/
      n4_1 = 4; /*0xffd832f1*/
    }
    else
    {
      n2_1 = 2; /*0xffd832f7*/
      n4_1 = 2; /*0xffd832ff*/
    }
    n4 = 4; /*0xffd83307*/
    n4_2 = 4; /*0xffd8330b*/
LABEL_17:
    for ( i = 0; i < 4; ++i ) /*0xffd83335*/
    {
      if ( n2 == 2 ) /*0xffd8333a*/
      {
        v8 = (unsigned __int8)byte_FFD93FCC[v2]; /*0xffd83343*/
        v12 = (unsigned __int8)byte_FFD93FCD[v2]; /*0xffd8334a*/
        v9 = (unsigned __int8)byte_FFD93F44[4 * (_DWORD)n3_1 + i]; /*0xffd8334e*/
      }
      else
      {
        v8 = (unsigned __int8)byte_FFD93F8C[v2]; /*0xffd8335f*/
        v12 = (unsigned __int8)byte_FFD93F8D[v2]; /*0xffd83366*/
        v9 = (unsigned __int8)byte_FFD93F5C[4 * (_DWORD)n3_1 + i]; /*0xffd8336a*/
      }
      v10 = *(&n2_1 + i); /*0xffd83372*/
      v13 = v9; /*0xffd8337f*/
      sub_FFD7F9AF(64, (int)"DGCR%d = %d\n", v8, v10); /*0xffd83387*/
      sub_FFD8C578(-32, v10); /*0xffd8339f*/
      sub_FFD7F9AF(64, (int)"DGCR%d = %d\n", v12, v10); /*0xffd833b0*/
      sub_FFD8C578(-32, v10); /*0xffd833c8*/
      sub_FFD7F9AF(64, (int)"PG1_TGT%d = %d\n", v13, v10); /*0xffd833d9*/
      sub_FFD8C578(-32, v10); /*0xffd833f4*/
      n2 = n2_2; /*0xffd833f9*/
      v2 += 2; /*0xffd833ff*/
    }
    v2 = v15; /*0xffd8340c*/
LABEL_23:
    ++n3_1; /*0xffd83413*/
    v2 += 8; /*0xffd83414*/
    v15 = v2; /*0xffd83417*/
  }
  while ( (unsigned int)n3_1 < n3 ); /*0xffd8341f*/
  return sub_FFD7F9AF(64, (int)"PchConfigurePsfGrantCountsForPcie() End\n"); /*0xffd83433*/
}

// === 0xffd85246 ===
{"addr":"0xffd85246","code":"int __fastcall sub_FFD85246(int a1, int a2, int a3)\n{\n  int n15000_6; // edi\n  int v5; // ebx\n  int n15000_5; // esi\n  unsigned __int8 v7; // al\n  int v8; // ebp\n  _DWORD *n15000_8; // ebp\n  int v10; // edi\n  int v11; // esi\n  unsigned __int8 v12; // al\n  int v13; // edi\n  unsigned int v14; // eax\n  int v15; // ecx\n  unsigned __int8 v16; // al\n  int v17; // esi\n  int v18; // eax\n  bool v19; // zf\n  unsigned __int16 *i; // ecx\n  int v21; // ecx\n  _WORD *n15000_7; // esi\n  int v23; // edi\n  int v24; // edx\n  int v25; // ebx\n  int v26; // esi\n  int v27; // eax\n  int j; // ebx\n  int n15000_3; // edi\n  int v30; // eax\n  unsigned int j_1; // ecx\n  int v32; // esi\n  unsigned int v33; // edx\n  int v34; // edx\n  char *v35; // edi\n  int v36; // ecx\n  char v37; // al\n  int v38; // ebx\n  int v39; // edi\n  int v40; // esi\n  int n15000_4; // edx\n  unsigned int v42; // ecx\n  int v43; // eax\n  int v44; // eax\n  unsigned __int8 v46; // [esp+10h] [ebp-48h]\n  unsigned __int8 v47; // [esp+11h] [ebp-47h]\n ... [11197 chars total]","refs":[{"addr":"0xffd7f9af","name":"sub_FFD7F9AF"},{"addr":"0xffd93d94","name":"aPchinitrootpor","string":"PchInitRootPorts() Start\n"},{"addr":"0xffd93db0","name":"aDwrPchinitroot","string":"DWR: PchInitRootPorts() End\n"},{"addr":"0xffd8d59a","name":"sub_FFD8D59A"},{"addr":"0xffd8cbba","name":"sub_FFD8CBBA"},{"addr":"0xffd8c76f","name":"sub_FFD8C76F"},{"addr":"0xffd8bffd","name":"sub_FFD8BFFD"},{"addr":"0xffd8d921","name":"sub_FFD8D921"},{"addr":"0xffd834e9","name":"sub_FFD834E9"},{"addr":"0xffd839ac","name":"sub_FFD839AC"}]}Output truncated. Run: curl -o .ida-mcp/0dd08b46-6856-4525-99b0-6ec7e22c3ec6.json http://127.0.0.1:13432/output/0dd08b46-6856-4525-99b0-6ec7e22c3ec6.json

// === Function at 0xffd85f37 ===
int sub_FFD85F37()
{
  int v0; // eax
  int v1; // eax
  int v2; // esi
  int v3; // eax
  _DWORD v5[2]; // [esp+8h] [ebp-8h] BYREF

  v0 = sub_FFD8AD54(); /*0xffd85f3e*/
  v1 = (*(int (__cdecl **)(int, void *, _DWORD, _DWORD, _DWORD *))(*(_DWORD *)v0 + 32))(v0, &unk_FFD97EEC, 0, 0, v5); /*0xffd85f53*/
  v2 = v1; /*0xffd85f56*/
  if ( v1 < 0 )
  {
    sub_FFD7F9AF(0x80000000, (int)"ERROR: DWR Can't find PCH Policy (Status: %r)\n", v1);
    sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v2); /*0xffd85f78*/
    v3 = sub_FFD7F97E(); /*0xffd85f80*/
    if ( v3 ) /*0xffd85f88*/
      (*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffd85f99*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchRootPorts.c",
        4100,
        "!EFI_ERROR (Status)");
    v5[1] = 0; /*0xffd85f9f*/
    while ( 1 ) /*0xffd85fa2*/
      ; /*0xffd85fa2*/
  }
  return (unsigned __int8)(*(_DWORD *)(v5[0] + 2975) >> 18); /*0xffd85faa*/
}

// === Function at 0xffd860b8 ===
int __thiscall sub_FFD860B8(int this)
{
  int v2; // esi
  int v3; // edi
  int v4; // eax
  _DWORD *v5; // eax
  int n8; // edx
  int v8; // [esp+14h] [ebp-8h] BYREF
  int n17; // [esp+18h] [ebp-4h] BYREF

  sub_FFD7F9AF(64, (int)"ConfigureXhci() - Start\n"); /*0xffd860c8*/
  v2 = *(_DWORD *)(this + 3510); /*0xffd860cd*/
  sub_FFD8BE68(); /*0xffd860d9*/
  v3 = sub_FFD8CBBA(0, 20, 0); /*0xffd860f1*/
  sub_FFD8C76F(&v8); /*0xffd860f3*/
  *(_DWORD *)(v3 + 16) = v2; /*0xffd860fd*/
  sub_FFD8CC4F(v3 + 4, 6); /*0xffd86101*/
  if ( (*(_BYTE *)(this + 2263) & 2) != 0 ) /*0xffd86109*/
    *(_DWORD *)(v2 + 33004) |= 1u; /*0xffd86114*/
  v4 = sub_FFD8AD54(); /*0xffd8611a*/
  (*(void (__cdecl **)(int, int *))(*(_DWORD *)v4 + 40))(v4, &n17); /*0xffd86127*/
  if ( n17 == 17 ) /*0xffd86133*/
    sub_FFD86747(this + 2263); /*0xffd86137*/
  else
    sub_FFD85FBC(); /*0xffd8613e*/
  sub_FFD861FF(this, v2, v3); /*0xffd86148*/
  sub_FFD8701A(this, v2); /*0xffd86151*/
  sub_FFD7F9AF(64, (int)"xHCI: XhciPostInitDone Start\n");
  *(_DWORD *)(v2 + 32992) &= ~0x10000u; /*0xffd86174*/
  *(_DWORD *)(v3 + 80) = 265186911; /*0xffd8617c*/
  sub_FFD7F9AF(64, (int)"xHCI: XhciPostInitDone End\n");
  if ( (*(_BYTE *)(this + 2263) & 4) != 0 ) /*0xffd8618e*/
  {
    sub_FFD86E37(this + 2263, v3); /*0xffd86194*/
  }
  else
  {
    sub_FFD7F9AF(0x80000000, (int)"Clear Over-Current registers\n"); /*0xffd861a5*/
    v5 = (_DWORD *)(v3 + 208); /*0xffd861ae*/
    n8 = 8; /*0xffd861b4*/
    do /*0xffd861c8*/
    {
      *(v5 - 8) = 0; /*0xffd861b5*/
      *v5++ = 0; /*0xffd861bc*/
      --n8; /*0xffd861c5*/
    }
    while ( n8 ); /*0xffd861c8*/
  }
  sub_FFD8687F(this + 2263, v2); /*0xffd861ce*/
  sub_FFD8CC6A(v3 + 4, 65529); /*0xffd861db*/
  *(_DWORD *)(v3 + 16) = 0; /*0xffd861e7*/
  sub_FFD7F9AF(64, (int)"ConfigureXhciPreMem () - End\n"); /*0xffd861ee*/
  return 0; /*0xffd861f5*/
}

// === Function at 0xffd8690c ===
int __fastcall sub_FFD8690C(int a1, int a2)
{
  int v2; // ebp
  int n15_1; // ebx
  unsigned __int8 i_4; // cl
  unsigned __int8 i_1; // al
  unsigned __int64 v6; // rdi
  int v7; // ebx
  int v8; // ebp
  _DWORD *v9; // eax
  _DWORD *v10; // esi
  unsigned int v11; // ecx
  int result; // eax
  int v13; // [esp-8h] [ebp-34h]
  char v14; // [esp+11h] [ebp-1Bh] BYREF
  unsigned __int8 i; // [esp+12h] [ebp-1Ah]
  unsigned __int8 i_3; // [esp+13h] [ebp-19h]
  unsigned int n1342177280; // [esp+14h] [ebp-18h] BYREF
  int v18; // [esp+18h] [ebp-14h]
  int v19; // [esp+1Ch] [ebp-10h]
  int n15; // [esp+20h] [ebp-Ch] BYREF
  unsigned int i_2; // [esp+24h] [ebp-8h] BYREF
  unsigned int v22; // [esp+28h] [ebp-4h] BYREF

  v2 = a2; /*0xffd86913*/
  v19 = a1; /*0xffd86915*/
  v18 = a2; /*0xffd86920*/
  sub_FFD7F9AF(64, (int)"xHCI: Usb2AfeProgramming Start\n");
  sub_FFD8BE68(); /*0xffd86929*/
  sub_FFD8BB3A(v13); /*0xffd8692e*/
  sub_FFD8C909(&v22); /*0xffd86937*/
  n15_1 = sub_FFD8CBBA(0, 31, 2); /*0xffd8694b*/
  n15 = n15_1; /*0xffd86951*/
  sub_FFD8ADCC(202, 6, 16427, 0, 0, 0, &n1342177280, &v14, 6); /*0xffd86970*/
  n1342177280 |= 0x400000u; /*0xffd86975*/
  sub_FFD8ADCC(202, 7, 16427, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd86999*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd869a9*/
  sub_FFD8ADCC(202, 6, 16385, 0, 0, 0, &n1342177280, &v14, 6); /*0xffd869cc*/
  n1342177280 |= 0x3000000u; /*0xffd869d8*/
  sub_FFD8ADCC(202, 7, 16385, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd869f5*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd86a05*/
  sub_FFD8ADCC(202, 6, 28672, 0, 0, 0, &n1342177280, &v14, 6); /*0xffd86a2a*/
  n1342177280 = (unsigned __int16)n1342177280 | 0x50500000; /*0xffd86a41*/
  sub_FFD8ADCC(202, 7, 28672, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd86a59*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd86a69*/
  n1342177280 = 1342177280; /*0xffd86a71*/
  sub_FFD8ADCC(202, 7, 28724, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd86a95*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd86aa5*/
  n1342177280 = 175176950; /*0xffd86aad*/
  sub_FFD8ADCC(202, 7, 28728, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd86ad3*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd86ae3*/
  n1342177280 = 532398080; /*0xffd86aeb*/
  sub_FFD8ADCC(202, 7, 28732, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd86b0f*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd86b1f*/
  n1342177280 = 34432; /*0xffd86b27*/
  sub_FFD8ADCC(202, 7, 32516, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd86b4d*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd86b5d*/
  n1342177280 = 67251212; /*0xffd86b65*/
  sub_FFD8ADCC(202, 7, 28712, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd86b8b*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd86b9b*/
  n1342177280 = 184552192; /*0xffd86ba9*/
  sub_FFD8ADCC(202, 7, 32515, 0, 1u, 0, &n1342177280, &v14, 7); /*0xffd86bc9*/
  sub_FFD8A1DE(n1342177280, v2, n15_1); /*0xffd86bd9*/
  i_4 = sub_FFD8C035(); /*0xffd86be6*/
  i_1 = 1; /*0xffd86be8*/
  i_3 = i_4; /*0xffd86bea*/
  for ( i = 1; i_1 <= i_3; i = i_1 ) /*0xffd86bf4*/
  {
    i_2 = i_1; /*0xffd86c07*/
    v6 = (unsigned __int64)(i_1 | 0x40u) << 8; /*0xffd86c25*/
    sub_FFD8ADCC(202, 6, v6, SHIDWORD(v6), 0, 0, &n1342177280, &v14, 6); /*0xffd86c2c*/
    v7 = 2 * i; /*0xffd86c3d*/
    n1342177280 = n1342177280 & 0xFFFF80FF /*0xffd86c87*/
                | ((*(_BYTE *)(v19 + 16 * i - 3) & 7
                  | (8 * (*(_BYTE *)(v19 + 16 * i - 4) & 7 | (8 * (*(_BYTE *)(v19 + 16 * i - 1) & 1))))) << 8)
                | 0xFC000010;
    sub_FFD8ADCC(202, 7, v6, SHIDWORD(v6), 1u, 0, &n1342177280, &v14, 7); /*0xffd86c93*/
    sub_FFD8A1DE(n1342177280, v18, n15); /*0xffd86ca9*/
    v8 = (unsigned __int64)i_2 >> 24; /*0xffd86cb9*/
    LODWORD(v6) = i_2 << 8; /*0xffd86cbd*/
    HIDWORD(v6) = (i_2 << 8) | 0x4026; /*0xffd86cca*/
    n1342177280 = 0; /*0xffd86cd8*/
    sub_FFD8ADCC(202, 6, SHIDWORD(v6), v8, 0, 0, &n1342177280, &v14, 6); /*0xffd86ce2*/
    n1342177280 ^= (n1342177280 ^ (*(unsigned __int8 *)(v19 + 8 * v7 - 2) << 23)) & 0x1800000; /*0xffd86d0b*/
    sub_FFD8ADCC(202, 7, SHIDWORD(v6), v8, 1u, 0, &n1342177280, &v14, 7); /*0xffd86d22*/
    n15_1 = n15; /*0xffd86d27*/
    sub_FFD8A1DE(n1342177280, v18, n15); /*0xffd86d39*/
    LODWORD(v6) = v6 | 0x4008; /*0xffd86d47*/
    sub_FFD8ADCC(202, 6, v6, v8, 0, 0, &n1342177280, &v14, 6); /*0xffd86d61*/
    n1342177280 = n1342177280 & 0xFFFFC17F | 0x1A80; /*0xffd86d7c*/
    sub_FFD8ADCC(202, 7, v6, v8, 1u, 0, &n1342177280, &v14, 7); /*0xffd86d94*/
    v2 = v18; /*0xffd86d99*/
    sub_FFD8A1DE(n1342177280, v18, n15_1); /*0xffd86da8*/
    i_1 = i + 1; /*0xffd86db4*/
  }
  if ( sub_FFD8BE68() == 2 ) /*0xffd86dcc*/
  {
    i_3 = sub_FFD89FDC(&i_2); /*0xffd86ddd*/
    v9 = (_DWORD *)sub_FFD8A048(); /*0xffd86de1*/
    v10 = v9; /*0xffd86de6*/
    if ( v9 ) /*0xffd86dea*/
    {
      v11 = i_2 + *v9; /*0xffd86df2*/
      n15 = 15; /*0xffd86df8*/
      sub_FFD8D51B(v11, &n15, 4); /*0xffd86e00*/
      *v10 += 4; /*0xffd86e05*/
      if ( i_3 == 1 ) /*0xffd86e0e*/
        sub_FFD8A02F(n15_1); /*0xffd86e12*/
    }
  }
  sub_FFD8A2C4(v2, n15_1); /*0xffd86e1b*/
  result = *(_DWORD *)(v22 + 24) | 0x20000000; /*0xffd86e2a*/
  *(_DWORD *)(v22 + 24) = result; /*0xffd86e2f*/
  return result; /*0xffd86e24*/
}

// === Function at 0xffd879ed ===
int __thiscall sub_FFD879ED(_DWORD *this)
{
  unsigned __int8 i; // bl
  int v3; // ecx
  int v5; // [esp-4h] [ebp-20h]
  unsigned __int8 v6; // [esp+11h] [ebp-Bh]
  char v7; // [esp+12h] [ebp-Ah] BYREF
  char v8; // [esp+13h] [ebp-9h] BYREF
  _BYTE v9[2]; // [esp+14h] [ebp-8h] BYREF

  sub_FFD7F9AF(64, (int)"XhciUsb3Tune() Start\n"); /*0xffd879fd*/
  for ( i = 0; i < (unsigned __int8)sub_FFD8C051(); ++i ) /*0xffd87a06*/
  {
    if ( (*(_BYTE *)(this + 4 * i + 67) & 0x81) != 0 ) /*0xffd87a22*/
    {
      sub_FFD8E3BE(); /*0xffd87a2c*/
      sub_FFD8E062(v6, &v8, &v7); /*0xffd87a41*/
      v3 = v5; /*0xffd87a4b*/
      if ( v7 == 1 ) /*0xffd87a4c*/
      {
        LOBYTE(v3) = v6; /*0xffd87a56*/
        sub_FFD8EBC8(v3, v9); /*0xffd87a58*/
        if ( (*(this + 4 * i + 67) & 1) != 0 ) /*0xffd87a6e*/
          sub_FFD8C578(-4128769, (*(this + 4 * i + 67) & 0x7E) << 15); /*0xffd87a85*/
        if ( (*(this + 4 * i + 67) & 0x80u) != 0 ) /*0xffd87a95*/
          sub_FFD8C578(-4128769, (*(this + 4 * i + 67) & 0x3F00) << 8); /*0xffd87aae*/
        sub_FFD8C578(-3, 0); /*0xffd87ac9*/
        sub_FFD8C578(-1, 2); /*0xffd87ad6*/
      }
    }
  }
  return sub_FFD7F9AF(64, (int)"XhciUsb3Tune() End\n"); /*0xffd87afb*/
}

// === Function at 0xffd87b03 ===
int __thiscall sub_FFD87B03(int this)
{
  int v2; // edi
  int v3; // ebx
  int v5; // ebp
  unsigned int n0x3E8; // esi
  unsigned int i; // ebp
  int n2; // esi
  int n35; // edi
  unsigned int v10; // [esp+10h] [ebp-4h] BYREF

  v2 = *(_DWORD *)(this + 3510); /*0xffd87b11*/
  v3 = sub_FFD8CBBA(0, 20, 1); /*0xffd87b1d*/
  if ( (unsigned __int16)sub_FFD8CCA5((unsigned __int16 *)v3) == 0xFFFF )
  {
    sub_FFD7F9AF(64, (int)"xDCI: Pci device NOT found\n");
    return -2147483634; /*0xffd87b3e*/
  }
  else
  {
    v5 = sub_FFD8CBBA(0, 20, 0); /*0xffd87b63*/
    sub_FFD8C578(-1, 63); /*0xffd87b65*/
    sub_FFD8C5B5(); /*0xffd87b6a*/
    if ( (*(_BYTE *)(this + 2683) & 1) != 0 )
    {
      *(_DWORD *)(v5 + 16) = v2; /*0xffd87cfb*/
      sub_FFD8CC4F(v5 + 4, 2); /*0xffd87cfe*/
      *(_DWORD *)(v2 + 32984) &= 0xFFCFFFFF; /*0xffd87d11*/
      sub_FFD8CC6A(v5 + 4, 65533); /*0xffd87d1e*/
      *(_DWORD *)(v5 + 16) = 0; /*0xffd87d2b*/
      sub_FFD8CC85(4); /*0xffd87d34*/
    }
    else
    {
      sub_FFD7F9AF(64, (int)"xDCI: Device disabled\n");
      *(_DWORD *)(v5 + 16) = v2; /*0xffd87b91*/
      sub_FFD8CC4F(v5 + 4, 2); /*0xffd87b95*/
      *(_DWORD *)(v2 + 32984) |= 0x200000u; /*0xffd87ba5*/
      n0x3E8 = 0; /*0xffd87bb6*/
      *(_DWORD *)(v2 + 32984) &= ~0x100000u; /*0xffd87bb8*/
      while ( (*(_DWORD *)(v2 + 32988) & 0x20000000) == 0 && n0x3E8 < 0x3E8 ) /*0xffd87bc6*/
      {
        sub_FFD7FA46(0x64u); /*0xffd87bcb*/
        ++n0x3E8; /*0xffd87bd0*/
      }
      *(_DWORD *)(v2 + 32984) = *(_DWORD *)(v2 + 32984) & 0xFFFFFFFC | 1; /*0xffd87bf4*/
      sub_FFD8CC6A(v5 + 4, 65533); /*0xffd87bfa*/
      *(_DWORD *)(v5 + 16) = 0; /*0xffd87c01*/
      *(_DWORD *)(v3 + 16) = v2; /*0xffd87c0c*/
      sub_FFD8CC4F(v3 + 4, 2); /*0xffd87c0f*/
      *(_DWORD *)(v2 + 49424) |= 2u; /*0xffd87c23*/
      *(_DWORD *)(v2 + 49664) |= 0x40u; /*0xffd87c32*/
      *(_DWORD *)(v2 + 49856) |= 0x8000000u; /*0xffd87c46*/
      sub_FFD8CC4F(v2 + 1112088, 3); /*0xffd87c4c*/
      for ( i = 0; (sub_FFD8CCA5((unsigned __int16 *)(v2 + 1112080)) & 0xF00) == 0 && i < 0x3E8; ++i ) /*0xffd87c51*/
        sub_FFD7FA46(0x64u); /*0xffd87c60*/
      sub_FFD8CC6A(v3 + 4, 65533); /*0xffd87c80*/
      *(_DWORD *)(v3 + 16) = 0; /*0xffd87c85*/
      *(_DWORD *)(v3 + 132) |= 3u; /*0xffd87c95*/
      n2 = sub_FFD8BE68(); /*0xffd87ca0*/
      n35 = sub_FFD8BB3A(); /*0xffd87ca7*/
      sub_FFD8C578(-1, 256); /*0xffd87cc4*/
      sub_FFD8C909(&v10); /*0xffd87ccf*/
      if ( n2 == 2 && n35 >= 35 ) /*0xffd87cdc*/
        *(_DWORD *)(v10 + 1576) |= 0x1000000u; /*0xffd87ced*/
    }
    return 0; /*0xffd87d3a*/
  }
}

// === Function at 0xffd87d42 ===
int sub_FFD87D42()
{
  int v0; // eax
  int v1; // eax
  _DWORD *v2; // edi
  int v4; // eax
  int v5; // esi
  int v6; // eax

  sub_FFD7F9AF(64, (int)"InstallPchSpi() Start\n"); /*0xffd87d4c*/
  v0 = sub_FFD8CBBA(0, 31, 5); /*0xffd87d58*/
  *(_DWORD *)(v0 + 16) = -33488896; /*0xffd87d60*/
  *(_DWORD *)(v0 + 4) |= 2u; /*0xffd87d6d*/
  v1 = sub_FFD8ADB0(104); /*0xffd87d73*/
  v2 = (_DWORD *)v1; /*0xffd87d78*/
  if ( !v1 ) /*0xffd87d7c*/
    return -2147483639; /*0xffd87d7e*/
  sub_FFD8F09A((_DWORD *)(v1 + 12)); /*0xffd87d88*/
  *v2 = -2147483632; /*0xffd87d90*/
  v2[1] = &unk_FFD97EBC; /*0xffd87d98*/
  v2[2] = v2 + 5; /*0xffd87d9f*/
  v4 = sub_FFD7F948(v2); /*0xffd87da2*/
  v5 = v4; /*0xffd87da7*/
  if ( v4 < 0 ) /*0xffd87dab*/
  {
    sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0xffd87db8*/
    v6 = sub_FFD7F97E(); /*0xffd87dc0*/
    if ( v6 ) /*0xffd87dc7*/
      (*(void (__cdecl **)(const char *, int, const char *))(v6 + 4))( /*0xffd87dd8*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchSpi.c",
        130,
        "!EFI_ERROR (Status)");
  }
  sub_FFD7F9AF(64, (int)"SPI PPI Installed\n"); /*0xffd87de5*/
  sub_FFD7F9AF(64, (int)"InstallPchSpi() End\n"); /*0xffd87df1*/
  return v5; /*0xffd87dfb*/
}

// === Function at 0xffd87dff ===
int __thiscall sub_FFD87DFF(_BYTE *this)
{
  int result; // eax
  int v3; // esi
  int n128; // ecx
  _DWORD v5[4]; // [esp+8h] [ebp-10h] BYREF

  result = sub_FFD7F9AF(64, (int)"ConfigureLpcOnPolicy()\n"); /*0xffd87e0f*/
  if ( (*(this + 3514) & 1) == 0 ) /*0xffd87e1d*/
  {
    sub_FFD7F9AF(64, (int)"Disable EnhancePort8xhDecoding\n"); /*0xffd87e26*/
    sub_FFD8D48A(v5, 16); /*0xffd87e33*/
    result = sub_FFD8CA98(v5); /*0xffd87e3b*/
    v3 = 0; /*0xffd87e40*/
    while ( 1 ) /*0xffd87e42*/
    {
      n128 = v5[v3]; /*0xffd87e42*/
      if ( (_WORD)n128 == 128 && (n128 & 0x7FFF0000) == 0x100000 ) /*0xffd87e59*/
        break; /*0xffd87e59*/
      if ( (unsigned int)++v3 >= 4 ) /*0xffd87e5f*/
        return result; /*0xffd87e5f*/
    }
    *(_DWORD *)(sub_FFD8CBBA(0, 31, 0) + 4 * v3 + 132) = 0; /*0xffd87e83*/
    return sub_FFD8C497(4, 0); /*0xffd87e8d*/
  }
  return result; /*0xffd87e94*/
}

// === Function at 0xffd87e99 ===
bool sub_FFD87E99()
{
  int v0; // esi
  int n5120; // eax
  bool result; // al
  unsigned __int16 v3; // [esp+4h] [ebp-4h] BYREF

  sub_FFD8C76F(&v3); /*0xffd87ea1*/
  v0 = v3; /*0xffd87ea6*/
  result = 0; /*0xffd87ee2*/
  if ( (sub_FFD8CD06(v3) & 0x8000u) != 0 ) /*0xffd87eb9*/
  {
    n5120 = sub_FFD8CD06(v0 + 4) & 0x1C00; /*0xffd87ed0*/
    if ( (_WORD)n5120 == 5120 || (_WORD)n5120 == 6144 ) /*0xffd87ee0*/
      return 1; /*0xffd87eb9*/
  }
  return result; /*0xffd87ee8*/
}

// === Function at 0xffd87eed ===
int sub_FFD87EED()
{
  int v0; // eax
  int v1; // ebx
  __int16 v2; // bp
  int v3; // eax
  int result; // eax
  char v5; // cl
  _DWORD *v6; // edi
  unsigned int v7; // ebx
  unsigned int v8; // ebx
  int v9; // eax
  int v10; // eax
  int v11; // esi
  int v12; // eax
  int v13; // [esp+14h] [ebp-8h] BYREF
  int v14; // [esp+18h] [ebp-4h]

  v0 = sub_FFD8EEB6(); /*0xffd87ef4*/
  v1 = sub_FFD8CD6B(v0); /*0xffd87f00*/
  sub_FFD7F9AF(64, (int)"(WDT) Readback = 0x%08x\n", v1); /*0xffd87f0a*/
  if ( (v1 & 0x4000) != 0 ) /*0xffd87f18*/
  {
    LOBYTE(v14) = 1; /*0xffd87f1c*/
    v2 = (v1 & 0x3FF) + 1; /*0xffd87f27*/
  }
  else
  {
    v14 = 0; /*0xffd87f2e*/
    v2 = 0; /*0xffd87f32*/
  }
  v3 = sub_FFD8AD54(); /*0xffd87f34*/
  result = (*(int (__cdecl **)(int, int, int, int *))(*(_DWORD *)v3 + 52))(v3, 4, 28, &v13); /*0xffd87f45*/
  if ( result >= 0 ) /*0xffd87f4d*/
  {
    v5 = v14; /*0xffd87f5c*/
    v6 = (_DWORD *)(v13 + 8); /*0xffd87f60*/
    *(_DWORD *)(v13 + 8) = unk_FFD97F0C; /*0xffd87f63*/
    *++v6 = unk_FFD97F10; /*0xffd87f64*/
    *++v6 = unk_FFD97F14; /*0xffd87f65*/
    v6[1] = unk_FFD97F18; /*0xffd87f66*/
    *(_BYTE *)(v13 + 26) = v5; /*0xffd87f75*/
    *(_WORD *)(v13 + 24) = v2; /*0xffd87f7c*/
    if ( (v1 & 0x3000000) != 0 ) /*0xffd87f82*/
    {
      sub_FFD7F9AF(0x80000000, (int)"(WDT) Expiration detected.\n", v1); /*0xffd87f8b*/
      v7 = v1 & 0xFC3FFFFF | 0x3800000; /*0xffd87f99*/
    }
    else
    {
      if ( (v1 & 0x400000) == 0 || sub_FFD87E99() ) /*0xffd87fa9*/
      {
        sub_FFD7F9AF(64, (int)"(WDT) Status OK.\n", v1); /*0xffd87fcf*/
        v8 = v1 & 0xFF7FFFFF; /*0xffd87fd7*/
      }
      else
      {
        sub_FFD7F9AF(0x80000000, (int)"(WDT) Unexpected reset detected and ignored.\n"); /*0xffd87fb8*/
        v8 = v1 & 0xFF3FFFFF; /*0xffd87fbf*/
      }
      v7 = v8 | 0x3000000; /*0xffd87fdd*/
    }
    v9 = sub_FFD8EEB6(); /*0xffd87fdf*/
    sub_FFD8CD97(v9, v7); /*0xffd87fe8*/
    sub_FFD7F948(&unk_FFD9816C); /*0xffd87ff2*/
    v10 = sub_FFD7F948(&unk_FFD98144); /*0xffd87ffc*/
    v11 = v10; /*0xffd88001*/
    if ( v10 < 0 ) /*0xffd88005*/
    {
      sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v10); /*0xffd8800e*/
      v12 = sub_FFD7F97E(); /*0xffd88016*/
      if ( v12 ) /*0xffd8801d*/
        (*(void (__cdecl **)(const char *, int, const char *))(v12 + 4))( /*0xffd8802e*/
          "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\Wdt.c",
          216,
          "!EFI_ERROR (Status)");
    }
    return v11; /*0xffd88034*/
  }
  return result; /*0xffd88036*/
}

// === Function at 0xffd880d2 ===
int sub_FFD880D2()
{
  int v0; // eax
  _DWORD *v1; // edi
  int v2; // eax
  int v3; // eax
  _DWORD *v4; // esi
  _DWORD *v5; // eax
  int v6; // eax
  int v7; // esi
  int v8; // eax
  int v10; // eax

  sub_FFD7F9AF(64, (int)"InstallPchReset() Start\n"); /*0xffd880de*/
  v0 = sub_FFD8ADB0(40); /*0xffd880e8*/
  v1 = (_DWORD *)v0; /*0xffd880ed*/
  if ( !v0 ) /*0xffd880f1*/
    return -2147483639; /*0xffd881e7*/
  sub_FFD90233(v0 + 12); /*0xffd880fc*/
  v1[5] = sub_FFD88046; /*0xffd88106*/
  *v1 = -2147483632; /*0xffd8810c*/
  v1[1] = &unk_FFD97FAC; /*0xffd88112*/
  v1[2] = v1 + 5; /*0xffd88119*/
  v2 = sub_FFD7F948(v1); /*0xffd8811c*/
  if ( v2 < 0 ) /*0xffd88132*/
  {
    sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v2); /*0xffd8813b*/
    v3 = sub_FFD7F97E(); /*0xffd88143*/
    if ( v3 ) /*0xffd8814a*/
      (*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffd88153*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchReset.c",
        132,
        "!EFI_ERROR (Status)");
  }
  v4 = (_DWORD *)sub_FFD8ADB0(12); /*0xffd88164*/
  v5 = (_DWORD *)sub_FFD8ADB0(4); /*0xffd88166*/
  if ( !v4 || !v5 ) /*0xffd88171*/
  {
    v10 = sub_FFD7F97E(); /*0xffd881cd*/
    if ( v10 ) /*0xffd881d4*/
      (*(void (__cdecl **)(const char *, int, const char *))(v10 + 4))( /*0xffd881e1*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchReset.c",
        139,
        "((BOOLEAN)(0==1))");
    return -2147483639; /*0xffd881e1*/
  }
  *v5 = sub_FFD88081; /*0xffd88173*/
  *v4 = -2147483632; /*0xffd8817b*/
  v4[1] = &unk_FFD97F2C; /*0xffd88181*/
  v4[2] = v5; /*0xffd88188*/
  v6 = sub_FFD7F948(v4); /*0xffd8818b*/
  v7 = v6; /*0xffd88190*/
  if ( v6 < 0 ) /*0xffd88194*/
  {
    sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v6); /*0xffd8819d*/
    v8 = sub_FFD7F97E(); /*0xffd881a5*/
    if ( v8 ) /*0xffd881ac*/
      (*(void (__cdecl **)(const char *, int, const char *))(v8 + 4))( /*0xffd881b5*/
        "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\LibraryPrivate\\PeiPchInitLib\\PchReset.c",
        153,
        "!EFI_ERROR (Status)");
  }
  sub_FFD7F9AF(64, (int)"InstallPchReset() End\n"); /*0xffd881c2*/
  return v7; /*0xffd881ec*/
}

// === Function at 0xffd8ad54 ===
int sub_FFD8AD54()
{
  int v0; // esi
  int __return_address; // [esp+0h] [ebp-Ch]
  int v3; // [esp+6h] [ebp-6h]

  sub_FFD8D30B(__return_address); /*0xffd8ad5d*/
  v0 = *(_DWORD *)(v3 - 4); /*0xffd8ad65*/
  if ( !v0 ) /*0xffd8ad6a*/
    sub_FFD7F9D9( /*0xffd8ad79*/
      (int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
      48,
      "PeiServices != ((void *) 0)");
  return v0; /*0xffd8ad81*/
}

// === Function at 0xffd8b940 ===
int __thiscall sub_FFD8B940(void *this)
{
  int n256; // esi
  int n13; // edi
  int v3; // eax
  void *v4; // ecx
  int v5; // eax
  int result; // eax

  n256 = 256; /*0xffd8b947*/
  n13 = 13; /*0xffd8b94e*/
  do /*0xffd8b9e0*/
  {
    v3 = sub_FFD8B14D(n256, this, -1, 0, 0); /*0xffd8b95f*/
    if ( v3 < 0 ) /*0xffd8b969*/
    {
      sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", v3); /*0xffd8b976*/
      v5 = sub_FFD7F97E(); /*0xffd8b97e*/
      if ( v5 ) /*0xffd8b985*/
        (*(void (__cdecl **)(const char *, int, const char *))(v5 + 4))( /*0xffd8b992*/
          "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
          1584,
          "!EFI_ERROR (Status)");
    }
    result = sub_FFD8B14D(n256, v4, -1, 0, 0); /*0xffd8b9a3*/
    if ( result < 0 ) /*0xffd8b9ad*/
    {
      sub_FFD7F9AF(0x80000000, (int)"\nASSERT_EFI_ERROR (Status = %r)\n", result); /*0xffd8b9ba*/
      result = sub_FFD7F97E(); /*0xffd8b9c2*/
      if ( result ) /*0xffd8b9c9*/
        result = (*(int (__cdecl **)(const char *, int, const char *))(result + 4))( /*0xffd8b9d6*/
                   "e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
                   1712,
                   "!EFI_ERROR (Status)");
    }
    ++n256; /*0xffd8b9dc*/
    --n13; /*0xffd8b9dd*/
  }
  while ( n13 ); /*0xffd8b9e0*/
  return result; /*0xffd8b9e6*/
}

// === Function at 0xffd7f6ec ===
void *__cdecl sub_FFD7F6EC(void *buf, unsigned int count, char value)
{
  memset(buf, value, count); /*0xffd7f6f9*/
  return buf; /*0xffd7f6ff*/
}

// === Function at 0xffd70c ===


// === 0xffd70c ===
{"addr":"0xffd70c","code":null,"error":"Decompilation failed"}

// === Function at 0xffd7f72c ===
char *__cdecl sub_FFD7F72C(char *dst, char *src, unsigned int count_1)
{
  unsigned int count; // edx
  char *dst_1; // edi
  char *src_1; // esi

  count = count_1; /*0xffd7f736*/
  if ( src < dst && &src[count_1 - 1] >= dst ) /*0xffd7f744*/
  {
    src_1 = &src[count_1 - 1]; /*0xffd7f758*/
    dst_1 = &dst[count_1 - 1]; /*0xffd7f75a*/
  }
  else
  {
    count = count_1 & 3; /*0xffd7f748*/
    qmemcpy(dst, src, 4 * (count_1 >> 2)); /*0xffd7f751*/
    src_1 = &src[4 * (count_1 >> 2)]; /*0xffd7f751*/
    dst_1 = &dst[4 * (count_1 >> 2)]; /*0xffd7f751*/
  }
  qmemcpy(dst_1, src_1, count); /*0xffd7f761*/
  return dst; /*0xffd7f768*/
}

// === Function at 0xffd7f76c ===
int __cdecl sub_FFD7F76C(int a1, int a2, int a3, int a4)
{
  do /*0xffd7f785*/
  {
    *(_DWORD *)(a1 + 8 * a2 - 8) = a3; /*0xffd7f77d*/
    *(_DWORD *)(a1 + 8 * a2-- - 4) = a4; /*0xffd7f781*/
  }
  while ( a2 ); /*0xffd7f785*/
  return a1; /*0xffd7f789*/
}

// === Function at 0xffd7f78c ===
void *__cdecl sub_FFD7F78C(void *buf, unsigned int count, int value)
{
  memset32(buf, value, count); /*0xffd7f799*/
  return buf; /*0xffd7f79f*/
}

// === Function at 0xffd7f948 ===
int __thiscall sub_FFD7F948(void *this)
{
  int v2; // eax

  v2 = sub_FFD8AD54(); /*0xffd7f94b*/
  return (*(int (__cdecl **)(int, void *))(*(_DWORD *)v2 + 24))(v2, this); /*0xffd7f959*/
}

// === Function at 0xffd7f95b ===
int __fastcall sub_FFD7F95B(int a1, int a2, int a3, int a4)
{
  int v6; // eax

  v6 = sub_FFD8AD54(); /*0xffd7f962*/
  return (*(int (__cdecl **)(int, int, int, int, int))(*(_DWORD *)v6 + 32))(v6, a1, a2, a3, a4); /*0xffd7f97a*/
}

// === Function at 0xffd7f9f7 ===
int __fastcall sub_FFD7F9F7(unsigned int a1)
{
  unsigned int v1; // esi
  int n0x400000; // edi
  int v3; // ebx
  int result; // eax

  v1 = a1 >> 22; /*0xffd7fa04*/
  n0x400000 = a1 & 0x3FFFFF; /*0xffd7fa07*/
  do /*0xffd7fa3f*/
  {
    v3 = n0x400000 + (sub_FFD8CD6B(1288) & 0xFFFFFF); /*0xffd7fa1c*/
    n0x400000 = 0x400000; /*0xffd7fa1e*/
    while ( ((v3 - sub_FFD8CD6B(1288)) & 0x800000) == 0 ) /*0xffd7fa38*/
      _mm_pause(); /*0xffd7fa25*/
    result = v1--; /*0xffd7fa3a*/
  }
  while ( result ); /*0xffd7fa3f*/
  return result; /*0xffd7fa41*/
}

// === Function at 0xffd83452 ===


// === 0xffd83452 ===
{"addr":"0xffd83452","code":null,"error":"Decompilation failed"}

// === Function at 0xffd840b0 ===


// === 0xffd840b0 ===
{"addr":"0xffd840b0","code":null,"error":"Decompilation failed"}

// === Function at 0xffd84b0b ===


// === 0xffd84b0b ===
{"addr":"0xffd84b0b","code":null,"error":"Decompilation failed"}

// === Function at 0xffd84f8b ===


// === 0xffd84f8b ===
{"addr":"0xffd84f8b","code":null,"error":"Decompilation failed"}

// === Function at 0xffd858c3 ===


// === 0xffd858c3 ===
{"addr":"0xffd858c3","code":null,"error":"Decompilation failed"}

// === Function at 0xffd85bc2 ===


// === 0xffd85bc2 ===
{"addr":"0xffd85bc2","code":null,"error":"Decompilation failed"}

// === Function at 0xffd86203 ===


// === 0xffd86203 ===
{"addr":"0xffd86203","code":null,"error":"Decompilation failed"}

// === Function at 0xffd86e4d ===
int __usercall sub_FFD86E37@<eax>(int a1@<edx>, int a2@<ecx>, int a3, int a4, int a5, int a6, int a7, ...)
{
  int v7; // ebx
  unsigned int n8_3; // esi
  unsigned int v9; // edi
  unsigned __int8 *v10; // ebx
  unsigned __int8 n8; // al
  int n8_4; // ebp
  int v13; // eax
  unsigned int n8_1; // ecx
  _DWORD *v15; // edx
  int v16; // eax
  unsigned int v17; // edi
  unsigned __int8 *v18; // ebp
  unsigned __int8 n8_2; // al
  int n8_5; // ebx
  int v21; // eax
  _DWORD *v22; // ecx
  int result; // eax
  unsigned int retaddr; // [esp+5Ch] [ebp+0h]
  int v27; // [esp+74h] [ebp+18h] BYREF
  va_list va; // [esp+74h] [ebp+18h]
  int v29; // [esp+78h] [ebp+1Ch]
  int v30; // [esp+7Ch] [ebp+20h]
  int v31; // [esp+80h] [ebp+24h]
  int v32; // [esp+84h] [ebp+28h]
  int v33; // [esp+88h] [ebp+2Ch]
  int v34; // [esp+8Ch] [ebp+30h]
  int v35; // [esp+90h] [ebp+34h]
  va_list va1; // [esp+94h] [ebp+38h] BYREF

  va_start(va1, a7);
  va_start(va, a7);
  v27 = va_arg(va1, _DWORD); /*0xffd86e37*/
  v29 = va_arg(va1, _DWORD); /*0xffd86e37*/
  v30 = va_arg(va1, _DWORD); /*0xffd86e37*/
  v31 = va_arg(va1, _DWORD); /*0xffd86e37*/
  v32 = va_arg(va1, _DWORD); /*0xffd86e37*/
  v33 = va_arg(va1, _DWORD); /*0xffd86e37*/
  v34 = va_arg(va1, _DWORD); /*0xffd86e37*/
  v35 = va_arg(va1, _DWORD); /*0xffd86e37*/
  v7 = a2; /*0xffd86e3e*/
  sub_FFD8D4C8(va1, retaddr); /*0xffd86e4f*/
  sub_FFD8D4C8((int *)va, retaddr); /*0xffd86e5b*/
  sub_FFD8BF54(); /*0xffd86e60*/
  n8_3 = 0; /*0xffd86e65*/
  v9 = 0; /*0xffd86e67*/
  if ( (unsigned __int8)sub_FFD8C051() ) /*0xffd86e69*/
  {
    v10 = (unsigned __int8 *)(v7 + 264); /*0xffd86e72*/
    do /*0xffd86ebd*/
    {
      n8 = *v10; /*0xffd86e78*/
      if ( *v10 != 8 ) /*0xffd86e7c*/
      {
        n8_4 = n8; /*0xffd86e7e*/
        if ( n8 >= 8u ) /*0xffd86e84*/
        {
          v13 = sub_FFD7F97E(); /*0xffd86e86*/
          if ( v13 ) /*0xffd86e8d*/
            (*(void (**)(void))(v13 + 4))(); /*0xffd86e9e*/
        }
        *((int *)va + n8_4) |= 1 << v9; /*0xffd86eab*/
      }
      ++v9; /*0xffd86eaf*/
      v10 += 16; /*0xffd86eb0*/
    }
    while ( v9 < (unsigned __int8)sub_FFD8C051() ); /*0xffd86ebd*/
    v7 = a2; /*0xffd86ebf*/
  }
  n8_1 = 0; /*0xffd86ec7*/
  v15 = (_DWORD *)(a1 + 208); /*0xffd86ec9*/
  do /*0xffd86edc*/
  {
    v16 = *((int *)va + n8_1++); /*0xffd86ecf*/
    *v15++ = v16; /*0xffd86ed4*/
  }
  while ( n8_1 < 8 ); /*0xffd86edc*/
  v17 = 0; /*0xffd86ede*/
  v18 = (unsigned __int8 *)(v7 + 8); /*0xffd86ee0*/
  while ( (unsigned int)(sub_FFD8BE68() - 1) <= 1 && v17 < retaddr ) /*0xffd86efb*/
  {
    n8_2 = *v18; /*0xffd86efd*/
    if ( *v18 != 8 ) /*0xffd86f02*/
    {
      n8_5 = n8_2; /*0xffd86f04*/
      if ( n8_2 >= 8u ) /*0xffd86f0a*/
      {
        v21 = sub_FFD7F97E(); /*0xffd86f0c*/
        if ( v21 ) /*0xffd86f13*/
          (*(void (**)(void))(v21 + 4))(); /*0xffd86f24*/
      }
      va1[n8_5] = (void *)((unsigned int)va1[n8_5] | (1 << v17)); /*0xffd86f31*/
    }
    ++v17; /*0xffd86f35*/
    v18 += 16; /*0xffd86f36*/
  }
  v22 = (_DWORD *)(a1 + 176); /*0xffd86f3f*/
  do /*0xffd86f52*/
  {
    result = (int)va1[n8_3++]; /*0xffd86f45*/
    *v22++ = result; /*0xffd86f4a*/
  }
  while ( n8_3 < 8 ); /*0xffd86f52*/
  return result; /*0xffd86f54*/
}

// === Function at 0xffd8733e ===


// === 0xffd8733e ===
{"addr":"0xffd8733e","code":null,"error":"Decompilation failed"}

// === Function at 0xffd87dff ===
int __thiscall sub_FFD87DFF(_BYTE *this)
{
  int result; // eax
  int v3; // esi
  int n128; // ecx
  _DWORD v5[4]; // [esp+8h] [ebp-10h] BYREF

  result = sub_FFD7F9AF(64, (int)"ConfigureLpcOnPolicy()\n"); /*0xffd87e0f*/
  if ( (*(this + 3514) & 1) == 0 ) /*0xffd87e1d*/
  {
    sub_FFD7F9AF(64, (int)"Disable EnhancePort8xhDecoding\n"); /*0xffd87e26*/
    sub_FFD8D48A(v5, 16); /*0xffd87e33*/
    result = sub_FFD8CA98(v5); /*0xffd87e3b*/
    v3 = 0; /*0xffd87e40*/
    while ( 1 ) /*0xffd87e42*/
    {
      n128 = v5[v3]; /*0xffd87e42*/
      if ( (_WORD)n128 == 128 && (n128 & 0x7FFF0000) == 0x100000 ) /*0xffd87e59*/
        break; /*0xffd87e59*/
      if ( (unsigned int)++v3 >= 4 ) /*0xffd87e5f*/
        return result; /*0xffd87e5f*/
    }
    *(_DWORD *)(sub_FFD8CBBA(0, 31, 0) + 4 * v3 + 132) = 0; /*0xffd87e83*/
    return sub_FFD8C497(4, 0); /*0xffd87e8d*/
  }
  return result; /*0xffd87e94*/
}