// DxePlatformDriverEntry - decompiled from Platform.efi
__int64 __fastcall DxePlatformDriverEntry(__int64 *Length__1)
{
  __int64 ImageHandle; // rbx
  char v2; // r14
  bool v3; // r12
  char v4; // r13
  unsigned __int16 n4; // r15
  signed __int64 v6; // rax
  __int64 result; // rax
  UINTN Length; // r8
  __int64 v9; // rdi
  __int64 v10; // rdx
  unsigned __int64 i; // rbx
  char *v12; // rsi
  char n93; // al
  unsigned __int8 v14; // al
  __int64 *Length__2; // rsi
  __int64 v16; // rdi
  CHAR16 *v17; // rbx
  UINTN AllocationSize; // rcx
  void *DevicePath; // rdi
  __int64 v20; // rax
  __int64 v21; // rax
  _QWORD v22[3]; // [rsp+30h] [rbp-18h] BYREF
  __int64 *Length_; // [rsp+90h] [rbp+48h] BYREF
  __int64 v24; // [rsp+98h] [rbp+50h] BYREF
  __int64 v25; // [rsp+A0h] [rbp+58h] BYREF
  __int64 v26; // [rsp+A8h] [rbp+60h] BYREF

  Length_ = Length__1; /*0x14b4*/
  ImageHandle = ImageHandle_0; /*0x14cc*/
  LOWORD(Length_) = 1; /*0x14e6*/
  v2 = 0; /*0x14ed*/
  v3 = 0; /*0x14f0*/
  ZeroMem(&SourceBuffer__0, 0x2A4u); /*0x14f3*/
  CopyMem(&SourceBuffer__0, &DestinationBuffer__3, 0x2A4u); /*0x1505*/
  v4 = 0; /*0x150a*/
  n4 = 4; /*0x150d*/
  if ( n4 == 4 ) /*0x151f*/
  {
    v4 = 1; /*0x152b*/
    (*(void (__fastcall **)(void *))(qword_14590 + 40))(&SourceBuffer__0); /*0x152e*/
    v6 = RegisterHiiPackage((__int64)&unk_FB40, (__int64)&SourceBuffer__0); /*0x153b*/
    if ( v6 < 0 ) /*0x1543*/
    {
      DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v6); /*0x1551*/
      Assert( /*0x1569*/
        (__int64)"e:\\hs\\PurleyRpPkg\\Platform\\Dxe\\Setup\\SetupPlatform.c",
        1018,
        (__int64)"!EFI_ERROR (Status)");
    }
  }
  result = (*(__int64 (__fastcall **)(__int64, void *, __int64 *, __int64, _QWORD, int))(BootServices + 280))( /*0x1594*/
             ImageHandle,
             &unk_FA20,
             &v24,
             ImageHandle,
             0,
             2);
  if ( result < 0 ) /*0x159d*/
    return result; /*0x159d*/
  result = (*(__int64 (__fastcall **)(void *, _QWORD, _QWORD *))(BootServices + 320))(&unk_FB10, 0, v22); /*0x15b7*/
  v9 = result; /*0x15bd*/
  if ( result < 0 ) /*0x15c3*/
    return result; /*0x15c3*/
  v10 = v24; /*0x15c9*/
  for ( i = v24 + 20; /*0x15d0*/
        i < v24 + (unsigned __int64)*(unsigned int *)(v24 + 16) && *(_BYTE *)(i + 3) != 2;
        i += *(_DWORD *)i & 0xFFFFFF )
  {
    ; /*0x15e6*/
  }
  v12 = (char *)(i + 4); /*0x15f0*/
  if ( (*(_DWORD *)i & 0xFFFFFFu) <= 4 ) /*0x15fc*/
  {
LABEL_22:
    Length__2 = Length_; /*0x167b*/
    goto LABEL_23; /*0x167b*/
  }
  while ( 1 ) /*0x15fe*/
  {
    n93 = *v12; /*0x15fe*/
    if ( *v12 != 14 ) /*0x1602*/
      break; /*0x1602*/
    if ( (unsigned __int8)CompareMem(v12 + 2, &SourceBuffer__1, Length) ) /*0x160f*/
    {
      v2 = 1; /*0x1618*/
      goto LABEL_19; /*0x161b*/
    }
    v2 = 0; /*0x161d*/
LABEL_20:
    v14 = v12[1] & 0x7F; /*0x1652*/
    v12 += v14; /*0x165d*/
    n4 += v14; /*0x166b*/
    if ( n4 >= (*(_DWORD *)i & 0xFFFFFFu) ) /*0x1675*/
    {
      v10 = v24; /*0x1677*/
      goto LABEL_22; /*0x1677*/
    }
  }
  if ( n93 == 1 || n93 == 93 ) /*0x1628*/
    v3 = StrCmpS(v12 + 2, (UINTN)&Length_, 2) == 0; /*0x1640*/
  if ( !v2 ) /*0x1647*/
    goto LABEL_20; /*0x1647*/
