// HiiExtractConfig - decompiled from Platform.efi
__int64 __fastcall HiiExtractConfig(__int64 *p_psub_1B18, CHAR16 *ZeroPool_2, CHAR16 **a3, __int64 a4)
{
  char v9; // r12
  CHAR16 *ZeroPool_1; // rsi
  __int64 v11; // r8
  const CHAR16 *v12; // rax
  const char *ConfigRequestHdr____((void__)_0); // r8
  __int64 n1524; // rdx
  UINTN AllocationSize; // r15
  const CHAR8 *ZeroPool; // rax
  __int64 v17; // rbp

  if ( !a3 || !a4 ) /*0x1b4c*/
    return 0x8000000000000002uLL; /*0x1d30*/
  *a3 = ZeroPool_2; /*0x1b52*/
  if ( ZeroPool_2 ) /*0x1b58*/
  {
    if ( SetupRecordsList(ZeroPool_2, (__int64)&SourceBuffer__3, L"PchRcConfiguration") ) /*0x1b6b*/
      return HiiSubCallback((__int64)ZeroPool_2, a3, a4); /*0x1b82*/
    if ( !SetupRecordsList(ZeroPool_2, (__int64)&SourceBuffer__1, aIntelsetup) )// "IntelSetup" /*0x1b95*/
      return 0x800000000000000EuLL; /*0x1b9c*/
  }
  v9 = 0; /*0x1bc4*/
  CopyMem(&SourceBuffer__0, &DestinationBuffer__3, 0x2A4u); /*0x1bc7*/
  ZeroPool_1 = ZeroPool_2; /*0x1bd3*/
  byte_14A6C = *(_BYTE *)(qword_12B70 + 148); /*0x1bdc*/
  if ( !ZeroPool_2 || !PlatformSetupPolicy(ZeroPool_2, L"OFFSET") ) /*0x1bf1*/
  {
    if ( p_psub_1B18 == &psub_1B18 ) /*0x1c09*/
    {
      v11 = qword_FE70; /*0x1c0b*/
    }
    else
    {
      if ( p_psub_1B18 != (__int64 *)&unk_17A80 ) /*0x1c1e*/
        return 0x800000000000000EuLL; /*0x1ba8*/
      v11 = qword_FE80; /*0x1c24*/
    }
    v12 = ConstructConfigHdr( /*0x1c39*/
            &SourceBuffer__1,
            aIntelsetup, // "IntelSetup"
            v11);
    if ( !v12 ) /*0x1c44*/
    {
      ConfigRequestHdr____((void__)_0) = "ConfigRequestHdr != ((void *) 0)"; /*0x1c46*/
      n1524 = 1524; /*0x1c4d*/
LABEL_16:
      Assert( /*0x1c52*/
        (__int64)"e:\\hs\\PurleyRpPkg\\Platform\\Dxe\\Setup\\SetupPlatform.c",
        n1524,
        (__int64)ConfigRequestHdr____((void__)_0));
      return 0x8000000000000009uLL; /*0x1c68*/
    }
    AllocationSize = 2 * StrLen(v12) + 66; /*0x1c7a*/
    ZeroPool = (const CHAR8 *)AllocateZeroPool(AllocationSize); /*0x1c85*/
    ZeroPool_1 = (CHAR16 *)ZeroPool; /*0x1c8a*/
    if ( !ZeroPool ) /*0x1c90*/
    {
      ConfigRequestHdr____((void__)_0) = "ConfigRequest != ((void *) 0)"; /*0x1c92*/
      n1524 = 1536; /*0x1c99*/
      goto LABEL_16; /*0x1c9e*/
    }
    v9 = 1; /*0x1cb5*/
    AsciiStrLen(ZeroPool); /*0x1cb8*/
    ExtractConfig(); /*0x1cc0*/
  }
  v17 = (*(__int64 (__fastcall **)(__int64, CHAR16 *, void *, __int64, __int64, CHAR16 **))(qword_FE68 + 24))( /*0x1ce9*/
          qword_FE68,
          ZeroPool_1,
          &SourceBuffer__0,
          676,
          a4,
          a3);
  if ( v9 ) /*0x1cef*/
    ExtractConfig(); /*0x1cf4*/
  if ( ZeroPool_2 ) /*0x1cfc*/
  {
    if ( !PlatformSetupPolicy(ZeroPool_2, L"OFFSET") ) /*0x1d0d*/
      *a3 = &ZeroPool_2[StrLen(ZeroPool_2)]; /*0x1d28*/
  }
  else
  {
    *a3 = 0; /*0x1cfe*/
  }
  return v17; /*0x1d49*/
}