LABEL_19:
  if ( !v3 ) /*0x164c*/
    goto LABEL_20; /*0x164c*/
  DebugPrint(0x80000000, "INTELRCSETUP page FOUND in IFRPACK \n"); /*0x1779*/
  ++word_FCBC; /*0x178a*/
  DevicePath = CreateDevicePath(AllocationSize, 0x1Au, (__int64)&SourceBuffer__2); /*0x1799*/
  if ( !DevicePath ) /*0x179f*/
    Assert( /*0x17b4*/
      (__int64)"e:\\hs\\PurleyRpPkg\\Platform\\Dxe\\Setup\\SetupPlatform.c",
      1079,
      (__int64)"VendorDevicePath != ((void *) 0)");
  v25 = 0; /*0x17c7*/
  v20 = (*(__int64 (__fastcall **)(__int64 *, void *, void *, _QWORD))(BootServices + 328))( /*0x17d6*/
          &v25,
          &unk_FA90,
          DevicePath,
          0);
  v9 = v20; /*0x17dc*/
  if ( v20 < 0 ) /*0x17e2*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v20); /*0x17f1*/
    Assert((__int64)"e:\\hs\\PurleyRpPkg\\Platform\\Dxe\\Setup\\SetupPlatform.c", 1088, (__int64)"!EFI_ERROR (Status)"); /*0x1809*/
  }
  qword_FE70 = v25; /*0x1819*/
  v26 = v25; /*0x1827*/
  psub_1B18 = (__int64)HiiExtractConfig; /*0x1839*/
  Length__2 = &qword_FEA8; /*0x1840*/
  psub_1EEC = (__int64)HiiConfigRouting; /*0x184e*/
  psub_20C0 = (__int64)SetupFormCallback; /*0x185c*/
  v21 = (*(__int64 (__fastcall **)(__int64 *, void *, _QWORD, __int64 *))(BootServices + 128))( /*0x186a*/
          &v26,
          &unk_FBA0,
          0,
          &psub_1B18);
  if ( v21 < 0 ) /*0x1873*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v21); /*0x1882*/
    Assert((__int64)"e:\\hs\\PurleyRpPkg\\Platform\\Dxe\\Setup\\SetupPlatform.c", 2657, (__int64)"!EFI_ERROR (Status)"); /*0x189a*/
  }
  v10 = v24; /*0x189f*/
LABEL_23:
  if ( n4 >= (*(_DWORD *)i & 0xFFFFFFu) ) /*0x1696*/
  {
    DebugPrint(0x80000000, "INTELRCSETUP page not found in IFRPACK \n"); /*0x16a2*/
    if ( v9 < 0 ) /*0x16aa*/
    {
      DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v9); /*0x16b9*/
      Assert( /*0x16d1*/
        (__int64)"e:\\hs\\PurleyRpPkg\\Platform\\Dxe\\Setup\\SetupPlatform.c",
        1105,
        (__int64)"!EFI_ERROR (Status)");
    }
    v10 = v24; /*0x16d6*/
  }
  v16 = (*(__int64 (__fastcall **)(_QWORD, __int64, __int64, __int64 *))v22[0])(v22[0], v10, v25, Length__2); /*0x16fc*/
  v17 = ConstructConfigHdr( /*0x1704*/
          (__int64)&SourceBuffer__1,
          aIntelsetup, // "IntelSetup"
          v25);
  if ( !v17 ) /*0x170a*/
    Assert( /*0x171f*/
      (__int64)"e:\\hs\\PurleyRpPkg\\Platform\\Dxe\\Setup\\SetupPlatform.c",
      1112,
      (__int64)"ConfigRequestHdr != ((void *) 0)");
  if ( v4 ) /*0x1727*/
  {
    if ( !CheckActionFlag((__int64)v17) ) /*0x172c*/
      Assert((__int64)"e:\\hs\\PurleyRpPkg\\Platform\\Dxe\\Setup\\SetupPlatform.c", 1115, (__int64)"ActionFlag"); /*0x1748*/
  }
  ExtractConfig(); /*0x1750*/
  return v16; /*0x1758*/
}
