Newer
Older
AMI-Aptio-BIOS-Reversed / NvmeDynamicSetup / NvmeDynamicSetup.c
@Ajax Dong Ajax Dong 2 days ago 131 KB Init
#include "NvmeDynamicSetup.h"

//
// NvmeDynamicSetup - UEFI Module (Regenerated from IDA)
// Total functions: 103
//

// Function: CopyMemRaw @ 0x2e0 (0x42 bytes)
// Index: 1/103

char *__fastcall CopyMemRaw(char *dst, char *src, unsigned __int64 count)
{
  char *dst_1; // rax
  unsigned __int64 count_1; // rcx
  char *dst_2; // rdi
  char *src_1; // rsi

  dst_1 = dst; /*0x2f0*/
  if ( src < dst && &src[count - 1] >= dst ) /*0x2f8*/
  {
    src_1 = &src[count - 1]; /*0x310*/
    dst_2 = &dst[count - 1]; /*0x313*/
  }
  else
  {
    count_1 = count; /*0x2fa*/
    count &= 7u; /*0x2fd*/
    count_1 >>= 3; /*0x304*/
    qmemcpy(dst, src, 8 * count_1); /*0x308*/
    src_1 = &src[8 * count_1]; /*0x308*/
    dst_2 = &dst[8 * count_1]; /*0x308*/
  }
  qmemcpy(dst_2, src_1, count); /*0x31c*/
  return dst_1; /*0x31f*/
}


// Function: ZeroMemRaw @ 0x330 (0x20 bytes)
// Index: 2/103

char *__fastcall ZeroMemRaw(char *buf, unsigned __int64 a2)
{
  memset(buf, 0, 8 * (a2 >> 3)); /*0x346*/
  memset(&buf[8 * (a2 >> 3)], 0, a2 & 7); /*0x34b*/
  return buf; /*0x34e*/
}


// Function: SetMemRaw @ 0x350 (0x11 bytes)
// Index: 3/103

void *__fastcall SetMemRaw(void *buf, unsigned __int64 count, char value)
{
  memset(buf, value, count); /*0x35a*/
  return buf; /*0x35f*/
}


// Function: CompareMemRaw @ 0x370 (0x1d bytes)
// Index: 4/103

unsigned __int64 __fastcall CompareMemRaw(_BYTE *src, _BYTE *p_n2, __int64 n2)
{
  bool v6; // zf

  do /*0x37b*/
  {
    if ( !n2 ) /*0x37b*/
      break; /*0x37b*/
    v6 = *src++ == *p_n2++; /*0x37b*/
    --n2; /*0x37b*/
  }
  while ( v6 ); /*0x37b*/
  return (unsigned __int8)*(src - 1) - (unsigned __int64)(unsigned __int8)*(p_n2 - 1); /*0x38a*/
}


// Function: _ModuleEntryPoint @ 0x3d0 (0x2b bytes)
// Index: 5/103

EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  NvmeDynamicSetupLibInit((__int64)ImageHandle, (__int64)SystemTable); /*0x3e0*/
  return NvmeDynamicSetupEntry(ImageHandle, SystemTable); /*0x3f5*/
}


// Function: NvmeDynamicSetupLibInit @ 0x3fc (0x2db bytes)
// Index: 6/103

__int64 __fastcall NvmeDynamicSetupLibInit(__int64 ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  signed __int64 v3; // rax
  __int64 v4; // rbx
  __int64 v5; // rax
  __int64 PcdProtocol; // rax
  __int64 v7; // rax
  __int64 v8; // rax
  __int64 v9; // rax

  ::ImageHandle = ImageHandle; /*0x411*/
  if ( !ImageHandle ) /*0x425*/
    Assert( /*0x434*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
      51,
      (__int64)"gImageHandle != ((void *) 0)");
  SystemTable_0 = (__int64)SystemTable; /*0x439*/
  if ( !SystemTable ) /*0x443*/
    Assert( /*0x452*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
      57,
      (__int64)"gST != ((void *) 0)");
  BootServices_0 = (__int64)SystemTable->BootServices; /*0x45b*/
  if ( !BootServices_0 ) /*0x465*/
    Assert( /*0x474*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
      63,
      (__int64)"gBS != ((void *) 0)");
  RuntimeServices_0 = (__int64)SystemTable->RuntimeServices; /*0x47d*/
  if ( !RuntimeServices_0 ) /*0x487*/
    Assert( /*0x49a*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeServicesTableLib\\UefiRuntimeServicesTableLib.c",
      47,
      (__int64)"gRT != ((void *) 0)");
  v3 = DxeServicesTableLibInit((__int64)&qword_8C60, &qword_9600); /*0x4ad*/
  v4 = v3; /*0x4b9*/
  if ( v3 < 0 ) /*0x4cb*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v3); /*0x4d5*/
    Assert( /*0x4e9*/
      (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
      64,
      (__int64)"!EFI_ERROR (Status)");
  }
  if ( !qword_9600 ) /*0x4f6*/
    Assert( /*0x50b*/
      (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
      65,
      (__int64)"gDS != ((void *) 0)");
  if ( v4 < 0 ) /*0x513*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0x51e*/
    Assert( /*0x532*/
      (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\AmiModulePkg\\Nvme\\NvmeDynamicSetup\\NvmeDynamicSetup\\DEBUG\\AutoGen.c",
      333,
      (__int64)"!EFI_ERROR (Status)");
  }
  if ( !qword_9608 ) /*0x53f*/
  {
    v5 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_8BA0, 0, &qword_9608); /*0x558*/
    if ( v5 < 0 ) /*0x561*/
    {
      DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x56c*/
      Assert( /*0x580*/
        (__int64)"e:\\hs\\CpRcPkg\\Library\\DxeMmPciBaseLib\\DxeMmPciBaseLib.c",
        52,
        (__int64)"!EFI_ERROR (Status)");
    }
    if ( !qword_9608 ) /*0x58d*/
      Assert( /*0x5a2*/
        (__int64)"e:\\hs\\CpRcPkg\\Library\\DxeMmPciBaseLib\\DxeMmPciBaseLib.c",
        53,
        (__int64)"mPciUsra != ((void *) 0)");
  }
  GetPciSegmentBaseAddress(); /*0x5a7*/
  PcdProtocol = LocatePcdProtocol(); /*0x5ac*/
  qword_9618 = (*(__int64 (__fastcall **)(__int64))(PcdProtocol + 32))(5); /*0x5b9*/
  v7 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_8C30, 0, &qword_9620); /*0x5d7*/
  if ( v7 < 0 ) /*0x5e7*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v7); /*0x5f2*/
    Assert( /*0x602*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
      88,
      (__int64)"!EFI_ERROR (Status)");
  }
  v8 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_8C20, 0, &qword_9640); /*0x61e*/
  if ( v8 < 0 ) /*0x627*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v8); /*0x632*/
    Assert( /*0x642*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
      94,
      (__int64)"!EFI_ERROR (Status)");
  }
  v9 = (*(__int64 (__fastcall **)(void *, _QWORD, void *))(BootServices_0 + 320))(&unk_8BF0, 0, &unk_9630); /*0x65e*/
  if ( v9 < 0 ) /*0x667*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v9); /*0x672*/
    Assert( /*0x682*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
      100,
      (__int64)"!EFI_ERROR (Status)");
  }
  (*(void (__fastcall **)(void *, _QWORD, void *))(BootServices_0 + 320))(&unk_8C80, 0, &unk_9628); /*0x69e*/
  return (*(__int64 (__fastcall **)(void *, _QWORD, void *))(BootServices_0 + 320))(&unk_8C00, 0, &unk_9638);
}


// Function: NvmeEnumPciDevice @ 0x6d8 (0x17c bytes)
// Index: 7/103

unsigned __int64 __fastcall NvmeEnumPciDevice(unsigned __int8 a1, unsigned __int8 a2, unsigned __int8 a3)
{
  __int64 PciAddress; // rbx
  UINTN Address; // rax
  int Bar0; // edi
  unsigned __int64 MmioBase; // rdi
  unsigned __int8 DeviceIndex; // si
  __int64 DevIndex2; // r15
  __int64 MmioOffset; // r14
  _BYTE *CtrlBase; // rbp
  UINTN CtrlBase2; // rbx

  PciAddress = (a3 << 20) | 0x2D000u; /*0x708*/
  Address = PciExpressLibAddress(PciAddress); /*0x70a*/
  if ( MmioRead16(Address) == 0xFFFF ) /*0x71f*/
    return 0x800000000000000EuLL; /*0x721*/
  Bar0 = *(_DWORD *)PciExpressLibAddress(PciAddress | 0x10); /*0x740*/
  if ( (Bar0 & 6) == 4 ) /*0x746*/
    MmioBase = Bar0 & 0xFFFFFFF0 | ((unsigned __int64)*(unsigned int *)PciExpressLibAddress(PciAddress | 0x14) << 32); /*0x767*/
  else
    MmioBase = Bar0 & 0xFFFFFFF0; /*0x771*/
  DeviceIndex = 0; /*0x774*/
  DevIndex2 = 0; /*0x776*/
  do /*0x82f*/
  {
    MmioOffset = DeviceIndex << 15; /*0x784*/
    if ( MmioRead16(MmioOffset + MmioBase + 2) == DeviceIndex + 8240 ) /*0x79b*/
    {
      CtrlBase = (_BYTE *)(MmioBase + ((unsigned __int64)*(unsigned __int8 *)(MmioOffset + MmioBase + 25) << 20)); /*0x7b1*/
      CtrlBase2 = MmioBase + ((unsigned __int64)*(unsigned __int8 *)(MmioOffset + MmioBase + 26) << 20); /*0x7bb*/
      if ( MmioRead16((UINTN)CtrlBase) != 0xFFFF && CtrlBase[11] == 1 && CtrlBase[10] == 8 && CtrlBase[9] == 2 ) /*0x7e2*/
        byte_8C92[36 * a1 + 12 * a2 + 3 * DevIndex2] = 1; /*0x802*/
      MmioRead16(CtrlBase2); /*0x809*/
    }
    ++DeviceIndex; /*0x825*/
    ++DevIndex2; /*0x828*/
  }
  while ( DeviceIndex < 4u ); /*0x82f*/
  return 0; /*0x846*/
}


// Function: NvmeSsmSendCommand @ 0x854 (0xfc bytes)
// Index: 8/103

__int64 __fastcall NvmeSsmSendCommand(__int64 a1, char *dst)
{
  __int64 Status; // rax
  __int64 Status_1; // rbx
  char buf_1[8]; // [rsp+30h] [rbp-D0h] BYREF
  int Zero1; // [rsp+38h] [rbp-C8h]
  int Flags; // [rsp+3Ch] [rbp-C4h]
  char buf_2[24]; // [rsp+58h] [rbp-A8h] BYREF
  char buf[8]; // [rsp+70h] [rbp-90h] BYREF
  char *DataPtr; // [rsp+78h] [rbp-88h]
  int BufferLen; // [rsp+80h] [rbp-80h]
  char PadByte; // [rsp+94h] [rbp-6Ch]
  char *CmdBufPtr; // [rsp+98h] [rbp-68h]
  char *buf_3; // [rsp+A0h] [rbp-60h]
  char src[4096]; // [rsp+B0h] [rbp-50h] BYREF

  ZeroMemS(buf, 0x40u); /*0x87e*/
  ZeroMemS(buf_1, 0x24u); /*0x88d*/
  ZeroMemS(buf_2, 0x10u); /*0x89c*/
  ZeroMemS(src, 0x1000u); /*0x8aa*/
  Zero1 = 0; /*0x8af*/
  CmdBufPtr = buf_1; /*0x8c4*/
  buf_1[0] = 6; /*0x8d0*/
  buf_3 = buf_2; /*0x8d5*/
  Flags = 1; /*0x8df*/
  DataPtr = src; /*0x8ea*/
  buf_1[4] = 1; /*0x8ef*/
  BufferLen = 4096; /*0x8f4*/
  *(_QWORD *)buf = 50000000; /*0x8fb*/
  PadByte = 0; /*0x904*/
  Status = (*(__int64 (__fastcall **)(__int64, _QWORD, _QWORD, char *, _QWORD))(a1 + 8))(a1, 0, 0, buf, 0); /*0x908*/
  Status_1 = Status; /*0x90b*/
  if ( Status >= 0 ) /*0x911*/
  {
    CopyMemS(dst, src, 0x1000u); /*0x934*/
    return 0; /*0x939*/
  }
  else
  {
    GetPciExpressBaseAddress( /*0x91d*/
      (const CHAR16 *)L"IntelGetNvmeIdentifyData - IntelGetNvmeIdentifyData->PassThru (%r)\n",
      Status);
    return Status_1; /*0x922*/
  }
}


// Function: NvmeLookupHwSubType @ 0x950 (0x147 bytes)
// Index: 9/103

__int64 __fastcall NvmeLookupHwSubType(
        char EntryCount,
        __int64 a2,
        __int64 a3,
        __int64 a4,
        _BYTE *a5,
        char *p_n26,
        UINT16 *AdjustedIdx,
        UINT16 *a8)
{
  _BYTE *TablePtr; // rcx
  char HwSubType; // dl
  __int64 LoopCount; // r8
  unsigned __int8 SubType; // bl
  unsigned __int8 DeviceId; // bl
  unsigned __int8 AdjustedIdx_1; // cl
  _DWORD *PciRegPtr; // rax
  UINTN Address; // rbx

  *AdjustedIdx = -1; /*0x98a*/
  *a8 = -1; /*0x991*/
  TablePtr = &unk_8C90; /*0x995*/
  *p_n26 = -1; /*0x99c*/
  HwSubType = 0; /*0x9a0*/
  *a5 = -1; /*0x9a2*/
  LoopCount = 24; /*0x9a6*/
  do /*0x9cc*/
  {
    if ( TablePtr[2] ) /*0x9ac*/
    {
      if ( HwSubType == EntryCount ) /*0x9b5*/
      {
        *a5 = *TablePtr; /*0x9b9*/
        *p_n26 = TablePtr[1]; /*0x9bf*/
      }
      ++HwSubType; /*0x9c2*/
    }
    TablePtr += 3; /*0x9c4*/
    --LoopCount; /*0x9c8*/
  }
  while ( LoopCount ); /*0x9cc*/
  if ( *a5 != 0xFF ) /*0x9d2*/
  {
    SubType = *p_n26; /*0x9d8*/
    if ( *p_n26 != -1 ) /*0x9de*/
    {
      if ( SubType >= 0x1Au ) /*0x9e9*/
      {
        if ( SubType <= 0x1Du ) /*0x9ed*/
        {
          DeviceId = SubType - 26; /*0xa19*/
          AdjustedIdx_1 = *(_BYTE *)((unsigned __int8)*a5 + a2); /*0xa1c*/
          goto LABEL_18; /*0xa1f*/
        }
        if ( SubType > 0x29u ) /*0x9f1*/
        {
          if ( SubType <= 0x2Du ) /*0x9f5*/
          {
            DeviceId = SubType - 42; /*0xa0d*/
            AdjustedIdx_1 = *(_BYTE *)((unsigned __int8)*a5 + a3); /*0xa10*/
            goto LABEL_18; /*0xa13*/
          }
          if ( (unsigned __int8)(SubType - 58) <= 3u ) /*0x9fb*/
          {
            DeviceId = SubType - 58; /*0xa01*/
            AdjustedIdx_1 = *(_BYTE *)((unsigned __int8)*a5 + a4); /*0xa04*/
LABEL_18:
            PciRegPtr = (_DWORD *)PciExpressLibAddress((AdjustedIdx_1 << 20) | 0x2D010u); /*0xa29*/
            Address = (*PciRegPtr & 0xFFFFFFF0) /*0xa54*/
                    + ((unsigned __int64)*((unsigned __int8 *)&word_18[0x4000 * (unsigned __int64)DeviceId]
                                         + (*PciRegPtr & 0xFFFFFFF0)
                                         + 1) << 20);
            *AdjustedIdx = MmioRead16(Address); /*0xa63*/
            *a8 = MmioRead16(Address + 2); /*0xa6c*/
            return 0; /*0xa72*/
          }
        }
      }
      AdjustedIdx_1 = (unsigned __int8)AdjustedIdx; /*0xa21*/
      DeviceId = (unsigned __int8)AdjustedIdx; /*0xa25*/
      goto LABEL_18; /*0xa25*/
    }
  }
  return 0x800000000000000EuLL; /*0xa8d*/
}


// Function: NvmeGetDriveInfo @ 0xa98 (0x31d bytes)
// Index: 10/103

unsigned __int8 *__fastcall NvmeGetDriveInfo(
        __int64 BusMin,
        __int64 a2,
        unsigned __int8 *DataPtr,
        __int64 a4,
        unsigned __int8 *a5,
        __int64 *p_n26)
{
  __int64 StrideA; // r14
  unsigned __int8 *DataPtr_1; // rax
  __int64 StrideC; // rbp
  char Lun; // si
  unsigned __int8 PortIdx; // r13
  unsigned __int8 *DataPtr_3; // r15
  int BusDevFn; // edi
  UINTN Address; // rax
  unsigned __int64 BusMin_1; // rbx
  char FuncIdx; // bp
  __int64 FuncLoop; // r12
  UINTN Address_1; // rax
  unsigned __int64 BusMin_3; // rbx
  char FuncIdx2; // bp
  __int64 n32; // r12
  UINTN Address_2; // rax
  unsigned __int64 BusMin_5; // rbx
  char FuncIdx3; // bp
  __int64 FuncLoop2; // r12
  unsigned __int8 *DataPtr_2; // [rsp+28h] [rbp-60h]
  unsigned __int64 BusMin_2; // [rsp+30h] [rbp-58h]
  unsigned __int64 BusMin_4; // [rsp+30h] [rbp-58h]
  unsigned __int64 BusMin_6; // [rsp+30h] [rbp-58h]
  __int64 StrideA_1; // [rsp+98h] [rbp+10h]
  __int64 StrideC_1; // [rsp+A8h] [rbp+20h]

  StrideA = a2 - (_QWORD)DataPtr; /*0xab8*/
  DataPtr_1 = DataPtr; /*0xabb*/
  StrideC = a4 - (_QWORD)DataPtr; /*0xabe*/
  StrideA_1 = a2 - (_QWORD)DataPtr; /*0xac1*/
  StrideC_1 = a4 - (_QWORD)DataPtr; /*0xac9*/
  Lun = 42; /*0xad1*/
  do /*0xd9e*/
  {
    PortIdx = 0; /*0xada*/
    DataPtr_2 = DataPtr_1; /*0xadd*/
    DataPtr_3 = DataPtr_1; /*0xae5*/
    BusDevFn = (Lun - 10) & 0x1F; /*0xae8*/
    do /*0xd88*/
    {
      Address = PciExpressLibAddress((BusDevFn | (32 * (unsigned int)DataPtr_3[StrideA])) << 15); /*0xafc*/
      if ( MmioRead16(Address) != 0xFFFF ) /*0xb0d*/
      {
        BusMin_1 = *(unsigned __int8 *)PciExpressLibAddress(((BusDevFn | (32 * DataPtr_3[StrideA])) << 15) | 0x19u); /*0xb28*/
        BusMin_2 = *(unsigned __int8 *)PciExpressLibAddress(((BusDevFn | (32 * DataPtr_3[StrideA])) << 15) | 0x1Au); /*0xb43*/
        if ( BusMin_1 <= BusMin_2 ) /*0xb4b*/
        {
          do /*0xbae*/
          {
            FuncIdx = 0; /*0xb65*/
            FuncLoop = 32; /*0xb67*/
            do /*0xba4*/
            {
              if ( !*(_BYTE *)PciExpressLibAddress( /*0xb8a*/
                                ((unsigned __int64)(unsigned __int8)BusMin_1 << 20)
                              | ((unsigned __int64)(FuncIdx & 0x1F) << 15)
                              | 0xE)
                && BusMin_1 == BusMin )
              {
                *a5 = PortIdx; /*0xb94*/
                *(_BYTE *)p_n26 = Lun - 16; /*0xb9a*/
              }
              ++FuncIdx; /*0xb9d*/
              --FuncLoop; /*0xba0*/
            }
            while ( FuncLoop ); /*0xba4*/
            ++BusMin_1; /*0xba6*/
          }
          while ( BusMin_1 <= BusMin_2 ); /*0xbae*/
          BusDevFn = (Lun - 10) & 0x1F; /*0xbb0*/
          DataPtr_3 = DataPtr_2; /*0xbba*/
          StrideC = StrideC_1; /*0xbbf*/
        }
      }
      Address_1 = PciExpressLibAddress((BusDevFn | (32 * (unsigned int)*DataPtr_3)) << 15); /*0xbd3*/
      if ( MmioRead16(Address_1) != 0xFFFF ) /*0xbe4*/
      {
        BusMin_3 = *(unsigned __int8 *)PciExpressLibAddress(((BusDevFn | (32 * *DataPtr_3)) << 15) | 0x19u); /*0xbfe*/
        BusMin_4 = *(unsigned __int8 *)PciExpressLibAddress(((BusDevFn | (32 * *DataPtr_3)) << 15) | 0x1Au); /*0xc18*/
        if ( BusMin_3 <= BusMin_4 ) /*0xc20*/
        {
          do /*0xc80*/
          {
            FuncIdx2 = 0; /*0xc3a*/
            n32 = 32; /*0xc3c*/
            do /*0xc76*/
            {
              if ( !*(_BYTE *)PciExpressLibAddress( /*0xc5f*/
                                ((unsigned __int64)(unsigned __int8)BusMin_3 << 20)
                              | ((unsigned __int64)(FuncIdx2 & 0x1F) << 15)
                              | 0xE)
                && BusMin_3 == BusMin )
              {
                *(_BYTE *)p_n26 = Lun; /*0xc69*/
                *a5 = PortIdx; /*0xc6c*/
              }
              ++FuncIdx2; /*0xc6f*/
              --n32; /*0xc72*/
            }
            while ( n32 ); /*0xc76*/
            ++BusMin_3; /*0xc78*/
          }
          while ( BusMin_3 <= BusMin_4 ); /*0xc80*/
          BusDevFn = (Lun - 10) & 0x1F; /*0xc82*/
          DataPtr_3 = DataPtr_2; /*0xc8c*/
          StrideC = StrideC_1; /*0xc91*/
        }
      }
      Address_2 = PciExpressLibAddress((BusDevFn | (32 * (unsigned int)DataPtr_3[StrideC])) << 15); /*0xca6*/
      if ( MmioRead16(Address_2) != 0xFFFF ) /*0xcb7*/
      {
        BusMin_5 = *(unsigned __int8 *)PciExpressLibAddress(((BusDevFn | (32 * DataPtr_3[StrideC])) << 15) | 0x19u); /*0xcd2*/
        BusMin_6 = *(unsigned __int8 *)PciExpressLibAddress(((BusDevFn | (32 * DataPtr_3[StrideC])) << 15) | 0x1Au); /*0xced*/
        if ( BusMin_5 <= BusMin_6 ) /*0xcf5*/
        {
          do /*0xd58*/
          {
            FuncIdx3 = 0; /*0xd0f*/
            FuncLoop2 = 32; /*0xd11*/
            do /*0xd4e*/
            {
              if ( !*(_BYTE *)PciExpressLibAddress( /*0xd34*/
                                ((unsigned __int64)(unsigned __int8)BusMin_5 << 20)
                              | ((unsigned __int64)(FuncIdx3 & 0x1F) << 15)
                              | 0xE)
                && BusMin_5 == BusMin )
              {
                *a5 = PortIdx; /*0xd3e*/
                *(_BYTE *)p_n26 = Lun + 16; /*0xd44*/
              }
              ++FuncIdx3; /*0xd47*/
              --FuncLoop2; /*0xd4a*/
            }
            while ( FuncLoop2 ); /*0xd4e*/
            ++BusMin_5; /*0xd50*/
          }
          while ( BusMin_5 <= BusMin_6 ); /*0xd58*/
          BusDevFn = (Lun - 10) & 0x1F; /*0xd5a*/
          DataPtr_3 = DataPtr_2; /*0xd64*/
          StrideC = StrideC_1; /*0xd69*/
        }
      }
      StrideA = StrideA_1; /*0xd71*/
      ++DataPtr_3; /*0xd79*/
      ++PortIdx; /*0xd7c*/
      DataPtr_2 = DataPtr_3; /*0xd7f*/
    }
    while ( PortIdx < 2u ); /*0xd88*/
    ++Lun; /*0xd8e*/
    DataPtr_1 = DataPtr; /*0xd96*/
  }
  while ( (unsigned __int8)(Lun - 42) < 4u ); /*0xd9e*/
  return DataPtr_1; /*0xda4*/
}


// Function: NvmeHiiNewString @ 0xdb8 (0x1b8 bytes)
// Index: 11/103

_BYTE *__fastcall NvmeHiiNewString(__int64 a1, __int64 a2, unsigned __int16 *a3)
{
  __int64 v3; // r10
  _BYTE *v7; // r8
  _BYTE *result; // rax
  _BYTE *v9; // r9
  __int64 v10; // r8
  __int64 v11; // rax
  __int64 v12; // rcx
  __int64 v13; // r8
  _QWORD v14[2]; // [rsp+40h] [rbp-10h] BYREF
  _BYTE *v15; // [rsp+88h] [rbp+38h] BYREF

  v3 = qword_95C8; /*0xdcd*/
  v15 = 0; /*0xdd7*/
  v14[0] = 0; /*0xdde*/
  v7 = 0; /*0xde8*/
  if ( !qword_95C8 ) /*0xdee*/
  {
    result = (_BYTE *)(*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))( /*0xe07*/
                        &unk_8C30,
                        0,
                        &qword_95C8);
    if ( (__int64)result < 0 ) /*0xe10*/
      return result; /*0xe10*/
    v7 = v15; /*0xe16*/
    v3 = qword_95C8; /*0xe1a*/
  }
  result = (_BYTE *)qword_95B8; /*0xe21*/
  if ( qword_95B8 ) /*0xe2b*/
  {
    v15 = (_BYTE *)qword_95B8; /*0xe9f*/
  }
  else
  {
    if ( (*(__int64 (__fastcall **)(__int64, __int64, _BYTE *, _QWORD *))(v3 + 24))(v3, a1, v7, v14) == 0x8000000000000005uLL ) /*0xe48*/
    {
      result = (_BYTE *)(*(__int64 (__fastcall **)(__int64, _QWORD, _BYTE **))(BootServices + 64))(4, v14[0], &v15); /*0xe5e*/
      if ( (__int64)result < 0 ) /*0xe64*/
        return result; /*0xe64*/
      result = (_BYTE *)(*(__int64 (__fastcall **)(__int64, __int64, _BYTE *, _QWORD *))(qword_95C8 + 24))( /*0xe7f*/
                          qword_95C8,
                          a1,
                          v15,
                          v14);
      if ( (__int64)result < 0 ) /*0xe85*/
        return result; /*0xe85*/
    }
    result = v15; /*0xe8b*/
    v3 = qword_95C8; /*0xe8f*/
    qword_95B8 = (__int64)v15; /*0xe96*/
  }
  if ( result ) /*0xea6*/
  {
    while ( 2 ) /*0xeac*/
    {
      v9 = result; /*0xeac*/
      while ( *result != 59 ) /*0xec1*/
      {
        if ( !*result ) /*0xeb3*/
        {
          v13 = *a3; /*0xf28*/
          if ( (_WORD)v13 ) /*0xf36*/
            return (_BYTE *)(*(__int64 (__fastcall **)(__int64, __int64, __int64, _BYTE *, __int64, _QWORD))(v3 + 16))( /*0xf59*/
                              v3,
                              a1,
                              v13,
                              v9,
                              a2,
                              0);
          else
            return (_BYTE *)(*(__int64 (__fastcall **)(__int64, __int64, unsigned __int16 *, _BYTE *, _QWORD, __int64, _QWORD))v3)( /*0xf4a*/
                              v3,
                              a1,
                              a3,
                              v9,
                              0,
                              a2,
                              0);
        }
        v15 = ++result; /*0xeb8*/
      }
      *result = 0; /*0xec8*/
      v10 = *a3; /*0xece*/
      if ( (_WORD)v10 ) /*0xee0*/
        v11 = (*(__int64 (__fastcall **)(__int64, __int64, __int64, _BYTE *, __int64, _QWORD))(qword_95C8 + 16))( /*0xf02*/
                qword_95C8,
                a1,
                v10,
                v9,
                a2,
                0);
      else
        v11 = (*(__int64 (__fastcall **)(__int64, __int64, unsigned __int16 *, _BYTE *, _QWORD, __int64, _QWORD))qword_95C8)( /*0xef4*/
                qword_95C8,
                a1,
                a3,
                v9,
                0,
                a2,
                0);
      v12 = v11; /*0xf05*/
      *v15 = 59; /*0xf0c*/
      result = ++v15; /*0xf13*/
      if ( v12 >= 0 ) /*0xf1d*/
      {
        v3 = qword_95C8; /*0xf1f*/
        continue; /*0xf26*/
      }
      break;
    }
  }
  return result; /*0xf67*/
}


// Function: NvmeUpdateDisplayString @ 0xf70 (0xe8 bytes)
// Index: 12/103

char *__fastcall NvmeUpdateDisplayString(char **OpCodeHandle, __int64 a2, unsigned int n7, unsigned __int8 *a4)
{
  __int16 *v5; // rsi
  unsigned int i; // ebp
  char v9; // dl
  unsigned __int8 *v10; // r8
  __int64 n2; // rcx
  char *i_1; // rax
  __int16 v13; // r14
  __int16 v14; // di
  __int16 v15; // bx
  char buf[2]; // [rsp+10h] [rbp-38h] BYREF
  __int16 v17; // [rsp+12h] [rbp-36h]
  __int16 v18; // [rsp+14h] [rbp-34h]
  __int16 v19; // [rsp+16h] [rbp-32h]

  if ( n7 ) /*0xf73*/
  {
    v5 = (__int16 *)(a2 + 4); /*0xf98*/
    for ( i = 0; i < n7; ++i ) /*0xfa5*/
    {
      v9 = 0; /*0xfac*/
      v10 = a4; /*0xfaf*/
      n2 = 2; /*0xfb2*/
      do /*0xfca*/
      {
        i_1 = (char *)*v10; /*0xfb7*/
        if ( i == (_DWORD)i_1 ) /*0xfc0*/
          v9 = 1; /*0xfc0*/
        ++v10; /*0xfc4*/
        --n2; /*0xfc7*/
      }
      while ( n2 ); /*0xfca*/
      v13 = *(v5 - 2); /*0xfcc*/
      if ( (v13 || *v5) && !v9 ) /*0xfdf*/
      {
        v14 = *v5; /*0xfe1*/
        v15 = *(v5 - 1); /*0xfe9*/
        ZeroMemS(buf, 8u); /*0xff2*/
        v17 = v13; /*0x1008*/
        v18 = v15; /*0x1011*/
        v19 = v14; /*0x1019*/
        i_1 = HiiCreateOpCode(OpCodeHandle, buf, 3, 8u, 0); /*0x101e*/
      }
      v5 += 3; /*0x102a*/
    }
  }
  return i_1; /*0x1057*/
}


// Function: NvmeInitDynamicMainForm @ 0x1058 (0x912 bytes)
// Index: 13/103

__int64 NvmeInitDynamicMainForm()
{
  __int64 v0; // rax
  __int64 v1; // rbx
  __int64 n871; // rdx
  __int64 result; // rax
  __int64 v4; // rax
  __int64 v5; // rsi
  unsigned __int64 v6; // rax
  __int64 EntryCount; // r15
  unsigned __int16 *i_1; // r14
  char *dst_2; // rax
  char SetupValue; // bl
  __int64 v11; // rcx
  __int64 i_3; // rcx
  __int64 v13; // rax
  __int64 n39; // rax
  unsigned int FormatString_2; // r12d
  __int64 v16; // r13
  __int64 v17; // rbx
  unsigned int FormatString_3; // edi
  __int64 v19; // rsi
  __int64 v20; // rax
  UINTN Address; // rcx
  UINT32 v22; // eax
  unsigned __int64 v23; // rcx
  unsigned __int64 v24; // rdi
  unsigned __int64 v25; // rbx
  unsigned __int16 *i_4; // rbx
  UINTN Address_1; // rcx
  char *dst_1; // [rsp+40h] [rbp-C0h] BYREF
  char v29[4]; // [rsp+48h] [rbp-B8h] BYREF
  unsigned __int8 buf_2[4]; // [rsp+4Ch] [rbp-B4h] BYREF
  unsigned __int8 buf_1[4]; // [rsp+50h] [rbp-B0h] BYREF
  unsigned __int8 buf[4]; // [rsp+54h] [rbp... [14504 chars total]


// Function: NvmeEnumerateNvmeDevices @ 0x196c (0x916 bytes)
// Index: 14/103

unsigned __int64 NvmeEnumerateNvmeDevices()
{
  __int64 v0; // r13
  int v1; // ebx
  char SetupValue; // di
  __int64 v3; // rdx
  __int64 v4; // rcx
  __int64 v5; // rdx
  __int64 v6; // rcx
  __int64 v7; // rcx
  unsigned __int64 v8; // r14
  __int64 n2; // rsi
  __int64 v10; // rax
  __int64 n1256; // rdx
  __int64 v12; // rax
  __int64 v13; // rax
  __int64 v14; // rax
  char *dst_1; // rax
  __int64 n39; // rax
  __int64 v17; // rax
  __int64 i_1; // rcx
  __int64 v19; // rax
  __int64 n5; // rax
  char *dst_2; // rcx
  char *v22; // r8
  __int64 v23; // rax
  char *dst_3; // rcx
  unsigned int FormatString_1; // r12d
  _QWORD *v26; // r15
  unsigned __int16 *n26_1; // r14
  int v28; // esi
  unsigned __int64 v29; // rcx
  unsigned __int64 v30; // rdi
  unsigned __int64 v31; // rbx
  UINTN Address; // rcx
  unsigned __int64 result; // rax
  char *dst; // [rsp+30h] [rbp-D0h] BYREF
  unsigned __int8 i; // [rsp+38h] [rbp-C8h] BYREF
  _BYTE v36[3]; // [rsp+39h] [rbp-C7h] BYREF
  unsi... [14443 chars total]


// Function: NvmeSetConfigAction @ 0x2284 (0x176 bytes)
// Index: 15/103

// (decompile failed for NvmeSetConfigAction @ 0x2284)


// Function: NvmeDynamicSetupNotification @ 0x23fc (0x1fe bytes)
// Index: 16/103

void NvmeDynamicSetupNotification()
{
  __int16 v0; // r15
  __int64 v1; // rcx
  _QWORD *OpCodeHandle_1; // rsi
  __int64 v3; // rcx
  _QWORD *OpCodeHandle_3; // rax
  EFI_QUESTION_ID QuestionId; // dx
  EFI_VARSTORE_ID VarStoreId; // r8
  UINT16 VarOffset; // r9
  void *OpCodeHandle_2; // r14
  UINT8 *StringOpCode; // rbx
  EFI_QUESTION_ID QuestionId_1; // dx
  EFI_VARSTORE_ID VarStoreId_1; // r8
  UINT16 VarOffset_1; // r9
  UINT8 *v13; // rax
  __int64 v14; // rdx
  __int64 dst_; // rcx
  const CHAR8 *FormatString; // r8
  __int64 *v17; // rdi
  const __int16 *M.2_Rear%d:_%a; // rdx
  UINT16 Value; // dx
  UINTN Address; // rcx
  unsigned __int16 v21; // bx
  EFI_STRING_ID OpCodeHandle; // [rsp+20h] [rbp-59h]
  EFI_STRING_ID OpCodeHandlea; // [rsp+20h] [rbp-59h]
  EFI_STRING_ID Help; // [rsp+28h] [rbp-51h]
  EFI_STRING_ID Help_1; // [rsp+28h] [rbp-51h]
  char buf_1[2]; // [rsp+30h] [rbp-49h] BYREF
  unsigned __int16 v27; // [rsp+32h] [rbp-47h]
  __int16 n12; // [rsp+34h] [rbp-45h]
  __int16 v29; // [rsp+36h] [rbp-43h]
  UINT8 StringFlags; // [rsp+38h] [rbp-41h]
  char n4; // [rsp+3Ch] [rbp-3Dh]
  __int16 n2; // [rsp+3Dh] [rbp-3Ch]
  int buf; // [rsp+40h] [rbp-39h] BYREF
  UINT8 MaxSize; // [rsp+48h] [rbp-31h]
  void *DefaultsOpCodeHandle; // [rsp+50h] [rbp-29h]
  UINT16 v36; // [rsp+F0h] [rbp+77h] BYREF

  v0 = 0; /*0x2428*/
  SetMem32Raw(&buf, 0, 0x64u); /*0x2430*/
  v36 = 0; /*0x243c*/
  DebugPrint(0x40u, "\nNvmeInitDynamicMainFormContents Entry \n"); /*0x2446*/
  OpCodeHandle_1 = HiiCreateOpCodeHandle(v1); /*0x2450*/
  OpCodeHandle_3 = HiiCreateOpCodeHandle(v3); /*0x2453*/
  OpCodeHandle_2 = OpCodeHandle_3; /*0x2458*/
  if ( OpCodeHandle_1 )
  {
    if ( OpCodeHandle_3 )
    {
      StringOpCode = HiiCreateStringOpCode( /*0x2478*/
                       OpCodeHandle_1,
                       QuestionId,
                       VarStoreId,
                       VarOffset,
                       OpCodeHandle,
                       Help,
                       buf_1[0],
                       StringFlags,
                       buf,
                       MaxSize,
                       DefaultsOpCodeHandle);
      v13 = HiiCreateStringOpCode( /*0x247b*/
              OpCodeHandle_2,
              QuestionId_1,
              VarStoreId_1,
              VarOffset_1,
              OpCodeHandlea,
              Help_1,
              buf_1[0],
              StringFlags,
              buf,
              MaxSize,
              DefaultsOpCodeHandle);
      if ( StringOpCode )
      {
        if ( v13 )
        {
          StringOpCode[18] = 0; /*0x2492*/
          v13[18] = 0; /*0x249b*/
          *(_WORD *)(StringOpCode + 19) = 4096; /*0x249f*/
          *(_WORD *)(v13 + 19) = 4097; /*0x24a8*/
          if ( (NvmeEnumerateNvmeDevices() & 0x8000000000000000uLL) != 0LL )
          {
            UnicodeSPrintAsciiFormat((CHAR16 *)&buf, (UINTN)L"No NVME Device Found", FormatString); /*0x257b*/
            NvmeHiiNewString((__int64)HiiHandle, (__int64)&buf, &v36); /*0x258f*/
            HiiCreateEndOpCode(OpCodeHandle_1); /*0x259b*/
            v36 = 0; /*0x25a0*/
          }
          else
          {
            v17 = (__int64 *)qword_9690; /*0x24ba*/
            while ( v17 != &qword_9690 )
            {
              if ( *((_WORD *)v17 - 14) )
              {
                M.2_Rear%d:_%a = L"M.2/Rear%d: %a";
                if ( !*((_BYTE *)v17 - 60) )
                  M.2_Rear%d:_%a = L"Slot%d: %a";
                UnicodeSPrintAsciiFormat( /*0x24fe*/
                  (CHAR16 *)&buf,
                  (UINTN)M.2_Rear%d:_%a,
                  *(const CHAR8 **)((char *)v17 - 108),
                  (char *)v17 - 148);
                v36 = PciWrite16(Address, Value); /*0x2511*/
                v21 = v36; /*0x2519*/
                ZeroMemS(buf_1, 0xFu); /*0x251c*/
                v27 = v21; /*0x2526*/
                n12 = 12; /*0x252a*/
                n4 = 4; /*0x2537*/
                v29 = v0 + 256; /*0x2543*/
                n2 = 2; /*0x254f*/
                HiiCreateOpCode((char **)OpCodeHandle_1, buf_1, 15, 0xFu, 0); /*0x255a*/
              }
              v17 = (__int64 *)*v17; /*0x255f*/
              ++v0; /*0x2562*/
            }
          }
          NvmeProcessIfrOpCode(dst_, v14, 1, OpCodeHandle_1, (__int64 *)OpCodeHandle_2); /*0x25b3*/
          HiiDestroyOpCodeHandle((void **)OpCodeHandle_1); /*0x25bb*/
          HiiDestroyOpCodeHandle((void **)OpCodeHandle_2); /*0x25c3*/
          DebugPrint(0x40u, "\nNvmeInitDynamicMainFormContents Exit \n"); /*0x25d4*/
        }
      }
    }
  }
}


// Function: NvmeDriverBindingStop @ 0x25fc (0x3d bytes)
// Index: 17/103

unsigned __int64 __fastcall NvmeDriverBindingStop(__int64 a1, __int64 a2, __int16 a3)
{
  if ( a2 ) /*0x2603*/
    return 0x8000000000000003uLL; /*0x2605*/
  if ( (unsigned __int16)(a3 - 256) <= 0xFFu ) /*0x2623*/
    NvmeSetConfigAction(a3 - 256); /*0x262d*/
  return 0; /*0x2634*/
}


// Function: NvmeDynamicSetupEntry @ 0x263c (0x1f3 bytes)
// Index: 18/103

__int64 __fastcall NvmeDynamicSetupEntry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  EFI_BOOT_SERVICES *BootServices; // r9
  EFI_RUNTIME_SERVICES *RuntimeServices; // rax
  __int64 v5; // rax
  __int64 v6; // rcx
  __int64 v7; // rbx
  __int64 v8; // r8
  unsigned __int64 i; // rdx
  __int64 v11; // [rsp+38h] [rbp-38h] BYREF
  __int64 (__fastcall **v12)(_QWORD, __int64, _QWORD, _QWORD *); // [rsp+40h] [rbp-30h] BYREF
  _QWORD v13[2]; // [rsp+48h] [rbp-28h] BYREF
  _BYTE v14[8]; // [rsp+58h] [rbp-18h] BYREF
  _DWORD v15[4]; // [rsp+60h] [rbp-10h] BYREF
  __int64 v16; // [rsp+A8h] [rbp+38h] BYREF

  v15[0] = 1897934574; /*0x264d*/
  v15[1] = 1087987539; /*0x265e*/
  v15[2] = 211697067; /*0x2665*/
  v15[3] = 1466358054; /*0x266c*/
  if ( ::SystemTable ) /*0x2673*/
  {
    BootServices = (EFI_BOOT_SERVICES *)::BootServices; /*0x2694*/
  }
  else
  {
    ::SystemTable = (__int64)SystemTable; /*0x2675*/
    BootServices = SystemTable->BootServices; /*0x267c*/
    RuntimeServices = SystemTable->RuntimeServices; /*0x2680*/
    ::BootServices = (__int64)BootServices; /*0x2684*/
    ::RuntimeServices = (__int64)RuntimeServices; /*0x268b*/
  }
  v5 = ((__int64 (__fastcall *)(void *, _QWORD, __int64 *))BootServices->LocateProtocol)(&unk_8C40, 0, &qword_95B0); /*0x26ab*/
  v6 = qword_95B0; /*0x26b2*/
  if ( v5 < 0 ) /*0x26ce*/
    v6 = 0; /*0x26ce*/
  qword_95B0 = v6; /*0x26d2*/
  v7 = (*(__int64 (__fastcall **)(EFI_HANDLE, void *, __int64 *))(::BootServices + 152))(ImageHandle, &unk_8DA0, &v11); /*0x26e2*/
  if ( v7 >= 0 ) /*0x26e8*/
  {
    v7 = (*(__int64 (__fastcall **)(EFI_HANDLE, void *, __int64 *, EFI_HANDLE, _QWORD, int))(::BootServices + 280))( /*0x2719*/
           ImageHandle,
           &unk_8DE0,
           &v16,
           ImageHandle,
           0,
           2);
    if ( v7 >= 0 ) /*0x271f*/
    {
      v7 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 (__fastcall ***)(_QWORD, __int64, _QWORD, _QWORD *)))(::BootServices + 320))( /*0x273f*/
             &unk_8D40,
             0,
             &v12);
      if ( v7 >= 0 ) /*0x2745*/
      {
        for ( i = v16 + 20; /*0x2756*/
              i < v16 + (unsigned __int64)*(unsigned int *)(v16 + 16) && *(_BYTE *)(i + 3) != 2;
              i += *(_DWORD *)i & 0xFFFFFF )
        {
          ; /*0x276c*/
        }
        NvmeConfigAccessInit(v11, i + 4, v8); /*0x278e*/
        v7 = (*v12)(v12, v16, 0, v13); /*0x27a8*/
        if ( v7 >= 0 ) /*0x27ae*/
          v7 = 0; /*0x27c1*/
      }
    }
  }
  if ( v7 >= 0 ) /*0x27c7*/
  {
    if ( (*(__int64 (__fastcall **)(__int64, __int64, __int64 (*)()))(::BootServices + 80))( /*0x27f2*/
           512,
           8,
           NvmeDynamicSetupNotification) >= 0 )
      (*(void (__fastcall **)(_DWORD *, _QWORD, _BYTE *))(::BootServices + 168))(v15, v13[1], v14); /*0x2807*/
    HiiHandle = qword_8CF8; /*0x2815*/
  }
  return v7; /*0x2827*/
}


// Function: MmioRead16 @ 0x2830 (0x2f bytes)
// Index: 19/103

UINT16 __cdecl MmioRead16(UINTN Address)
{
  if ( (Address & 1) != 0 ) /*0x283c*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c", 151, (__int64)"(Address & 1) == 0"); /*0x2851*/
  return *(_WORD *)Address; /*0x2859*/
}


// Function: MmioRead32 @ 0x2860 (0x4f bytes)
// Index: 20/103

UINT32 __cdecl MmioRead32(UINTN Address)
{
  UINT32 result; // eax

  if ( !qword_9690 ) /*0x286c*/
    result = Assert( /*0x2881*/
               (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\LinkedList.c",
               81,
               (__int64)"List->ForwardLink != ((void *) 0)");
  if ( !qword_9698 ) /*0x288e*/
    result = Assert( /*0x28a3*/
               (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\LinkedList.c",
               82,
               (__int64)"List->BackLink != ((void *) 0)");
  LOBYTE(result) = 1; /*0x28a8*/
  return result; /*0x28aa*/
}


// Function: MmioRead64 @ 0x28b0 (0x4f bytes)
// Index: 21/103

UINT64 __cdecl MmioRead64(UINTN Address)
{
  _QWORD *v1; // rdx
  _QWORD *v2; // rbx
  _QWORD *v4; // rcx

  v2 = v1; /*0x28b6*/
  if ( !(unsigned __int8)MmioRead32(Address) ) /*0x28b9*/
    Assert( /*0x28d5*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\LinkedList.c",
      273,
      (__int64)"InternalBaseLibIsListValid (ListHead)");
  *v2 = &qword_9690; /*0x28e1*/
  v4 = (_QWORD *)qword_9698; /*0x28e4*/
  v2[1] = qword_9698; /*0x28eb*/
  *v4 = v2; /*0x28ef*/
  qword_9698 = (__int64)v2; /*0x28f2*/
  return (UINT64)&qword_9690; /*0x28f9*/
}


// Function: DivU64x32 @ 0x2900 (0x5a bytes)
// Index: 22/103

UINT64 __cdecl DivU64x32(UINT64 Dividend, UINT32 Divisor)
{
  _DWORD *v2; // r8
  unsigned __int64 Divisor_1; // rbx
  _DWORD *v4; // rdi

  Divisor_1 = Divisor; /*0x290f*/
  v4 = v2; /*0x2911*/
  if ( !Divisor ) /*0x2919*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\DivU64x32Remainder.c", 47, (__int64)"Divisor != 0"); /*0x292e*/
  if ( v4 ) /*0x2936*/
    *v4 = Dividend % Divisor_1; /*0x2940*/
  return Dividend / Divisor_1; /*0x2954*/
}


// Function: MmioWrite32 @ 0x295c (0x38 bytes)
// Index: 23/103

// local variable allocation has failed, the output may be wrong!
UINT32 __cdecl MmioWrite32(UINTN Address, UINT32 Value)
{
  char Value_1; // bl

  Value_1 = Value; /*0x2962*/
  if ( *(_QWORD *)&Value >= 0x40u ) /*0x2969*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\LShiftU64.c", 39, (__int64)"Count < 64"); /*0x297e*/
  return 1LL << Value_1; /*0x298e*/
}


// Function: CopyMemS @ 0x2994 (0x99 bytes)
// Index: 24/103

char *__fastcall CopyMemS(char *dst, char *src, unsigned __int64 count)
{
  char *dst_1; // rax
  unsigned __int64 v7; // rbp

  dst_1 = dst; /*0x29b1*/
  if ( count ) /*0x29b7*/
  {
    v7 = count - 1; /*0x29b9*/
    if ( count - 1 > ~(unsigned __int64)dst ) /*0x29c3*/
      Assert( /*0x29d8*/
        (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
        56,
        (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)DestinationBuffer)");
    if ( v7 > ~(unsigned __int64)src ) /*0x29e6*/
      Assert( /*0x29fb*/
        (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
        57,
        (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)SourceBuffer)");
    if ( dst == src ) /*0x2a03*/
      return dst; /*0x2a05*/
    else
      return CopyMemRaw(dst, src, count); /*0x2a13*/
  }
  return dst_1; /*0x2a27*/
}


// Function: ZeroMemS @ 0x2a30 (0x63 bytes)
// Index: 25/103

char *__fastcall ZeroMemS(char *buf, unsigned __int64 a2)
{
  if ( !buf ) /*0x2a43*/
    Assert( /*0x2a56*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
      53,
      (__int64)"Buffer != ((void *) 0)");
  if ( a2 > -(__int64)buf ) /*0x2a64*/
    Assert( /*0x2a79*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
      54,
      (__int64)"Length <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)Buffer + 1)");
  return ZeroMemRaw(buf, a2); /*0x2a89*/
}


// Function: GetDebugInfoPtr @ 0x2a94 (0x7f bytes)
// Index: 26/103

__int64 GetDebugInfoPtr()
{
  __int64 result; // rax
  unsigned __int64 n0x10; // rbx
  __int64 v2; // rax
  __int64 v3; // rcx

  result = qword_95F8; /*0x2a9e*/
  if ( !qword_95F8 ) /*0x2aaa*/
  {
    n0x10 = (*(__int64 (__fastcall **)(__int64))(BootServices_0 + 24))(31); /*0x2ac3*/
    (*(void (__fastcall **)(unsigned __int64))(BootServices_0 + 32))(n0x10); /*0x2ac6*/
    if ( n0x10 <= 0x10 ) /*0x2acd*/
    {
      v2 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_8B80, 0, &qword_95F8); /*0x2aea*/
      v3 = qword_95F8; /*0x2af0*/
      if ( v2 < 0 ) /*0x2afa*/
        v3 = 0; /*0x2afa*/
      qword_95F8 = v3; /*0x2afe*/
      return v3; /*0x2b05*/
    }
    else
    {
      return 0; /*0x2acf*/
    }
  }
  return result; /*0x2b0d*/
}


// Function: DebugPrint @ 0x2b14 (0x47 bytes)
// Index: 27/103

void DebugPrint(UINTN ErrorLevel, const CHAR8 *Format, ...)
{
  void (__fastcall **v3)(UINTN, const CHAR8 *, __int64 *); // r10
  va_list va; // [rsp+40h] [rbp+18h] BYREF

  va_start(va, Format);
  if ( GetDebugInfoPtr() ) /*0x2b2b*/
  {
    if ( ((unsigned int)GetCmosData() & (unsigned int)ErrorLevel) != 0 ) /*0x2b43*/
      (*v3)(ErrorLevel, Format, (__int64 *)va); /*0x2b52*/
  }
}


// Function: Assert @ 0x2b5c (0x3e bytes)
// Index: 28/103

__int64 __fastcall Assert(__int64 a1, __int64 a2, __int64 a3)
{
  __int64 result; // rax

  result = GetDebugInfoPtr(); /*0x2b74*/
  if ( result ) /*0x2b7c*/
    return (*(__int64 (__fastcall **)(__int64, __int64, __int64))(result + 8))(a1, a2, a3); /*0x2b87*/
  return result; /*0x2b94*/
}


// Function: DxeServicesTableLibInit @ 0x2b9c (0xc4 bytes)
// Index: 29/103

unsigned __int64 __fastcall DxeServicesTableLibInit(const UINT64 *Buffer, _QWORD *a2)
{
  __int64 SystemTable; // rdi
  __int64 v5; // rbx
  __int64 i; // r14

  if ( !Buffer ) /*0x2bbe*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 97, (__int64)"TableGuid != ((void *) 0)"); /*0x2bd1*/
  if ( !a2 ) /*0x2bd9*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 98, (__int64)"Table != ((void *) 0)"); /*0x2bec*/
  SystemTable = SystemTable_0; /*0x2bf1*/
  v5 = 0; /*0x2bf8*/
  *a2 = 0; /*0x2bfa*/
  if ( !*(_QWORD *)(SystemTable + 104) ) /*0x2bfe*/
    return 0x800000000000000EuLL; /*0x2c27*/
  for ( i = 0; !IsZeroGuid(Buffer, (const UINT64 *)(i + *(_QWORD *)(SystemTable + 112))); i += 24 ) /*0x2c04*/
  {
    if ( (unsigned __int64)++v5 >= *(_QWORD *)(SystemTable + 104) ) /*0x2c25*/
      return 0x800000000000000EuLL; /*0x2c25*/
  }
  *a2 = *(_QWORD *)(*(_QWORD *)(SystemTable + 112) + 24 * v5 + 16); /*0x2c5b*/
  return 0; /*0x2c45*/
}


// Function: DxeServicesGetMemoryMap @ 0x2c60 (0xf1 bytes)
// Index: 30/103

UINTN __fastcall DxeServicesGetMemoryMap(
        const CHAR16 *IntelGetNameSpaceData___IntelGetNameSpaceData__PassThru_(%r)_n,
        __int64 a2,
        unsigned __int16 **va)
{
  UINTN BufferSize; // rdx
  CHAR16 *Pool; // rdi
  UINTN v8; // rax
  UINTN v9; // rbx

  if ( !IntelGetNameSpaceData___IntelGetNameSpaceData__PassThru_(%r)_n ) /*0x2c88*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLibPrint.c", 67, (__int64)"Format != ((void *) 0)"); /*0x2c9b*/
  if ( ((unsigned __int8)IntelGetNameSpaceData___IntelGetNameSpaceData__PassThru_(%r)_n & 1) != 0 ) /*0x2ca3*/
    Assert( /*0x2cb8*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLibPrint.c",
      68,
      (__int64)"((UINTN) Format & 0x00000001) == 0");
  if ( !a2 ) /*0x2cc0*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLibPrint.c", 69, (__int64)"Console != ((void *) 0)"); /*0x2cd3*/
  Pool = (CHAR16 *)InternalAllocatePool((__int64)IntelGetNameSpaceData___IntelGetNameSpaceData__PassThru_(%r)_n, 642); /*0x2ce2*/
  if ( !Pool ) /*0x2ce8*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLibPrint.c", 74, (__int64)"Buffer != ((void *) 0)"); /*0x2cfb*/
  v8 = UnicodeSPrint(Pool, BufferSize, IntelGetNameSpaceData___IntelGetNameSpaceData__PassThru_(%r)_n, va); /*0x2d09*/
  v9 = v8; /*0x2d0e*/
  if ( a2 && v8 && (*(__int64 (__fastcall **)(__int64, CHAR16 *))(a2 + 8))(a2, Pool) < 0 ) /*0x2d27*/
    v9 = 0; /*0x2d27*/
  FreePool(Pool); /*0x2d2e*/
  return v9; /*0x2d4a*/
}


// Function: GetPciExpressBaseAddress @ 0x2d54 (0x30 bytes)
// Index: 31/103

UINTN GetPciExpressBaseAddress(const CHAR16 *IntelGetNameSpaceData___IntelGetNameSpaceData__PassThru_(%r)_n, ...)
{
  va_list va; // [rsp+38h] [rbp+10h] BYREF

  va_start(va, IntelGetNameSpaceData___IntelGetNameSpaceData__PassThru_(%r)_n);
  return DxeServicesGetMemoryMap( /*0x2d7f*/
           IntelGetNameSpaceData___IntelGetNameSpaceData__PassThru_(%r)_n,
           *(_QWORD *)(SystemTable_0 + 64),
           (unsigned __int16 **)va);
}


// Function: GetLpcBaseAddress @ 0x2d84 (0x30 bytes)
// Index: 32/103

__int64 GetLpcBaseAddress()
{
  _DWORD v1[6]; // [rsp+20h] [rbp-18h] BYREF

  v1[3] = 0; /*0x2d8b*/
  v1[1] = 0; /*0x2d93*/
  v1[2] = 512; /*0x2d97*/
  v1[0] = 1015808; /*0x2d9e*/
  return (*(__int64 (__fastcall **)(_DWORD *))(qword_9608 + 24))(v1); /*0x2daf*/
}


// Function: GetPciSegmentBaseAddress @ 0x2db4 (0x82 bytes)
// Index: 33/103

__int64 GetPciSegmentBaseAddress()
{
  __int64 result; // rax
  signed __int64 v1; // rax

  result = qword_9610; /*0x2db8*/
  if ( !qword_9610 ) /*0x2dc2*/
  {
    v1 = DxeServicesTableLibInit((__int64)&qword_8C50, &qword_9610); /*0x2dd2*/
    if ( v1 < 0 ) /*0x2dda*/
    {
      DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x2deb*/
      Assert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 54, (__int64)"!EFI_ERROR (Status)"); /*0x2e03*/
    }
    result = qword_9610; /*0x2e08*/
    if ( !qword_9610 ) /*0x2e12*/
    {
      Assert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 55, (__int64)"mHobList != ((void *) 0)"); /*0x2e25*/
      return qword_9610; /*0x2e2a*/
    }
  }
  return result; /*0x2e31*/
}


// Function: PciExpressLibAddress @ 0x2e38 (0x3a bytes)
// Index: 34/103

__int64 __fastcall PciExpressLibAddress(__int64 a1)
{
  if ( (a1 & 0xFFFFFFFFF0000000uLL) != 0 ) /*0x2e48*/
    Assert( /*0x2e5d*/
      (__int64)"e:\\hs\\MdePkg\\Library\\SmmPciExpressLib\\PciExpressLib.c",
      118,
      (__int64)"((Address) & ~0xfffffff) == 0");
  return a1 + qword_9618; /*0x2e6c*/
}


// Function: PciWrite16 @ 0x2e74 (0x158 bytes)
// Index: 35/103

UINT16 __cdecl PciWrite16(UINTN Address, UINT16 Value)
{
  __int64 v2; // r8
  EFI_HII_HANDLE HiiHandle; // rbp
  __int64 v4; // r15
  CHAR8 *SupportedLanguages; // rax
  CHAR8 *SupportedLanguages_1; // rdi
  UINT16 result; // ax
  __int64 v8; // rsi
  CHAR8 *SupportedLanguages_2; // rbx
  const CHAR8 *SupportedLanguages_3; // r14
  UINTN Length; // rax
  const CHAR8 *SecondString; // rdx
  __int64 v13; // rax
  UINT16 v14[8]; // [rsp+40h] [rbp-28h] BYREF

  HiiHandle = HiiHandle; /*0x2e91*/
  v14[0] = 0; /*0x2e9b*/
  v4 = v2; /*0x2ea0*/
  if ( !HiiHandle ) /*0x2ea6*/
    Assert((__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiString.c", 70, (__int64)"HiiHandle != ((void *) 0)"); /*0x2eb9*/
  if ( !v4 ) /*0x2ec1*/
    Assert((__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiString.c", 71, (__int64)"String != ((void *) 0)"); /*0x2ed5*/
  SupportedLanguages = HiiGetSupportedLanguages(HiiHandle); /*0x2edd*/
  SupportedLanguages_1 = SupportedLanguages; /*0x2ee2*/
  if ( !SupportedLanguages ) /*0x2ee8*/
    return 0; /*0x2eea*/
  v8 = 0x8000000000000002uLL; /*0x2ef3*/
  SupportedLanguages_2 = SupportedLanguages; /*0x2efd*/
  while ( *SupportedLanguages_2 )
  {
    SupportedLanguages_3 = SupportedLanguages_2; /*0x2f09*/
    if ( *SupportedLanguages_2 ) /*0x2f0c*/
    {
      do /*0x2f19*/
      {
        if ( *SupportedLanguages_2 == 59 ) /*0x2f14*/
          break; /*0x2f14*/
        ++SupportedLanguages_2; /*0x2f16*/
      }
      while ( *SupportedLanguages_2 ); /*0x2f19*/
      if ( *SupportedLanguages_2 ) /*0x2f1e*/
        *SupportedLanguages_2++ = 0; /*0x2f23*/
    }
    Length = AsciiStrLen("x-UEFI"); /*0x2f30*/
    if ( AsciiStrnCmp(SupportedLanguages_3, SecondString, Length) )
    {
      v13 = v14[0]
          ? (*(__int64 (__fastcall **)(__int64, EFI_HII_HANDLE, _QWORD, const CHAR8 *, __int64, _QWORD))(qword_9620 + 16))(
              qword_9620,
              HiiHandle,
              v14[0],
              SupportedLanguages_3,
              v4,
              0)
          : (*(__int64 (__fastcall **)(__int64, EFI_HII_HANDLE, UINT16 *, const CHAR8 *, _QWORD, __int64, _QWORD))qword_9620)(
              qword_9620,
              HiiHandle,
              v14,
              SupportedLanguages_3,
              0,
              v4,
              0);
      v8 = v13; /*0x2f86*/
      if ( v13 < 0 ) /*0x2f8c*/
        break; /*0x2f8c*/
    }
  }
  FreePool(SupportedLanguages_1); /*0x2f9a*/
  result = 0; /*0x2f9f*/
  if ( v8 >= 0 ) /*0x2fa6*/
    return v14[0]; /*0x2fa8*/
  return result; /*0x2fc2*/
}


// Function: HiiCreateOpCodeHandle @ 0x2fcc (0x4e bytes)
// Index: 36/103

_QWORD *__fastcall HiiCreateOpCodeHandle(__int64 a1)
{
  __int64 v1; // rcx
  _QWORD *Pool; // rbx
  __int64 v4; // rax

  Pool = (_QWORD *)InternalAllocatePool(a1, 24); /*0x2fdc*/
  if ( !Pool ) /*0x2fe2*/
    return 0; /*0x2fe2*/
  v4 = InternalAllocatePool(v1, 512); /*0x2fed*/
  *Pool = v4; /*0x2ff2*/
  if ( !v4 ) /*0x2ff8*/
  {
    FreePool(Pool); /*0x2ffd*/
    return 0; /*0x2fe6*/
  }
  Pool[2] = 0; /*0x3004*/
  Pool[1] = 512; /*0x300c*/
  return Pool; /*0x3014*/
}


// Function: HiiDestroyOpCodeHandle @ 0x301c (0x40 bytes)
// Index: 37/103

void __fastcall HiiDestroyOpCodeHandle(void **OpCodeHandle)
{
  if ( !OpCodeHandle ) /*0x3028*/
    Assert( /*0x303d*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLib.c",
      3054,
      (__int64)"OpCodeHandle != ((void *) 0)");
  if ( *OpCodeHandle ) /*0x3042*/
    FreePool(*OpCodeHandle); /*0x304a*/
  FreePool(OpCodeHandle); /*0x3057*/
}


// Function: HiiGrowBuffer @ 0x305c (0xa3 bytes)
// Index: 38/103

char *__fastcall HiiGrowBuffer(char **p_src, __int64 a2)
{
  char *count_1; // rdx
  char *count; // rcx
  char *v6; // rsi
  char *v7; // rcx
  char *result; // rax

  if ( !p_src ) /*0x3074*/
    Assert( /*0x3089*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLib.c",
      3114,
      (__int64)"OpCodeHandle != ((void *) 0)");
  count_1 = p_src[1]; /*0x3092*/
  count = &p_src[2][a2]; /*0x3096*/
  if ( count > count_1 ) /*0x309c*/
  {
    v6 = InternalReallocatePool((__int64)count, (unsigned __int64)count_1, (__int64)&count_1[a2 + 512], *p_src); /*0x30b0*/
    if ( !v6 ) /*0x30b6*/
      Assert((__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLib.c", 3123, (__int64)"Buffer != ((void *) 0)"); /*0x30cb*/
    *p_src = v6; /*0x30d7*/
    p_src[1] += a2 + 512; /*0x30da*/
  }
  v7 = p_src[2]; /*0x30de*/
  result = &(*p_src)[(_QWORD)v7]; /*0x30ea*/
  p_src[2] = &v7[a2]; /*0x30f0*/
  return result; /*0x30f9*/
}


// Function: HiiCreateOpCode @ 0x3100 (0xab bytes)
// Index: 39/103

char *__fastcall HiiCreateOpCode(char **OpCodeHandle, char *buf, char n95, unsigned __int64 n15, __int64 n3)
{
  char *dst; // rax

  if ( !buf ) /*0x3128*/
    Assert( /*0x313d*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLib.c",
      3158,
      (__int64)"OpCodeTemplate != ((void *) 0)");
  if ( n15 + n3 > 0x7F ) /*0x314f*/
    Assert( /*0x3164*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLib.c",
      3159,
      (__int64)"(OpCodeSize + ExtensionSize) <= 0x7F");
  *buf = n95; /*0x316c*/
  buf[1] = (n15 + n3) & 0x7F; /*0x3178*/
  dst = HiiGrowBuffer(OpCodeHandle, ((_BYTE)n15 + (_BYTE)n3) & 0x7F); /*0x317e*/
  return CopyMemS(dst, buf, n15); /*0x31a0*/
}


// Function: HiiCreateStringOpCode @ 0x31ac (0x47 bytes)
// Index: 40/103

UINT8 *__cdecl HiiCreateStringOpCode(
        void *OpCodeHandle,
        EFI_QUESTION_ID QuestionId,
        EFI_VARSTORE_ID VarStoreId,
        UINT16 VarOffset,
        EFI_STRING_ID Prompt,
        EFI_STRING_ID Help,
        UINT8 QuestionFlags,
        UINT8 StringFlags,
        UINT8 MinSize,
        UINT8 MaxSize,
        void *DefaultsOpCodeHandle)
{
  char buf[2]; // [rsp+30h] [rbp-28h] BYREF
  UINT64 Buffer[4]; // [rsp+32h] [rbp-26h] BYREF

  ZeroMemS(buf, 0x12u); /*0x31bf*/
  GetImageBase(Buffer); /*0x31c9*/
  return (UINT8 *)HiiCreateOpCode((char **)OpCodeHandle, buf, 95, 0x12u, 3); /*0x31ed*/
}


// Function: HiiCreateEndOpCode @ 0x31f4 (0x58 bytes)
// Index: 41/103

UINT8 *__cdecl HiiCreateEndOpCode(void *OpCodeHandle)
{
  __int16 v1; // dx
  __int16 v2; // bx
  char buf[2]; // [rsp+30h] [rbp-18h] BYREF
  __int16 v6; // [rsp+32h] [rbp-16h]
  __int16 n12; // [rsp+34h] [rbp-14h]
  char v8; // [rsp+36h] [rbp-12h]

  v2 = v1; /*0x31fe*/
  ZeroMemS(buf, 7u); /*0x320e*/
  v6 = v2; /*0x3223*/
  n12 = 12; /*0x322b*/
  v8 = 0; /*0x3233*/
  return (UINT8 *)HiiCreateOpCode((char **)OpCodeHandle, buf, 2, 7u, 0); /*0x3246*/
}


// Function: NvmeFindSubOpCode @ 0x324c (0x26b bytes)
// Index: 42/103

unsigned __int64 __fastcall NvmeFindSubOpCode(
        __int64 dst_,
        __int16 n2,
        char *src,
        char **OpCodeHandle,
        __int64 *OpCodeHandlea,
        char *dst)
{
  char *dst_1; // rbx
  unsigned __int64 n4; // rsi
  char *dst_2; // r15
  int n4_1; // ebp
  char v12; // bl
  char *src_1; // rdi
  bool v14; // r14
  __int64 v15; // rax
  char n93; // al
  char *p_n2; // rdx
  __int64 v19; // rax
  __int64 *OpCodeHandlea_1; // r14
  char *p_n2_1; // rbx
  __int64 v22; // rax
  int srca_1; // eax
  unsigned __int64 v24; // rcx
  __int64 v25; // rcx
  __int64 v26; // rbx
  char *v27; // rax
  char *dst_3; // r15
  int v29; // ebp
  __int64 v30; // rax
  unsigned __int64 v31; // rsi
  __int64 srca; // [rsp+60h] [rbp+8h] BYREF
  __int16 n2_1; // [rsp+68h] [rbp+10h] BYREF

  n2_1 = n2; /*0x3251*/
  srca = dst_; /*0x3256*/
  dst_1 = dst; /*0x326a*/
  n4 = 4; /*0x3275*/
  CopyMemS(dst, src, 4u); /*0x3286*/
  dst_2 = dst_1 + 4; /*0x3296*/
  n4_1 = 4; /*0x329a*/
  CopyMemS((char *)&srca, src, 4u); /*0x329c*/
  v12 = 0; /*0x32a1*/
  src_1 = src + 4; /*0x32a3*/
  v14 = 0; /*0x32a7*/
  while ( 1 ) /*0x32aa*/
  {
    if ( n4 >= ((unsigned int)srca & 0xFFFFFF) ) /*0x32b6*/
      return 0x800000000000000EuLL; /*0x32b6*/
    CopyMemS(dst_2, src_1, src_1[1] & 0x7F); /*0x32cb*/
    v15 = src_1[1] & 0x7F; /*0x32d4*/
    dst_2 += v15; /*0x32d7*/
    n4_1 += v15; /*0x32da*/
    n93 = *src_1; /*0x32dd*/
    if ( *src_1 == 14 ) /*0x32e1*/
      break; /*0x32e1*/
    if ( n93 == 1 || n93 == 93 ) /*0x3305*/
      v14 = CompareMemS(src_1 + 2, (char *)&n2_1, 2) == 0; /*0x331e*/
    if ( v12 ) /*0x3324*/
      goto LABEL_11; /*0x3324*/
LABEL_17:
    v19 = src_1[1] & 0x7F; /*0x3355*/
    n4 += v19; /*0x335c*/
    src_1 += v19; /*0x335f*/
  }
  if ( !IsZeroGuid((const UINT64 *)(src_1 + 2), &Buffer) ) /*0x32f5*/
  {
    v12 = 0; /*0x32fb*/
    goto LABEL_17; /*0x32fd*/
  }
  v12 = 1; /*0x32f7*/
LABEL_11:
  if ( !v14 ) /*0x3329*/
    goto LABEL_17; /*0x3329*/
  p_n2 = *OpCodeHandle; /*0x332b*/
  if ( (((unsigned __int8)src_1[1] ^ (unsigned __int8)(*OpCodeHandle)[1]) & 0x7F) != 0 ) /*0x3337*/
    goto LABEL_17; /*0x3337*/
  if ( (p_n2[1] & 0x7F) != 0 ? CompareMemS(src_1, p_n2, p_n2[1] & 0x7F) : 0LL )
    goto LABEL_17; /*0x3353*/
  OpCodeHandlea_1 = OpCodeHandlea; /*0x3367*/
  if ( OpCodeHandlea ) /*0x3372*/
  {
    p_n2_1 = (char *)*OpCodeHandlea; /*0x337d*/
    v22 = src_1[1] & 0x7F; /*0x3380*/
    n4 += v22; /*0x3383*/
    src_1 += v22; /*0x3386*/
    srca_1 = srca; /*0x3389*/
    while ( n4 < (srca_1 & 0xFFFFFFuLL) ) /*0x33da*/
    {
      if ( (((unsigned __int8)src_1[1] ^ (unsigned __int8)p_n2_1[1]) & 0x7F) == 0 ) /*0x3398*/
      {
        if ( (p_n2_1[1] & 0x7F) != 0 ) /*0x33a3*/
        {
          v24 = CompareMemS(src_1, p_n2_1, p_n2_1[1] & 0x7F); /*0x33b0*/
          srca_1 = srca; /*0x33b8*/
        }
        else
        {
          v24 = 0; /*0x33be*/
        }
        if ( !v24 ) /*0x33c3*/
          break; /*0x33c3*/
      }
      v25 = src_1[1] & 0x7F; /*0x33c9*/
      n4 += v25; /*0x33cc*/
      src_1 += v25; /*0x33cf*/
    }
    if ( n4 >= (srca_1 & 0xFFFFFFuLL) ) /*0x33e4*/
      return 0x800000000000000EuLL; /*0x3498*/
  }
  v26 = (*OpCodeHandle)[1] & 0x7F; /*0x33fa*/
  CopyMemS(dst_2, &(*OpCodeHandle)[v26], (unsigned __int64)&OpCodeHandle[2][-v26]); /*0x3404*/
  v27 = &OpCodeHandle[2][-v26]; /*0x340e*/
  dst_3 = &dst_2[(_QWORD)v27]; /*0x3411*/
  v29 = (_DWORD)v27 + n4_1; /*0x3414*/
  if ( OpCodeHandlea_1 ) /*0x341a*/
  {
    CopyMemS(dst_3, src_1, src_1[1] & 0x7F); /*0x342b*/
    v30 = src_1[1] & 0x7F; /*0x3434*/
    dst_3 += v30; /*0x3437*/
    v29 += v30; /*0x343a*/
  }
  v31 = (src_1[1] & 0x7F) + n4; /*0x344e*/
  CopyMemS(dst_3, &src[v31], (srca & 0xFFFFFF) - v31); /*0x345e*/
  LODWORD(srca) = (srca ^ ((srca & 0xFFFFFF) - v31 + v29)) & 0xFFFFFF ^ srca; /*0x348b*/
  CopyMemS(dst, (char *)&srca, 4u); /*0x348f*/
  return 0; /*0x34a7*/
}


// Function: NvmeProcessIfrOpCode @ 0x34b8 (0x279 bytes)
// Index: 43/103

__int64 __fastcall NvmeProcessIfrOpCode(
        __int64 dst_,
        __int64 a2,
        __int16 n2,
        char **OpCodeHandle,
        __int64 *OpCodeHandlea)
{
  EFI_HII_HANDLE HiiHandle; // r12
  char *src_1; // rsi
  char *ZeroPool_1; // rdi
  __int64 result; // rax
  __int64 Pool; // r14
  __int64 v11; // rbx
  unsigned int n20; // r13d
  char *dst_1; // rbx
  char **OpCodeHandle_2; // r12
  char v15; // di
  char *src; // r15
  __int64 dst__1; // rcx
  EFI_HII_HANDLE HiiHandle_2; // r12
  bool v19; // zf
  UINTN AllocationSize_1; // rbx
  _DWORD *v21; // r15
  UINT32 Unaligned32; // [rsp+30h] [rbp-28h]
  UINTN AllocationSize; // [rsp+38h] [rbp-20h] BYREF
  char *ZeroPool; // [rsp+40h] [rbp-18h]
  EFI_HII_HANDLE HiiHandle_1; // [rsp+48h] [rbp-10h]
  __int64 dst; // [rsp+A0h] [rbp+48h] BYREF
  __int64 v27; // [rsp+A8h] [rbp+50h]
  __int16 n2_1; // [rsp+B0h] [rbp+58h]
  char **OpCodeHandle_1; // [rsp+B8h] [rbp+60h]

  OpCodeHandle_1 = OpCodeHandle; /*0x34bb*/
  n2_1 = n2; /*0x34bf*/
  v27 = a2; /*0x34c4*/
  dst = dst_; /*0x34c8*/
  HiiHandle = HiiHandle; /*0x34df*/
  HiiHandle_1 = HiiHandle; /*0x34e9*/
  if ( !HiiHandle ) /*0x34f0*/
    Assert((__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLib.c", 4389, (__int64)"HiiHandle != ((void *) 0)"); /*0x3505*/
  if ( !OpCodeHandle ) /*0x350d*/
    Assert( /*0x3522*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLib.c",
      4390,
      (__int64)"StartOpCodeHandle != ((void *) 0)");
  src_1 = 0; /*0x3532*/
  AllocationSize = 0; /*0x3537*/
  ZeroPool_1 = 0; /*0x3541*/
  result = (*(__int64 (__fastcall **)(__int64, EFI_HII_HANDLE, UINTN *, _QWORD))(qword_9640 + 32))( /*0x3543*/
             qword_9640,
             HiiHandle,
             &AllocationSize,
             0);
  if ( result == 0x8000000000000005uLL ) /*0x3553*/
  {
    Pool = InternalAllocatePool(0x8000000000000005uLL, AllocationSize); /*0x3562*/
    if ( !Pool ) /*0x3568*/
      return 0x8000000000000009uLL; /*0x356a*/
    v11 = (*(__int64 (__fastcall **)(__int64, EFI_HII_HANDLE, UINTN *, __int64))(qword_9640 + 32))( /*0x3590*/
            qword_9640,
            HiiHandle,
            &AllocationSize,
            Pool);
    if ( v11 >= 0 ) /*0x3596*/
    {
      AllocationSize += (UINTN)OpCodeHandle[2]; /*0x35a4*/
      ZeroPool = (char *)AllocateZeroPool(AllocationSize); /*0x35ad*/
      ZeroPool_1 = ZeroPool; /*0x35b1*/
      if ( ZeroPool && (src_1 = (char *)AllocateZeroPool(AllocationSize)) != 0 ) /*0x35d7*/
      {
        n20 = 20; /*0x35d9*/
        CopyMemS(ZeroPool_1, (char *)Pool, 0x14u); /*0x35e8*/
        LOBYTE(v27) = 0; /*0x35f1*/
        dst_1 = ZeroPool_1 + 20; /*0x35f5*/
        Unaligned32 = ReadUnaligned32((const UINT32 *)(Pool + 16)); /*0x35fe*/
        if ( Unaligned32 <= 0x14 ) /*0x3604*/
          goto LABEL_22; /*0x3604*/
        OpCodeHandle_2 = OpCodeHandle_1; /*0x360a*/
        v15 = v27; /*0x360e*/
        do /*0x369b*/
        {
          src = (char *)(Pool + n20); /*0x3619*/
          CopyMemS((char *)&dst, src, 4u); /*0x3625*/
          n20 += *(_DWORD *)src & 0xFFFFFF; /*0x3632*/
          if ( src[3] == 2 /*0x365c*/
            && (NvmeFindSubOpCode(dst__1, n2_1, src, OpCodeHandle_2, OpCodeHandlea, src_1) & 0x8000000000000000uLL) == 0LL )
          {
            v15 = 1; /*0x365e*/
            src = src_1; /*0x3661*/
          }
          CopyMemS((char *)&dst, src, 4u); /*0x3671*/
          CopyMemS(dst_1, src, dst & 0xFFFFFF); /*0x3687*/
          dst_1 += dst & 0xFFFFFF; /*0x3694*/
        }
        while ( n20 < Unaligned32 ); /*0x369b*/
        HiiHandle_2 = HiiHandle_1; /*0x36a1*/
        v19 = v15 == 0; /*0x36a5*/
        ZeroPool_1 = ZeroPool; /*0x36a8*/
        if ( v19 ) /*0x36ac*/
        {
LABEL_22:
          v11 = 0x800000000000000EuLL; /*0x36f1*/
        }
        else
        {
          AllocationSize_1 = dst_1 - ZeroPool; /*0x36ae*/
          v21 = ZeroPool + 16; /*0x36b1*/
          AllocationSize = AllocationSize_1; /*0x36b5*/
          if ( ZeroPool == (char *)-16LL ) /*0x36bc*/
            Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 168, (__int64)"Buffer != ((void *) 0)"); /*0x36d1*/
          *v21 = AllocationSize_1; /*0x36d6*/
          v11 = (*(__int64 (__fastcall **)(__int64, EFI_HII_HANDLE, char *))(qword_9640 + 16))( /*0x36ec*/
                  qword_9640,
                  HiiHandle_2,
                  ZeroPool_1);
        }
      }
      else
      {
        v11 = 0x8000000000000009uLL; /*0x35b9*/
      }
    }
    FreePool((void *)Pool); /*0x36fe*/
    if ( ZeroPool_1 ) /*0x3706*/
      FreePool(ZeroPool_1); /*0x370b*/
    if ( src_1 ) /*0x3713*/
      FreePool(src_1); /*0x3718*/
    return v11; /*0x371d*/
  }
  return result; /*0x3720*/
}


// Function: HiiGetSupportedLanguages @ 0x3734 (0xa2 bytes)
// Index: 44/103

CHAR8 *__cdecl HiiGetSupportedLanguages(EFI_HII_HANDLE HiiHandle)
{
  void *ZeroPool; // rax
  void *ZeroPool_1; // rbx
  char v5; // [rsp+38h] [rbp+10h] BYREF
  UINTN AllocationSize; // [rsp+40h] [rbp+18h] BYREF

  if ( !HiiHandle ) /*0x3744*/
    Assert( /*0x3757*/
      (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLanguage.c",
      47,
      (__int64)"HiiHandle != ((void *) 0)");
  AllocationSize = 0; /*0x3768*/
  if ( (*(__int64 (__fastcall **)(__int64, EFI_HII_HANDLE, char *, UINTN *))(qword_9620 + 24))( /*0x3789*/
         qword_9620,
         HiiHandle,
         &v5,
         &AllocationSize) != 0x8000000000000005uLL )
    return 0; /*0x3789*/
  ZeroPool = AllocateZeroPool(AllocationSize); /*0x3794*/
  ZeroPool_1 = ZeroPool; /*0x3799*/
  if ( !ZeroPool ) /*0x379f*/
    return 0; /*0x379f*/
  if ( (*(__int64 (__fastcall **)(__int64, EFI_HII_HANDLE, void *, UINTN *))(qword_9620 + 24))( /*0x37bc*/
         qword_9620,
         HiiHandle,
         ZeroPool,
         &AllocationSize) < 0 )
  {
    FreePool(ZeroPool_1); /*0x37c1*/
    return 0; /*0x378d*/
  }
  return (CHAR8 *)ZeroPool_1; /*0x37d0*/
}


// Function: DebugPrintSerialWorker @ 0x37d8 (0xe1 bytes)
// Index: 45/103

__int64 DebugPrintSerialWorker()
{
  __int64 v1; // rcx
  unsigned __int64 n0x10; // rbx
  __int64 v3; // rax

  if ( byte_9650 ) /*0x37eb*/
  {
    if ( qword_9658 ) /*0x37f4*/
      return 0; /*0x37f8*/
    if ( !qword_9668 ) /*0x3807*/
      return 0x8000000000000003uLL; /*0x3807*/
    v1 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(qword_9668 + 208))(&unk_8BC0, 0, &qword_9658); /*0x382e*/
    if ( v1 < 0 ) /*0x3834*/
      qword_9658 = 0; /*0x3836*/
  }
  else
  {
    if ( qword_9670 ) /*0x3846*/
      return 0; /*0x3846*/
    if ( byte_9651 == 1 ) /*0x384f*/
      return 0x8000000000000003uLL; /*0x384f*/
    n0x10 = (*(__int64 (__fastcall **)(__int64))(BootServices + 24))(31); /*0x386a*/
    (*(void (__fastcall **)(unsigned __int64))(BootServices + 32))(n0x10); /*0x386d*/
    if ( n0x10 > 0x10 ) /*0x3874*/
      return 0x8000000000000003uLL; /*0x3813*/
    v1 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_8B80, 0, &qword_9670); /*0x3893*/
    v3 = qword_9670; /*0x3896*/
    if ( v1 < 0 ) /*0x38a0*/
      v3 = 0; /*0x38a0*/
    qword_9670 = v3; /*0x38a4*/
  }
  return v1; /*0x38b3*/
}


// Function: DebugPrintVarArg @ 0x38bc (0x8a bytes)
// Index: 46/103

__int64 DebugPrintVarArg(__int64 a1, char *HII_Extract_Config:_Guid_extraction_failed_n, ...)
{
  __int64 result; // rax
  __int64 (__fastcall **v4)(__int64, char *, __int64 *); // r9
  char v5; // r10
  char *HII_Extract_Config:_Guid_extraction_failed_n_1; // rdx
  __int64 v8; // [rsp+40h] [rbp+18h] BYREF
  va_list va; // [rsp+40h] [rbp+18h]
  __int64 v10; // [rsp+48h] [rbp+20h]
  va_list va1; // [rsp+50h] [rbp+28h] BYREF

  va_start(va1, HII_Extract_Config:_Guid_extraction_failed_n);
  va_start(va, HII_Extract_Config:_Guid_extraction_failed_n);
  v8 = va_arg(va1, _QWORD); /*0x38bc*/
  v10 = va_arg(va1, _QWORD); /*0x38bc*/
  result = DebugPrintSerialWorker(); /*0x38d3*/
  if ( result >= 0 ) /*0x38de*/
  {
    result = GetCmosData(); /*0x38f6*/
    if ( v4 ) /*0x38fe*/
    {
      if ( ((unsigned int)a1 & (unsigned int)result) != 0 ) /*0x3902*/
      {
        HII_Extract_Config:_Guid_extraction_failed_n_1 = HII_Extract_Config:_Guid_extraction_failed_n; /*0x3904*/
        if ( *HII_Extract_Config:_Guid_extraction_failed_n != v5 ) /*0x390c*/
        {
          do /*0x392e*/
          {
            if ( *HII_Extract_Config:_Guid_extraction_failed_n_1 == 37 ) /*0x3911*/
            {
              if ( *++HII_Extract_Config:_Guid_extraction_failed_n_1 == 115 ) /*0x3919*/
              {
                *HII_Extract_Config:_Guid_extraction_failed_n_1 = 97; /*0x391b*/
              }
              else if ( *HII_Extract_Config:_Guid_extraction_failed_n_1 == 71 ) /*0x3923*/
              {
                *HII_Extract_Config:_Guid_extraction_failed_n_1 = 103; /*0x3925*/
              }
            }
            ++HII_Extract_Config:_Guid_extraction_failed_n_1; /*0x3928*/
          }
          while ( *HII_Extract_Config:_Guid_extraction_failed_n_1 != v5 ); /*0x392e*/
          HII_Extract_Config:_Guid_extraction_failed_n_1 = HII_Extract_Config:_Guid_extraction_failed_n; /*0x3930*/
        }
        return (*v4)(a1, HII_Extract_Config:_Guid_extraction_failed_n_1, (__int64 *)va); /*0x393d*/
      }
    }
  }
  return result; /*0x3940*/
}


// Function: AllocatePool @ 0x3948 (0x2b bytes)
// Index: 47/103

void *__cdecl AllocatePool(UINTN AllocationSize)
{
  void *v2; // [rsp+38h] [rbp+10h] BYREF

  v2 = 0; /*0x3958*/
  (*(void (__fastcall **)(__int64, UINTN, void **))(BootServices + 64))(4, AllocationSize, &v2); /*0x3966*/
  return v2; /*0x396e*/
}


// Function: AllocateCopyPool @ 0x3974 (0x3e bytes)
// Index: 48/103

void *__cdecl AllocateCopyPool(UINTN AllocationSize, const void *Buffer)
{
  void *result; // rax
  void *v4; // rbx

  result = AllocatePool(AllocationSize); /*0x3981*/
  v4 = result; /*0x3986*/
  if ( result ) /*0x398c*/
  {
    (*(void (__fastcall **)(void *, UINTN, _QWORD))(BootServices + 360))(result, AllocationSize, 0); /*0x399e*/
    return v4; /*0x39a4*/
  }
  return result; /*0x39ac*/
}


// Function: InternalVarArgList @ 0x39b4 (0x52 bytes)
// Index: 49/103

__int64 __fastcall InternalVarArgList(_BYTE *src)
{
  _BYTE *src_1; // rdx
  __int64 v3; // r8
  __int64 v4; // r10

  src_1 = src; /*0x39b4*/
  if ( !src ) /*0x39ba*/
    return 0; /*0x39bc*/
  v3 = 0; /*0x39bf*/
  while ( 1 ) /*0x39c2*/
  {
    if ( *src_1 == 127 && src_1[1] == 0xFF ) /*0x39cb*/
      return v3 + 4; /*0x3a01*/
    v4 = (unsigned __int8)src_1[2]; /*0x39d2*/
    if ( !*src_1 || !((_DWORD)v4 + ((unsigned __int8)src_1[3] << 8)) ) /*0x39dd*/
      break; /*0x39dd*/
    v3 += (unsigned int)v4 + ((unsigned __int8)src_1[3] << 8); /*0x39eb*/
    src_1 += 256 * (unsigned __int64)(unsigned __int8)src_1[3] + v4; /*0x39f8*/
  }
  return v3; /*0x39be*/
}


// Function: VarArgListToBuffer @ 0x3a08 (0xd5 bytes)
// Index: 50/103

char *__fastcall VarArgListToBuffer(char *src, __int64 src_2)
{
  char *src_1; // rdi
  unsigned __int64 n8; // rbx
  char *Pool; // rax
  char *Pool_1; // r14
  char *Pool_2; // r15

  src_1 = src; /*0x3a24*/
  if ( src_2 ) /*0x3a2a*/
  {
    if ( src ) /*0x3a45*/
      n8 = InternalVarArgList(src) - 4; /*0x3a4c*/
    else
      n8 = 0; /*0x3a52*/
    Pool = (char *)AllocatePool( /*0x3a6a*/
                     n8
                   + ((unsigned __int64)*(unsigned __int8 *)(src_2 + 3) << 8)
                   + *(unsigned __int8 *)(src_2 + 2)
                   + 4LL);
    Pool_1 = Pool; /*0x3a6f*/
    Pool_2 = Pool; /*0x3a72*/
    if ( n8 ) /*0x3a78*/
    {
      CopyMemWithAsm(Pool, src_1, n8); /*0x3a83*/
      Pool_2 += n8; /*0x3a88*/
    }
    CopyMemWithAsm( /*0x3aa2*/
      Pool_2,
      (char *)src_2,
      *(unsigned __int8 *)(src_2 + 2) + ((unsigned __int64)*(unsigned __int8 *)(src_2 + 3) << 8));
    *(_DWORD *)&Pool_2[256 * (unsigned __int64)*(unsigned __int8 *)(src_2 + 3) + *(unsigned __int8 *)(src_2 + 2)] = dword_8D28; /*0x3abc*/
    return Pool_1; /*0x3abf*/
  }
  else
  {
    if ( !src ) /*0x3a2f*/
      src = (char *)&dword_8D28; /*0x3a31*/
    return VarArgCopy(src); /*0x3a38*/
  }
}


// Function: VarArgCopy @ 0x3ae0 (0x46 bytes)
// Index: 51/103

char *__fastcall VarArgCopy(char *src)
{
  UINTN AllocationSize; // rbx
  char *Pool; // rdi

  AllocationSize = InternalVarArgList(src); /*0x3afa*/
  Pool = (char *)AllocatePool(AllocationSize); /*0x3b0b*/
  CopyMemWithAsm(Pool, src, AllocationSize); /*0x3b0e*/
  return Pool; /*0x3b20*/
}


// Function: InternalGetVariable @ 0x3b28 (0xbe bytes)
// Index: 52/103

__int64 __fastcall InternalGetVariable(__int64 a1, _BYTE *n4, unsigned int *p_n3, UINTN *p_n32, __int64 *a5)
{
  __int64 result; // rax
  void *Pool; // rax

  if ( !*a5 ) /*0x3b52*/
    *p_n32 = 0; /*0x3b58*/
  result = (*(__int64 (__fastcall **)(__int64))(RuntimeServices + 72))(a1); /*0x3b6b*/
  if ( result == 0x8000000000000005uLL ) /*0x3b71*/
  {
    if ( *a5 ) /*0x3b82*/
      (*(void (**)(void))(BootServices + 72))(); /*0x3b91*/
    Pool = AllocatePool(*p_n32); /*0x3b97*/
    *a5 = (__int64)Pool; /*0x3b9c*/
    if ( Pool ) /*0x3ba2*/
      return (*(__int64 (__fastcall **)(__int64, _BYTE *, unsigned int *, UINTN *, void *))(RuntimeServices + 72))( /*0x3bc8*/
               a1,
               n4,
               p_n3,
               p_n32,
               Pool);
    else
      return 0x8000000000000009uLL; /*0x3ba4*/
  }
  return result; /*0x3bdf*/
}


// Function: UnicodeToHex @ 0x3be8 (0x1a9 bytes)
// Index: 53/103

__int64 __fastcall UnicodeToHex(__int64 a1, unsigned __int64 *p_n32, __int64 a3)
{
  _WORD *v4; // r10
  unsigned __int64 i; // r9
  __int16 v7; // cx
  __int16 v8; // cx
  __int16 v9; // cx
  __int16 v10; // cx
  char v11; // cl
  char v12; // cl
  __int16 v13; // dx
  char v14; // cl
  unsigned __int8 v15; // cl
  __int16 v16; // r8
  char v17; // cl
  unsigned __int8 v18; // cl
  __int16 v19; // dx
  char v20; // cl
  unsigned __int8 v21; // cl

  v4 = (_WORD *)(a1 + 4); /*0x3bf0*/
  for ( i = 0; ; ++i ) /*0x3bf9*/
  {
    v7 = *(v4 - 2); /*0x3bfc*/
    if ( (unsigned __int16)(v7 - 48) > 0x36u ) /*0x3c08*/
      break; /*0x3c08*/
    if ( (unsigned __int16)(v7 - 58) <= 6u ) /*0x3c15*/
      break; /*0x3c15*/
    if ( (unsigned __int16)(v7 - 71) <= 0x19u ) /*0x3c23*/
      break; /*0x3c23*/
    v8 = *(v4 - 1); /*0x3c29*/
    if ( (unsigned __int16)(v8 - 48) > 0x36u ) /*0x3c35*/
      break; /*0x3c35*/
    if ( (unsigned __int16)(v8 - 58) <= 6u ) /*0x3c42*/
      break; /*0x3c42*/
    if ( (unsigned __int16)(v8 - 71) <= 0x19u ) /*0x3c50*/
      break; /*0x3c50*/
    v9 = *v4; /*0x3c56*/
    if ( (unsigned __int16)(*v4 - 48) > 0x36u ) /*0x3c61*/
      break; /*0x3c61*/
    if ( (unsigned __int16)(v9 - 58) <= 6u ) /*0x3c6e*/
      break; /*0x3c6e*/
    if ( (unsigned __int16)(v9 - 71) <= 0x19u ) /*0x3c7c*/
      break; /*0x3c7c*/
    v10 = v4[1]; /*0x3c82*/
    if ( (unsigned __int16)(v10 - 48) > 0x36u /*0x3cb8*/
      || (unsigned __int16)(v10 - 58) <= 6u
      || (unsigned __int16)(v10 - 71) <= 0x19u
      || i >= *p_n32 - 1 )
    {
      break; /*0x3cb8*/
    }
    v11 = *((_BYTE *)v4 - 4); /*0x3cbe*/
    if ( (unsigned __int8)(v11 - 48) > 9u ) /*0x3cc7*/
    {
      if ( (unsigned __int8)(v11 - 65) > 5u ) /*0x3cd3*/
        v12 = v11 - 87; /*0x3cda*/
      else
        v12 = v11 - 55; /*0x3cd5*/
    }
    else
    {
      v12 = v11 - 48; /*0x3cc9*/
    }
    v13 = 16 * (v12 & 0xF); /*0x3ce3*/
    *(_WORD *)(a3 + 2 * i) = v13; /*0x3ce7*/
    v14 = *((_BYTE *)v4 - 2); /*0x3cec*/
    if ( (unsigned __int8)(v14 - 48) > 9u ) /*0x3cf5*/
    {
      if ( (unsigned __int8)(v14 - 65) > 5u ) /*0x3d01*/
        v15 = v14 - 87; /*0x3d08*/
      else
        v15 = v14 - 55; /*0x3d03*/
    }
    else
    {
      v15 = v14 - 48; /*0x3cf7*/
    }
    v16 = 16 * (v13 | v15); /*0x3d13*/
    *(_WORD *)(a3 + 2 * i) = v16; /*0x3d18*/
    v17 = *(_BYTE *)v4; /*0x3d1d*/
    if ( (unsigned __int8)(*(_BYTE *)v4 - 48) > 9u ) /*0x3d25*/
    {
      if ( (unsigned __int8)(v17 - 65) > 5u ) /*0x3d31*/
        v18 = v17 - 87; /*0x3d38*/
      else
        v18 = v17 - 55; /*0x3d33*/
    }
    else
    {
      v18 = v17 - 48; /*0x3d27*/
    }
    v19 = 16 * (v16 | v18); /*0x3d42*/
    *(_WORD *)(a3 + 2 * i) = v19; /*0x3d46*/
    v20 = *((_BYTE *)v4 + 2); /*0x3d4b*/
    if ( (unsigned __int8)(v20 - 48) > 9u ) /*0x3d54*/
    {
      if ( (unsigned __int8)(v20 - 65) > 5u ) /*0x3d60*/
        v21 = v20 - 87; /*0x3d67*/
      else
        v21 = v20 - 55; /*0x3d62*/
    }
    else
    {
      v21 = v20 - 48; /*0x3d56*/
    }
    v4 += 4; /*0x3d6d*/
    *(_WORD *)(a3 + 2 * i) = v19 | v21; /*0x3d74*/
  }
  *p_n32 = i; /*0x3d81*/
  *(_WORD *)(a3 + 2 * i) = 0; /*0x3d8b*/
  return 0; /*0x3d90*/
}


// Function: HexStringToBytes @ 0x3d94 (0x7d bytes)
// Index: 54/103

__int64 __fastcall HexStringToBytes(__int64 a1, unsigned __int64 n32, _BYTE *n4)
{
  unsigned __int64 n32_1; // r9
  __int64 v5; // r11
  __int64 n32_2; // rbx
  char v7; // dl
  char v8; // dl
  __int64 result; // rax
  char v10; // cl

  n32_1 = 0; /*0x3d99*/
  v5 = a1; /*0x3d9f*/
  if ( n32 ) /*0x3da5*/
  {
    n32_2 = n32 - 1; /*0x3da7*/
    do /*0x3e09*/
    {
      if ( n32_1 == n32_2 ) /*0x3dae*/
      {
        LOBYTE(a1) = *(_BYTE *)(v5 + 2 * n32_1); /*0x3db0*/
        v7 = 0; /*0x3db4*/
      }
      else
      {
        v8 = *(_BYTE *)(v5 + 2 * n32_1); /*0x3db8*/
        if ( (unsigned __int8)(v8 - 48) > 9u ) /*0x3dc1*/
        {
          if ( (unsigned __int8)(v8 - 65) > 5u ) /*0x3dcd*/
            v7 = v8 - 87; /*0x3dd4*/
          else
            v7 = v8 - 55; /*0x3dcf*/
        }
        else
        {
          v7 = v8 - 48; /*0x3dc3*/
        }
        LOBYTE(a1) = *(_BYTE *)(v5 + 2 * n32_1 + 2); /*0x3dd7*/
      }
      result = (unsigned int)(a1 - 48); /*0x3ddc*/
      if ( (unsigned __int8)(a1 - 48) > 9u ) /*0x3de1*/
      {
        result = (unsigned int)(a1 - 65); /*0x3de8*/
        if ( (unsigned __int8)(a1 - 65) > 5u ) /*0x3ded*/
          v10 = a1 - 87; /*0x3df4*/
        else
          v10 = a1 - 55; /*0x3def*/
      }
      else
      {
        v10 = a1 - 48; /*0x3de3*/
      }
      n32_1 += 2LL; /*0x3dfa*/
      *n4++ = v10 | (16 * v7); /*0x3e00*/
    }
    while ( n32_1 < n32 ); /*0x3e09*/
  }
  return result; /*0x3e10*/
}


// Function: ExtractPathFromString @ 0x3e14 (0x165 bytes)
// Index: 55/103

__int64 __fastcall ExtractPathFromString(__int16 *FirstString, __int64 a2)
{
  __int64 v3; // rbx
  __int16 *FirstString_1; // rsi
  __int16 i; // ax
  __int16 *v7; // rdi
  unsigned __int64 n32; // rsi
  __int16 *j; // rdx
  __int16 v10; // cx
  _BYTE *n4_1; // rbx
  __int64 result; // rax
  _BYTE *n4_2; // rcx
  __int64 v14; // rax
  unsigned __int64 v15; // rbx
  _BYTE *n4; // [rsp+40h] [rbp+8h] BYREF
  _BYTE *n4_3; // [rsp+50h] [rbp+18h] BYREF

  v3 = 0; /*0x3e2c*/
  n4 = 0; /*0x3e2f*/
  FirstString_1 = FirstString; /*0x3e37*/
  do /*0x3e73*/
  {
    for ( i = *FirstString_1; i != 38 && i; i = FirstString[v3] ) /*0x3e3a*/
      ++v3; /*0x3e44*/
    if ( !FirstString[v3] ) /*0x3e56*/
      return 0x800000000000000EuLL; /*0x3f5c*/
    FirstString_1 = &FirstString[++v3]; /*0x3e6c*/
  }
  while ( StrnCmp((const CHAR16 *)FirstString_1, (const CHAR16 *)L"PATH=", 0xAu) ); /*0x3e73*/
  v7 = &FirstString[v3]; /*0x3e7d*/
  n32 = 0; /*0x3e81*/
  for ( j = v7 + 5; ; ++j ) /*0x3e84*/
  {
    v10 = *j; /*0x3e88*/
    if ( (unsigned __int16)(*j - 48) > 0x36u /*0x3ea5*/
      || (unsigned __int16)(v10 - 58) <= 6u
      || (unsigned __int16)(v10 - 71) <= 0x19u )
    {
      break; /*0x3ea5*/
    }
    ++n32; /*0x3ea7*/
  }
  n4_1 = (_BYTE *)(n32 >> 1); /*0x3ec4*/
  result = (*(__int64 (__fastcall **)(__int64, unsigned __int64, _BYTE **))(BootServices + 64))(4, n32 >> 1, &n4); /*0x3eca*/
  if ( result >= 0 ) /*0x3ed0*/
  {
    HexStringToBytes((__int64)(v7 + 5), n32, n4); /*0x3ee5*/
    result = 0; /*0x3eea*/
  }
  else
  {
    n4_1 = n4; /*0x3ed2*/
  }
  if ( result >= 0 ) /*0x3ef0*/
  {
    n4_2 = n4; /*0x3ef2*/
    if ( n4 /*0x3f16*/
      && (unsigned __int64)n4_1 >= 4
      && *((unsigned __int16 *)n4 + 1) <= (unsigned __int64)n4_1
      && ((unsigned __int8)(*n4 - 1) <= 4u || *n4 == 127) )
    {
      n4_3 = n4; /*0x3f24*/
      v14 = (*(__int64 (__fastcall **)(void *, _BYTE **, __int64))(BootServices + 184))(&unk_8DD0, &n4_3, a2); /*0x3f33*/
      n4_2 = n4; /*0x3f39*/
      v15 = v14; /*0x3f3e*/
    }
    else
    {
      v15 = 0x800000000000000EuLL; /*0x3f43*/
    }
    (*(void (__fastcall **)(_BYTE *))(BootServices + 72))(n4_2); /*0x3f54*/
    return v15; /*0x3f57*/
  }
  return result; /*0x3f70*/
}


// Function: NvmeExtractConfig @ 0x3f7c (0x2c1 bytes)
// Index: 56/103

__int64 __fastcall NvmeExtractConfig(__int64 a1, __int64 FirstString, __int64 *a3, __int64 a4)
{
  __int64 result; // rax
  __int64 v8; // rbx
  UINTN AllocationSize; // rbx
  const void *Buffer; // rdx
  CHAR16 *CopyPool; // rax
  const CHAR16 *CopyPool_1; // r14
  UINTN v13; // rax
  const void *Buffer_1; // rdx
  CHAR16 *Destination; // rax
  CHAR16 *Destination_1; // r12
  __int64 v17; // rbx
  __int64 v18; // r15
  UINTN v19; // rax
  __int64 BootServices; // rdx
  __int64 v21; // [rsp+30h] [rbp-89h] BYREF
  __int64 v22; // [rsp+38h] [rbp-81h] BYREF
  _BYTE n4[16]; // [rsp+40h] [rbp-79h] BYREF
  _BYTE v24[160]; // [rsp+50h] [rbp-69h] BYREF
  BASE_LIST Marker; // [rsp+128h] [rbp+6Fh] BYREF

  v21 = 0; /*0x3fa5*/
  if ( !FirstString ) /*0x3fb3*/
  {
    *a3 = 0; /*0x3fb5*/
    return 0x8000000000000002uLL; /*0x3fc2*/
  }
  result = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_8D80, 0, &v22); /*0x3fdc*/
  if ( result >= 0 )
  {
    if ( StrnCmp((const CHAR16 *)FirstString, (const CHAR16 *)L"GUID=", 0xAu) ) /*0x3ffe*/
    {
LABEL_6:
      *a3 = FirstString; /*0x4008*/
      return 0x8000000000000002uLL; /*0x400b*/
    }
    Marker = (_QWORD *)(word_1C + 4); /*0x4019*/
    HexStringToBytes(FirstString + 10, 0x20u, n4); /*0x4021*/
    v8 = FirstString + 74; /*0x4026*/
    if ( *(_WORD *)(FirstString + 74) != 38 )
    {
      DebugPrintVarArg(0x80000000LL, "HII Extract Config: Guid extraction failed\n");
      goto LABEL_6; /*0x4046*/
    }
    if ( StrnCmp((const CHAR16 *)(FirstString + 76), (const CHAR16 *)L"NAME=", 0xAu) ) /*0x4056*/
    {
LABEL_10:
      *a3 = v8; /*0x4060*/
      return 0x8000000000000002uLL; /*0x4063*/
    }
    Marker = (_QWORD *)(byte_40 + 16); /*0x406b*/
    UnicodeToHex(FirstString + 86, (unsigned __int64 *)&Marker, (__int64)v24); /*0x4082*/
    v8 = FirstString + 86 + 8LL * (_QWORD)Marker; /*0x408b*/
    if ( *(_WORD *)v8 != 38 )
    {
      DebugPrintVarArg(0x80000000LL, "HII Extract Config: Name extraction failed\n");
      *a3 = FirstString + 74; /*0x40a6*/
      return 0x8000000000000002uLL; /*0x40a9*/
    }
    Marker = 0; /*0x40b3*/
    result = InternalGetVariable((__int64)v24, n4, 0, (UINTN *)&Marker, &v21); /*0x40cb*/
    if ( result >= 0 ) /*0x40d3*/
    {
      while ( 1 ) /*0x40e2*/
      {
        v8 += 2; /*0x40e2*/
        if ( *(_WORD *)v8 == 38 ) /*0x40ed*/
          break; /*0x40ed*/
        if ( !*(_WORD *)v8 ) /*0x40e0*/
        {
          AllocationSize = 2 * StrLen(L"&OFFSET=0&WIDTH=") + 18; /*0x4105*/
          CopyPool = (CHAR16 *)AllocateCopyPool(AllocationSize, Buffer); /*0x4110*/
          CopyPool_1 = CopyPool; /*0x4115*/
          if ( !CopyPool ) /*0x411b*/
            return 0x8000000000000009uLL; /*0x411b*/
          UnicodeBSPrint(CopyPool, AllocationSize, L"&OFFSET=0&WIDTH=%x", Marker); /*0x413d*/
          v13 = StrLen((const CHAR16 *)FirstString); /*0x4145*/
          Destination = (CHAR16 *)AllocateCopyPool(AllocationSize + 2 * (v13 + 1), Buffer_1); /*0x4151*/
          Destination_1 = Destination; /*0x4156*/
          if ( !Destination ) /*0x415c*/
            return 0x8000000000000009uLL; /*0x4127*/
          StrCat(Destination, (const CHAR16 *)FirstString); /*0x4164*/
          StrCat(Destination_1, CopyPool_1); /*0x416f*/
          v17 = v21; /*0x417c*/
          v18 = (*(__int64 (__fastcall **)(__int64, CHAR16 *, __int64, BASE_LIST, __int64, __int64 *))(v22 + 24))( /*0x419b*/
                  v22,
                  Destination_1,
                  v21,
                  Marker,
                  a4,
                  a3);
          v19 = StrLen((const CHAR16 *)FirstString); /*0x419e*/
          BootServices = BootServices; /*0x41a3*/
          *a3 = FirstString + 2 * v19; /*0x41ae*/
          (*(void (__fastcall **)(const CHAR16 *))(BootServices + 72))(CopyPool_1); /*0x41b4*/
          (*(void (__fastcall **)(CHAR16 *))(BootServices + 72))(Destination_1); /*0x41c1*/
          goto LABEL_24; /*0x41c4*/
        }
      }
      if ( StrnCmp((const CHAR16 *)(v8 + 2), (const CHAR16 *)L"OFFSET=", 0xEu) ) /*0x41d7*/
        goto LABEL_10; /*0x41df*/
      v17 = v21; /*0x41ed*/
      v18 = (*(__int64 (__fastcall **)(__int64, __int64, __int64, BASE_LIST, __int64, __int64 *))(v22 + 24))( /*0x4209*/
              v22,
              FirstString,
              v21,
              Marker,
              a4,
              a3);
LABEL_24:
      (*(void (__fastcall **)(__int64))(BootServices + 72))(v17); /*0x420c*/
      return v18; /*0x4219*/
    }
    else
    {
      *a3 = FirstString; /*0x40d5*/
    }
  }
  return result; /*0x4230*/
}


// Function: NvmeRouteConfig @ 0x4240 (0x26a bytes)
// Index: 57/103

__int64 __fastcall NvmeRouteConfig(__int64 a1, __int64 FirstString, _QWORD *a3)
{
  __int64 result; // rax
  _WORD *v6; // rbx
  __int64 v7; // r8
  unsigned __int64 n32_1; // r14
  __int64 v9; // [rsp+30h] [rbp-89h] BYREF
  __int64 v10; // [rsp+38h] [rbp-81h] BYREF
  _BYTE n4[16]; // [rsp+40h] [rbp-79h] BYREF
  __int64 v12[2]; // [rsp+50h] [rbp-69h] BYREF
  _BYTE v13[160]; // [rsp+60h] [rbp-59h] BYREF
  unsigned int n3; // [rsp+128h] [rbp+6Fh] BYREF
  unsigned __int64 n32; // [rsp+138h] [rbp+7Fh] BYREF

  v9 = 0; /*0x425a*/
  if ( !FirstString ) /*0x4269*/
  {
    *a3 = 0; /*0x426b*/
    return 0x8000000000000002uLL; /*0x4278*/
  }
  result = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_8D80, 0, &v10); /*0x4292*/
  if ( result < 0 ) /*0x429b*/
    return result; /*0x429b*/
  if ( StrnCmp((const CHAR16 *)FirstString, (const CHAR16 *)L"GUID=", 0xAu) ) /*0x42b4*/
  {
    *a3 = FirstString; /*0x42be*/
    return 0x8000000000000002uLL; /*0x42c1*/
  }
  if ( ExtractPathFromString((__int16 *)FirstString, (__int64)v12) < 0 ) /*0x42d2*/
    return 0x800000000000000EuLL; /*0x42de*/
  n32 = 32; /*0x42ef*/
  HexStringToBytes(FirstString + 10, 0x20u, n4); /*0x42f7*/
  v6 = (_WORD *)(FirstString + 74); /*0x42fc*/
  if ( *(_WORD *)(FirstString + 74) != 38 )
  {
    DebugPrintVarArg(0x80000000LL, "HII Route Config: Guid extraction failed\n");
LABEL_11:
    *a3 = v6; /*0x4317*/
    return 0x8000000000000002uLL; /*0x431a*/
  }
  if ( StrnCmp((const CHAR16 *)(FirstString + 76), (const CHAR16 *)L"NAME=", 0xAu) ) /*0x432d*/
    goto LABEL_11; /*0x4335*/
  n32 = 80; /*0x433b*/
  UnicodeToHex(FirstString + 86, &n32, (__int64)v13); /*0x434e*/
  v6 = (_WORD *)(FirstString + 86 + 8 * n32); /*0x4357*/
  if ( *v6 != 38 )
  {
    DebugPrintVarArg(0x80000000LL, "HII Route Config: Name extraction failed\n");
    goto LABEL_11; /*0x4368*/
  }
  n32 = 0; /*0x436a*/
  if ( InternalGetVariable((__int64)v13, n4, &n3, &n32, &v9) >= 0 ) /*0x4391*/
  {
    v7 = v9; /*0x43bf*/
    n32_1 = n32; /*0x43c4*/
  }
  else
  {
    if ( v9 ) /*0x439b*/
      (*(void (**)(void))(BootServices + 72))(); /*0x43a4*/
    v7 = 0; /*0x43a7*/
    n3 = 3; /*0x43aa*/
    n32_1 = 0; /*0x43b1*/
    v9 = 0; /*0x43b4*/
    n32 = 0; /*0x43b9*/
  }
  for ( result = (*(__int64 (__fastcall **)(__int64, __int64, __int64, unsigned __int64 *, _QWORD *))(v10 + 32))( /*0x43dc*/
                   v10,
                   FirstString,
                   v7,
                   &n32,
                   a3);
        ;
        result = (*(__int64 (__fastcall **)(__int64, __int64, __int64, unsigned __int64 *, _QWORD *))(v10 + 32))(
                   v10,
                   FirstString,
                   v9,
                   &n32,
                   a3) )
  {
    if ( result == 0x8000000000000007uLL ) /*0x43fb*/
      goto LABEL_24; /*0x43fb*/
    if ( result != 0x8000000000000002uLL ) /*0x4400*/
      break; /*0x4400*/
    if ( v9 ) /*0x4405*/
      return result; /*0x4405*/
LABEL_24:
    if ( v9 ) /*0x440e*/
      (*(void (__fastcall **)(__int64))(BootServices + 72))(v9); /*0x4417*/
    result = (*(__int64 (__fastcall **)(__int64, unsigned __int64, __int64 *))(BootServices + 64))(4, n32, &v9); /*0x442f*/
    if ( result < 0 ) /*0x4435*/
      return result; /*0x4435*/
    n32_1 = n32; /*0x4448*/
  }
  if ( result >= 0 ) /*0x445c*/
  {
    (*(void (__fastcall **)(_BYTE *, _BYTE *, _QWORD, unsigned __int64, __int64))(RuntimeServices + 88))( /*0x447e*/
      v13,
      n4,
      n3,
      n32_1,
      v9);
    (*(void (__fastcall **)(__int64))(BootServices + 72))(v9); /*0x448d*/
    return 0; /*0x4490*/
  }
  return result; /*0x44a2*/
}


// Function: NvmeCallback @ 0x44ac (0xb bytes)
// Index: 58/103

// (too small: 0xb bytes)


// Function: NvmeConfigAccessInit @ 0x44b8 (0x1af bytes)
// Index: 59/103

__int64 NvmeConfigAccessInit(__int64 a1, __int64 a2, __int64 a3, ...)
{
  __int64 v3; // rdi
  const CHAR16 **p_SecondString; // rbx
  __int64 **v7; // rdi
  __int64 *v8; // rax
  __int64 *v9; // rax
  __int64 *v10; // rax
  __int64 v11; // rax
  char *src; // rcx
  __int64 src_1; // rdx
  char *src_2; // rax
  __int128 v15; // xmm0
  char *v16; // rbx
  __int64 result; // rax
  __int64 v18; // [rsp+70h] [rbp+18h] BYREF
  char *src_3; // [rsp+78h] [rbp+20h] BYREF
  va_list va; // [rsp+78h] [rbp+20h]
  __int64 ***v21; // [rsp+80h] [rbp+28h]
  _QWORD *v22; // [rsp+88h] [rbp+30h]
  va_list va1; // [rsp+90h] [rbp+38h] BYREF

  va_start(va1, a3);
  va_start(va, a3);
  src_3 = va_arg(va1, char *); /*0x44b8*/
  v21 = va_arg(va1, __int64 ***); /*0x44b8*/
  v22 = va_arg(va1, _QWORD *); /*0x44b8*/
  v18 = 0; /*0x44e1*/
  v3 = 0; /*0x44e5*/
  p_SecondString = (const CHAR16 **)&off_8CE0; /*0x44e8*/
  do /*0x4518*/
  {
    if ( *p_SecondString && !StrnCmp((const CHAR16 *)(a2 + 2), *p_SecondString, 0x10u) ) /*0x4503*/
      break; /*0x450b*/
    ++v3; /*0x450d*/
    p_SecondString += 4; /*0x4510*/
  }
  while ( !v3 ); /*0x4518*/
  if ( v3 == 1 ) /*0x4525*/
  {
    v7 = (__int64 **)&unk_8DB0; /*0x4527*/
  }
  else
  {
    v7 = &(&off_8CE0)[4 * v3]; /*0x4530*/
    v8 = v7[1]; /*0x4533*/
    if ( v8 ) /*0x453a*/
    {
      if ( !*v8 ) /*0x4549*/
        *v8 = (__int64)NvmeExtractConfig; /*0x4555*/
      v9 = v7[1]; /*0x4558*/
      if ( !v9[1] ) /*0x455c*/
        v9[1] = (__int64)NvmeRouteConfig; /*0x4569*/
      v10 = v7[1]; /*0x456d*/
      if ( !v10[2] ) /*0x4571*/
        v10[2] = (__int64)NvmeCallback; /*0x457e*/
    }
    else
    {
      v7[1] = (__int64 *)&off_8D50; /*0x4543*/
    }
  }
  v11 = (*(__int64 (__fastcall **)(_QWORD, void *, char **))(BootServices + 152))( /*0x4599*/
          *(_QWORD *)(a1 + 24),
          &unk_8D30,
          (char **)va);
  src = src_3; /*0x459f*/
  src_1 = *(_QWORD *)(a1 + 32); /*0x45a7*/
  if ( v11 < 0 ) /*0x45ab*/
    src = 0; /*0x45ab*/
  src_3 = src; /*0x45af*/
  src_2 = VarArgListToBuffer(src, src_1); /*0x45b4*/
  v15 = *(_OWORD *)(a2 + 2); /*0x45b9*/
  src_3 = src_2; /*0x45c4*/
  xmmword_8D6C = v15; /*0x45cc*/
  v16 = VarArgListToBuffer(src_2, (__int64)&src_); /*0x45e0*/
  (*(void (__fastcall **)(char *))(BootServices + 72))(src_3); /*0x45e8*/
  result = (*(__int64 (__fastcall **)(__int64 *, void *, char *, void *, __int64 *, _QWORD))(BootServices + 328))( /*0x4617*/
             &v18,
             &unk_8D30,
             v16,
             &unk_8D90,
             v7[1],
             0);
  if ( result >= 0 ) /*0x4620*/
  {
    if ( v22 ) /*0x462d*/
      *v22 = v18; /*0x4634*/
    if ( v21 ) /*0x4642*/
    {
      if ( v7 == (__int64 **)&unk_8DB0 ) /*0x4647*/
        v7 = 0; /*0x4647*/
      *v21 = v7; /*0x464b*/
    }
    return 0; /*0x464e*/
  }
  return result; /*0x465a*/
}


// Function: IntToAscii @ 0x4668 (0x71 bytes)
// Index: 60/103

_BYTE *__fastcall IntToAscii(__int64 a1, _BYTE *n, __int64 n10, char a4)
{
  unsigned __int64 v4; // r11
  _BYTE *n_1; // r10
  unsigned __int64 v6; // rax
  unsigned __int64 n0xA; // rdx
  char v8; // dl

  v4 = (unsigned int)a1; /*0x466b*/
  n_1 = n; /*0x4671*/
  if ( a4 ) /*0x4677*/
    v4 = a1; /*0x4677*/
  if ( (_DWORD)n10 == 10 ) /*0x467f*/
    v4 = -a1; /*0x467f*/
  if ( a1 >= 0 ) /*0x4686*/
    v4 = a1; /*0x4686*/
  if ( v4 ) /*0x468d*/
  {
    do /*0x46b4*/
    {
      v6 = v4 / (int)n10; /*0x4697*/
      n0xA = v4 % (int)n10; /*0x4697*/
      v4 = v6; /*0x469a*/
      if ( n0xA >= 0xA ) /*0x46a1*/
        v8 = n0xA + 87; /*0x46a8*/
      else
        v8 = n0xA + 48; /*0x46a3*/
      *n_1++ = v8; /*0x46ab*/
    }
    while ( v6 ); /*0x46b4*/
  }
  else
  {
    *n = 48; /*0x46b8*/
    n_1 = n + 1; /*0x46bb*/
  }
  if ( (_DWORD)n10 == 10 && a1 < 0 ) /*0x46c7*/
    *n_1++ = 45; /*0x46c9*/
  *n_1 = 0; /*0x46d0*/
  return n_1 - 1; /*0x46d8*/
}


// Function: AsciiStrToUint64 @ 0x46dc (0xd7 bytes)
// Index: 61/103

__int64 __fastcall AsciiStrToUint64(char *FormatString, char **p_FormatString, int n32)
{
  char v3; // r10
  char v4; // r9
  unsigned int n0x7FFFFFFF; // r8d
  char *FormatString_1; // rdx
  char v9; // cl
  char n10; // cl

  v3 = 0; /*0x46e6*/
  v4 = 1; /*0x46ee*/
  n0x7FFFFFFF = 0; /*0x46f1*/
  while ( *FormatString == 32 || *FormatString == 9 ) /*0x46ff*/
    FormatString += 2; /*0x4701*/
  if ( *FormatString ) /*0x4707*/
  {
    if ( *FormatString == 45 ) /*0x4719*/
    {
      v4 = -1; /*0x471b*/
      FormatString += 2; /*0x471e*/
    }
    FormatString_1 = FormatString + 2; /*0x4725*/
    if ( *FormatString != 43 ) /*0x4729*/
      FormatString_1 = FormatString; /*0x4729*/
    while ( 1 ) /*0x472d*/
    {
      v9 = *FormatString_1; /*0x472d*/
      if ( (unsigned __int8)(*FormatString_1 - 48) > 9u ) /*0x4734*/
      {
        if ( (unsigned __int8)((v9 & 0xDF) - 65) > 0x19u ) /*0x4743*/
          break; /*0x4743*/
        n10 = (v9 & 0xDF) - 55; /*0x4748*/
      }
      else
      {
        n10 = v9 - 48; /*0x4736*/
      }
      if ( n10 >= 10 ) /*0x4753*/
        break; /*0x4753*/
      n0x7FFFFFFF = n10 + 10 * n0x7FFFFFFF; /*0x4759*/
      if ( v4 == 1 ) /*0x4760*/
      {
        if ( n0x7FFFFFFF >= 0x80000000 ) /*0x4769*/
          v3 = 1; /*0x476b*/
      }
      else if ( n0x7FFFFFFF > 0x80000000 ) /*0x477b*/
      {
        v3 = 1; /*0x477b*/
      }
      FormatString_1 += 2; /*0x477f*/
    }
    *p_FormatString = FormatString_1; /*0x4785*/
    if ( v3 ) /*0x478b*/
    {
      n0x7FFFFFFF = 0x7FFFFFFF; /*0x4796*/
      if ( v4 == -1 ) /*0x479c*/
        n0x7FFFFFFF = 0x80000000; /*0x479c*/
    }
    return n0x7FFFFFFF * v4; /*0x47a4*/
  }
  else
  {
    *p_FormatString = FormatString; /*0x470d*/
    return 0; /*0x4710*/
  }
}


// Function: StatusToString @ 0x47b4 (0xc7 bytes)
// Index: 62/103

const char *__fastcall StatusToString(unsigned __int64 n4, __int64 n37, __int64 n32)
{
  __int64 v4; // rax
  char *EFI_INTERRUPT_PENDING; // rcx
  unsigned __int64 n3; // rdx

  if ( !n4 ) /*0x47b7*/
    return "EFI_SUCCESS"; /*0x47c0*/
  if ( (n4 & 0x8000000000000000uLL) != 0LL ) /*0x47c1*/
  {
    n3 = n4 & 0x1FFFFFFFFFFFFFFFLL; /*0x4815*/
    if ( (n4 & 0xA000000000000000uLL) == 0xA000000000000000uLL ) /*0x4821*/
    {
      if ( n3 >= 3 ) /*0x4827*/
        return 0; /*0x4827*/
      v4 = 25 * n3; /*0x4829*/
      EFI_INTERRUPT_PENDING = aEfiInterruptPe; // "EFI_INTERRUPT_PENDING" /*0x482d*/
      return &EFI_INTERRUPT_PENDING[v4]; /*0x4834*/
    }
    if ( (n4 & 0xC000000000000000uLL) == 0xC000000000000000uLL ) /*0x4846*/
    {
      if ( n3 > 2 ) /*0x484c*/
        return 0; /*0x484c*/
      v4 = 25 * n3 + 36599; /*0x4852*/
    }
    else
    {
      if ( n3 > 0x1E ) /*0x485f*/
        return 0; /*0x485f*/
      v4 = 25 * n3 + 36663; /*0x4869*/
    }
LABEL_18:
    EFI_INTERRUPT_PENDING = (char *)&_ImageBase; /*0x4870*/
    return &EFI_INTERRUPT_PENDING[v4]; /*0x4870*/
  }
  if ( (n4 & 0x2000000000000000LL) == 0 ) /*0x47d0*/
  {
    if ( n4 > 4 ) /*0x47ef*/
      return 0; /*0x47ef*/
    v4 = 26 * n4 + 36310; /*0x47f5*/
    goto LABEL_18; /*0x47fc*/
  }
  if ( n4 >= 2 ) /*0x47d6*/
    return 0; /*0x47da*/
  v4 = 35 * n4; /*0x47db*/
  EFI_INTERRUPT_PENDING = aEfiWarnInterru; // "EFI_WARN_INTERRUPT_SOURCE_PENDING" /*0x47df*/
  return &EFI_INTERRUPT_PENDING[v4]; /*0x47c0*/
}


// Function: UnicodeSPrintAsciiFormat @ 0x487c (0x26 bytes)
// Index: 63/103

UINTN UnicodeSPrintAsciiFormat(CHAR16 *StartOfBuffer, UINTN BufferSize, const CHAR8 *FormatString, ...)
{
  const CHAR8 *FormatString_1; // [rsp+40h] [rbp+18h] BYREF

  FormatString_1 = FormatString; /*0x4883*/
  return UnicodeVSPrint(StartOfBuffer, 0, (const CHAR16 *)BufferSize, (VA_LIST)&FormatString_1); /*0x489d*/
}


// Function: UnicodeVSPrint @ 0x48a4 (0x478 bytes)
// Index: 64/103

UINTN __cdecl UnicodeVSPrint(CHAR16 *StartOfBuffer, UINTN BufferSize, const CHAR16 *FormatString, VA_LIST Marker)
{
  char *FormatString_1; // r12
  UINTN BufferSize_1; // r13
  CHAR16 *StartOfBuffer_1; // rdi
  CHAR16 *StartOfBuffer_2; // r15
  VA_LIST i_1; // rcx
  CHAR16 n37_1; // ax
  __int64 n32; // r8
  __int64 n37; // rdx
  __int16 n32_1; // si
  VA_LIST i_2; // rcx
  unsigned int v14; // edi
  unsigned int v15; // eax
  CHAR16 *j; // rax
  UINTN v17; // r8
  CHAR16 *m; // rcx
  UINTN *Marker_1; // rax
  UINTN _Status_Code_; // rax
  char v21; // al
  CHAR16 n100; // dx
  char v23; // r9
  __int64 n10; // r8
  __int64 *i_3; // rcx
  _WORD *v26; // rbx
  _BYTE *n; // rcx
  _BYTE *ii; // rcx
  bool v29; // zf
  __int16 v30; // dx
  _WORD *v31; // rcx
  _WORD *v32; // rcx
  unsigned __int64 v33; // rax
  CHAR16 *v34; // rcx
  CHAR16 v35; // ax
  _BYTE *k; // rdx
  __int64 v37; // r15
  char *p_FormatString; // [rsp+70h] [rbp-90h] BYREF
  CHAR16 *StartOfBuffer_3; // [rsp+78h] [rbp-88h]
  _WORD v41[32]; // [rsp+80h] [rbp-80h] BYREF
  _BYTE n_1[256]; // [rsp+C0h] [rbp-40h] BYREF
  _BYTE n_2[304]; // [rsp+1C0h] [rbp+C0h] BYREF
  VA_LIST i; // [rsp+310h] [rbp+210h]

  FormatString_1 = (char *)FormatString; /*0x48cb*/
  BufferSize_1 = BufferSize; /*0x48ce*/
  StartOfBuffer_1 = StartOfBuffer; /*0x48d1*/
  StartOfBuffer_2 = StartOfBuffer; /*0x48d4*/
  if ( !StartOfBuffer || !FormatString ) /*0x48e3*/
    return -1; /*0x4cfd*/
  if ( BufferSize == 1 ) /*0x48ed*/
  {
LABEL_83:
    *StartOfBuffer_2 = 0; /*0x4cf4*/
    v37 = (char *)StartOfBuffer_2 - (char *)StartOfBuffer_1; /*0x4cf8*/
    return v37 >> 1; /*0x4cfb*/
  }
  i_1 = Marker - 8; /*0x48f3*/
  for ( i = Marker - 8; ; i_1 = i ) /*0x48f7*/
  {
    n37_1 = *(_WORD *)FormatString_1; /*0x48fe*/
    n32 = 32; /*0x4909*/
    n37 = 37; /*0x490d*/
    if ( !*(_WORD *)FormatString_1 ) /*0x4914*/
    {
LABEL_82:
      StartOfBuffer_1 = StartOfBuffer; /*0x4ced*/
      goto LABEL_83; /*0x4ced*/
    }
    FormatString_1 += 2; /*0x491a*/
    if ( n37_1 != 37 ) /*0x4921*/
    {
      *StartOfBuffer_2 = n37_1; /*0x4923*/
LABEL_8:
      ++StartOfBuffer_2; /*0x4927*/
      --BufferSize_1; /*0x492b*/
      goto LABEL_78; /*0x492e*/
    }
    if ( *(_WORD *)FormatString_1 == 37 ) /*0x4938*/
    {
      FormatString_1 += 2; /*0x493a*/
      *StartOfBuffer_2 = 37; /*0x493e*/
      goto LABEL_8; /*0x4942*/
    }
    n32_1 = 32; /*0x4944*/
    if ( *(_WORD *)FormatString_1 == 48 ) /*0x494d*/
    {
      n32_1 = 48; /*0x494f*/
      FormatString_1 += 2; /*0x4952*/
    }
    switch ( *(_WORD *)FormatString_1 ) /*0x495c*/
    {
      case '*': /*0x495c*/
        FormatString_1 += 2; /*0x495e*/
        i_2 = i_1 + 8; /*0x4962*/
        i = i_2; /*0x4966*/
        v14 = *(_DWORD *)i_2; /*0x496d*/
        break;
      case 's': /*0x495c*/
        i = i_2 + 8; /*0x4998*/
        for ( j = (CHAR16 *)*((_QWORD *)i_2 + 1); *j; ++j ) /*0x499f*/
        {
          if ( !--BufferSize_1 ) /*0x49a8*/
            goto LABEL_80; /*0x49a8*/
          *StartOfBuffer_2++ = *j; /*0x49ae*/
        }
        goto LABEL_77; /*0x49c0*/
      case 'S': /*0x495c*/
      case 'a': /*0x495c*/
        i = i_2 + 8; /*0x4c9e*/
        for ( k = (_BYTE *)*((_QWORD *)i_2 + 1); *k; ++k ) /*0x4ca5*/
        {
          if ( !--BufferSize_1 ) /*0x4cae*/
            goto LABEL_80; /*0x4cae*/
          *StartOfBuffer_2++ = (char)*k; /*0x4cb3*/
        }
        goto LABEL_77; /*0x4cc2*/
      default:
        v15 = AsciiStrToUint64(FormatString_1, &p_FormatString, 32); /*0x4979*/
        i_2 = i; /*0x497e*/
        v14 = v15; /*0x4985*/
        FormatString_1 = p_FormatString; /*0x4987*/
        break;
    }
    if ( *(_WORD *)FormatString_1 != 99 ) /*0x49e5*/
      break; /*0x49e5*/
    i = i_2 + 8; /*0x49eb*/
    *StartOfBuffer_2++ = *((_WORD *)i_2 + 4); /*0x49f5*/
LABEL_77:
    FormatString_1 += 2; /*0x4cc4*/
LABEL_78:
    if ( BufferSize_1 == 1 ) /*0x4ccc*/
      goto LABEL_82; /*0x4ccc*/
  }
  if ( (*FormatString_1 & 0xDF) == 0x47 ) /*0x4a0a*/
  {
    StartOfBuffer_3 = StartOfBuffer_2; /*0x4a14*/
    i = i_2 + 8; /*0x4a19*/
    v17 = UnicodeBSPrint( /*0x4a99*/
            StartOfBuffer_2,
            BufferSize_1,
            L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
            (BASE_LIST)**((unsigned int **)i_2 + 1));
    StartOfBuffer_2 += v17; /*0x4aa2*/
    if ( *(_WORD *)FormatString_1 == 71 ) /*0x4aa6*/
    {
      for ( m = StartOfBuffer_3; *m; ++m ) /*0x4aad*/
      {
        if ( (unsigned __int16)(*m - 97) <= 0x19u ) /*0x4ac1*/
          *m -= 32; /*0x4ac7*/
      }
    }
    BufferSize_1 -= v17; /*0x4ad4*/
    goto LABEL_77; /*0x4ad7*/
  }
  if ( *(_WORD *)FormatString_1 == 114 ) /*0x4ae2*/
  {
    i = i_2 + 8; /*0x4ae8*/
    Marker_1 = (UINTN *)StatusToString(*((_QWORD *)i_2 + 1), n37, n32); /*0x4af5*/
    if ( Marker_1 ) /*0x4b03*/
      _Status_Code_ = UnicodeBSPrint(StartOfBuffer_2, BufferSize_1, L"%S", Marker_1); /*0x4b29*/
    else
      _Status_Code_ = UnicodeBSPrint( /*0x4b18*/
                        StartOfBuffer_2,
                        BufferSize_1,
                        L"%S(%X)",
                        ::Marker); // "Status Code"
    StartOfBuffer_2 += _Status_Code_; /*0x4b2e*/
    BufferSize_1 -= _Status_Code_; /*0x4b32*/
    goto LABEL_77; /*0x4b35*/
  }
  if ( *(_WORD *)FormatString_1 == 108 ) /*0x4b40*/
  {
    FormatString_1 += 2; /*0x4b42*/
    v21 = 1; /*0x4b46*/
  }
  else
  {
    v21 = 0; /*0x4b4a*/
  }
  n100 = *(_WORD *)FormatString_1; /*0x4b4d*/
  v23 = 1; /*0x4b52*/
  if ( *(_WORD *)FormatString_1 != 112 ) /*0x4b5f*/
    v23 = v21; /*0x4b5f*/
  if ( n100 == 100 || n100 == 105 ) /*0x4b6d*/
  {
    n10 = 10; /*0x4b83*/
  }
  else
  {
    if ( (n100 & 0xDF) != 0x58 ) /*0x4b75*/
      goto LABEL_78; /*0x4b75*/
    n10 = 16; /*0x4b7b*/
  }
  i_3 = (__int64 *)(i_2 + 8); /*0x4b89*/
  v26 = v41; /*0x4b8d*/
  i = (VA_LIST)i_3; /*0x4b91*/
  if ( v23 ) /*0x4b9b*/
  {
    for ( n = IntToAscii(*i_3, n_1, n10, 1); n >= n_1; --n ) /*0x4bac*/
      *v26++ = (char)*n; /*0x4bb4*/
  }
  else
  {
    for ( ii = IntToAscii(*(int *)i_3, n_2, n10, 0); ii >= n_2; --ii ) /*0x4bdb*/
      *v26++ = (char)*ii; /*0x4be3*/
  }
  v29 = *(_WORD *)FormatString_1 == 88; /*0x4bf9*/
  *v26 = 0; /*0x4bff*/
  if ( v29 || *(_WORD *)FormatString_1 == 112 ) /*0x4c0b*/
  {
    v30 = v41[0]; /*0x4c0d*/
    v31 = v41; /*0x4c11*/
    if ( v41[0] ) /*0x4c18*/
    {
      do /*0x4c37*/
      {
        if ( (unsigned __int16)(*v31 - 97) <= 0x19u ) /*0x4c2a*/
          *v31 -= 32; /*0x4c30*/
        ++v31; /*0x4c33*/
      }
      while ( *v31 ); /*0x4c37*/
      goto LABEL_62; /*0x4c3b*/
    }
  }
  else
  {
LABEL_62:
    v30 = v41[0]; /*0x4c3d*/
  }
  v32 = v41; /*0x4c41*/
  v33 = 0; /*0x4c45*/
  if ( v30 ) /*0x4c4b*/
  {
    do /*0x4c54*/
    {
      ++v32; /*0x4c4d*/
      ++v33; /*0x4c51*/
    }
    while ( *v32 ); /*0x4c54*/
  }
  while ( v33 < v14 ) /*0x4c72*/
  {
    ++v33; /*0x4c5e*/
    if ( !--BufferSize_1 ) /*0x4c65*/
      goto LABEL_80; /*0x4c65*/
    *StartOfBuffer_2++ = n32_1; /*0x4c67*/
  }
  v34 = v41; /*0x4c74*/
  if ( !v30 ) /*0x4c7b*/
    goto LABEL_77; /*0x4c7b*/
  while ( --BufferSize_1 ) /*0x4c7d*/
  {
    v35 = *v34++; /*0x4c83*/
    *StartOfBuffer_2++ = v35; /*0x4c8a*/
    if ( !*v34 ) /*0x4c92*/
      goto LABEL_77; /*0x4c96*/
  }
LABEL_80:
  *StartOfBuffer_2 = 0; /*0x4cda*/
  v37 = (char *)StartOfBuffer_2 - (char *)StartOfBuffer; /*0x4cde*/
  return v37 >> 1; /*0x4d09*/
}
/* Orphan comments:
"Status Code"
*/


// Function: UnicodeBSPrint @ 0x4d1c (0x1d bytes)
// Index: 65/103

UINTN __cdecl UnicodeBSPrint(CHAR16 *StartOfBuffer, UINTN BufferSize, const CHAR16 *FormatString, BASE_LIST Marker)
{
  BASE_LIST Markera; // [rsp+48h] [rbp+20h] BYREF

  Markera = Marker; /*0x4d21*/
  return UnicodeVSPrint(StartOfBuffer, BufferSize, FormatString, (VA_LIST)&Markera); /*0x4d34*/
}


// Function: StrnCmp @ 0x4d3c (0x78 bytes)
// Index: 66/103

INTN __cdecl StrnCmp(const CHAR16 *FirstString, const CHAR16 *SecondString, UINTN Length)
{
  const CHAR16 *FirstString_1; // r10
  __int64 n8; // r9
  __int64 v5; // r8

  FirstString_1 = (const CHAR16 *)((char *)FirstString + Length); /*0x4d42*/
  if ( Length >= 8 ) /*0x4d49*/
  {
    n8 = (unsigned __int8)FirstString & 7; /*0x4d4e*/
    if ( ((unsigned __int8)FirstString & 7) != 0 && n8 == ((unsigned __int8)SecondString & 7) ) /*0x4d5d*/
    {
      v5 = 8 - n8; /*0x4d62*/
      if ( n8 != 8 ) /*0x4d65*/
      {
        do /*0x4d77*/
        {
          if ( *(_BYTE *)FirstString != *(_BYTE *)SecondString ) /*0x4d6b*/
            break; /*0x4d6b*/
          FirstString = (const CHAR16 *)((char *)FirstString + 1); /*0x4d6d*/
          SecondString = (const CHAR16 *)((char *)SecondString + 1); /*0x4d70*/
          --v5; /*0x4d73*/
        }
        while ( v5 ); /*0x4d77*/
      }
    }
    while ( FirstString <= FirstString_1 - 4 && *(_QWORD *)FirstString == *(_QWORD *)SecondString ) /*0x4d85*/
    {
      FirstString += 4; /*0x4d87*/
      SecondString += 4; /*0x4d8a*/
    }
  }
  while ( 1 ) /*0x4da0*/
  {
    if ( FirstString >= FirstString_1 ) /*0x4da3*/
      return 0; /*0x4da7*/
    if ( *(_BYTE *)FirstString != *(_BYTE *)SecondString ) /*0x4d98*/
      break; /*0x4d98*/
    FirstString = (const CHAR16 *)((char *)FirstString + 1); /*0x4d9a*/
    SecondString = (const CHAR16 *)((char *)SecondString + 1); /*0x4d9d*/
  }
  return *(char *)FirstString - *(char *)SecondString; /*0x4da7*/
}


// Function: NvmeDetectDevice @ 0x4db4 (0xd3 bytes)
// Index: 67/103

__int64 __fastcall NvmeDetectDevice(__int64 a1, __int64 a2, char n6, unsigned __int8 *a4, __int64 *p_n26)
{
  __int64 v6; // rbx
  unsigned __int8 v7; // di
  unsigned __int8 v8; // bp
  unsigned __int8 i; // bl
  UINTN Address; // rax

  *a4 = -1; /*0x4ddb*/
  v6 = (n6 & 7 | 0xE0LL) << 12; /*0x4de6*/
  *(_BYTE *)p_n26 = -1; /*0x4ded*/
  v7 = *(_BYTE *)PciExpressLibAddress(v6 | 0x19); /*0x4e01*/
  v8 = *(_BYTE *)PciExpressLibAddress(v6 | 0x1A); /*0x4e09*/
  if ( v7 > v8 ) /*0x4e0f*/
    return 0x8000000000000003uLL; /*0x4e11*/
  while ( 2 ) /*0x4e1d*/
  {
    for ( i = 0; i < 0x20u; ++i ) /*0x4e1d*/
    {
      Address = PciExpressLibAddress(((32LL * v7) | i & 0x1F) << 15); /*0x4e34*/
      if ( MmioRead16(Address) != 0xFFFF ) /*0x4e49*/
      {
        *a4 = v7; /*0x4e66*/
        *(_BYTE *)p_n26 = i; /*0x4e6b*/
        return 0; /*0x4e69*/
      }
    }
    if ( ++v7 <= v8 ) /*0x4e58*/
      continue; /*0x4e58*/
    break;
  }
  return 0x800000000000000EuLL; /*0x4e7d*/
}


// Function: NvmeGetVendorDeviceIds @ 0x4e88 (0x119 bytes)
// Index: 68/103

__int16 __fastcall NvmeGetVendorDeviceIds(void *buf, void *buf_1, void *buf_2)
{
  unsigned __int8 n2; // bp
  unsigned __int8 v7; // si
  __int64 v8; // r14
  UINTN Address; // rax
  _BYTE *n8214; // rax
  UINTN Address_1; // rax
  __int64 n2_1; // rbx

  n2 = 0; /*0x4ea7*/
  SetMemS(buf, 2u); /*0x4eb4*/
  SetMemS(buf_1, 2u); /*0x4ebe*/
  SetMemS(buf_2, 2u); /*0x4ec8*/
  v7 = 0; /*0x4ecd*/
  v8 = 0; /*0x4ed0*/
  do /*0x4f7e*/
  {
    Address = PciExpressLibAddress((v7 << 20) | 0x42000LL); /*0x4ee5*/
    LOWORD(n8214) = MmioRead16(Address); /*0x4eed*/
    if ( (_WORD)n8214 == 0x8086 ) /*0x4efa*/
    {
      Address_1 = PciExpressLibAddress((v7 << 20) | 0x42002LL); /*0x4f06*/
      LOWORD(n8214) = MmioRead16(Address_1); /*0x4f0e*/
      if ( (_WORD)n8214 == 8214 && n2 < 2u ) /*0x4f20*/
      {
        n2_1 = n2; /*0x4f38*/
        *((_BYTE *)buf + n2) = *(_BYTE *)PciExpressLibAddress((v8 << 20) | 0x420CD); /*0x4f48*/
        *((_BYTE *)buf_1 + n2) = *(_BYTE *)PciExpressLibAddress((v8 << 20) | 0x420CE); /*0x4f5d*/
        n8214 = (_BYTE *)PciExpressLibAddress((v8 << 20) | 0x420CF); /*0x4f61*/
        ++n2; /*0x4f66*/
        *((_BYTE *)buf_2 + n2_1) = *n8214; /*0x4f70*/
      }
    }
    ++v7; /*0x4f74*/
    ++v8; /*0x4f77*/
  }
  while ( v7 != 0xFF ); /*0x4f7e*/
  return (__int16)n8214; /*0x4f93*/
}


// Function: NvmeGetSetupValue @ 0x4fa4 (0x90 bytes)
// Index: 69/103

char NvmeGetSetupValue()
{
  __int64 v0; // rax
  char n85; // dl
  _DWORD v3[4]; // [rsp+30h] [rbp-D0h] BYREF
  _BYTE v4[816]; // [rsp+40h] [rbp-C0h] BYREF
  char v5; // [rsp+380h] [rbp+280h] BYREF
  __int64 n814; // [rsp+388h] [rbp+288h] BYREF

  v3[0] = -326642109; /*0x4fbe*/
  v3[1] = 1270213540; /*0x4fe5*/
  v3[2] = 1044374945; /*0x4ff4*/
  v3[3] = -1458720202; /*0x4ffc*/
  n814 = 814; /*0x5006*/
  v0 = (*(__int64 (__fastcall **)(const __int16 *, _DWORD *, char *, __int64 *, _BYTE *))(RuntimeServices_0 + 72))( /*0x5011*/
         L"Setup",
         v3,
         &v5,
         &n814,
         v4);
  n85 = 85; /*0x501b*/
  if ( v0 >= 0 ) /*0x5026*/
    return v4[284]; /*0x5026*/
  return n85; /*0x502b*/
}


// Function: NvmeSetSetupOptions @ 0x5034 (0x263 bytes)
// Index: 70/103

__int64 __fastcall NvmeSetSetupOptions(__int64 a1, _BYTE *a2, _BYTE *p_i, _BYTE *a4, __int64 *p_ia)
{
  __int64 v5; // rax
  __int64 *p_ia_1; // r15
  _BYTE *v7; // rdi
  bool v8; // r13
  _BYTE *v10; // r14
  char p_ia_2; // r12
  __int64 v12; // r8
  char v13; // r9
  __int64 result; // rax
  char p_ia_3; // cl
  bool v16; // bl
  __int64 v17; // r8
  char v18; // r9
  bool v19; // zf
  __int64 v20; // [rsp+40h] [rbp-C0h] BYREF
  unsigned __int64 v21; // [rsp+48h] [rbp-B8h]
  _BYTE v22[298]; // [rsp+50h] [rbp-B0h] BYREF
  char p_ia_4; // [rsp+17Ah] [rbp+7Ah]
  __int64 v24; // [rsp+3C0h] [rbp+2C0h] BYREF
  unsigned int v25; // [rsp+3C8h] [rbp+2C8h] BYREF
  __int64 n814; // [rsp+3D0h] [rbp+2D0h] BYREF

  v24 = a1; /*0x5039*/
  v5 = qword_95B0; /*0x5058*/
  p_ia_1 = p_ia; /*0x5061*/
  v7 = a4; /*0x506b*/
  n814 = 814; /*0x506e*/
  v8 = qword_95B0 == 0; /*0x5079*/
  v20 = 0x4BB5EBA4EC87D643LL; /*0x507d*/
  v21 = 0xA90DB2363E3FE5A1uLL; /*0x5090*/
  v10 = a2; /*0x5098*/
  p_ia_2 = -1; /*0x50a3*/
  *p_i = -1; /*0x50a6*/
  *(_BYTE *)p_ia_1 = -1; /*0x50aa*/
  *a2 = 0; /*0x50ae*/
  *a4 = 0; /*0x50b0*/
  v25 = 0; /*0x50b3*/
  if ( v8 /*0x50f7*/
    || (LOBYTE(v24) = 1,
        LOBYTE(a4) = 89,
        LOBYTE(a2) = 46,
        (*(__int64 (__fastcall **)(__int64, _BYTE *, _QWORD, _BYTE *, _QWORD, _BYTE, __int64 **, __int64 *, __int64, unsigned __int64))(v5 + 16))(
          v5,
          a2,
          0,
          a4,
          0,
          0,
          &p_ia,
          &v24,
          v20,
          v21) < 0) )
  {
    v8 = 1; /*0x5107*/
  }
  else
  {
    p_ia_2 = (char)p_ia; /*0x50f9*/
  }
  if ( (*(__int64 (__fastcall **)(const __int16 *, __int64 *, unsigned int *, __int64 *, _BYTE *))(RuntimeServices_0 + 72))( /*0x513b*/
         L"Setup",
         &v20,
         &v25,
         &n814,
         v22) < 0 )
    return 0x8000000000000003uLL; /*0x5147*/
  p_ia_3 = p_ia_4; /*0x514c*/
  if ( !v8 ) /*0x515e*/
    p_ia_3 = p_ia_2; /*0x515e*/
  p_ia_4 = p_ia_3; /*0x5161*/
  GpioSetOutput(17170432, (int *)&v24, v12, v13); /*0x5169*/
  v16 = (_DWORD)v24 != 1; /*0x5181*/
  LODWORD(v24) = 0; /*0x5184*/
  GpioSetOutput(16973835, (int *)&v24, v17, v18); /*0x518d*/
  v19 = (_DWORD)v24 == 0; /*0x5194*/
  *v7 = 0; /*0x519a*/
  if ( v16 ) /*0x51a2*/
  {
    if ( v19 ) /*0x51e0*/
    {
      if ( !p_ia_2 ) /*0x51e5*/
      {
        *p_i = 4; /*0x5209*/
        *(_BYTE *)p_ia_1 = 0; /*0x520c*/
        goto LABEL_34; /*0x520f*/
      }
      if ( p_ia_2 == 9 ) /*0x51eb*/
      {
        *v10 = 4; /*0x5200*/
        *p_i = 8; /*0x5204*/
      }
      else
      {
        *v10 = 0; /*0x51ed*/
        if ( p_ia_2 == 11 ) /*0x51f4*/
        {
          *p_i = 4; /*0x51fb*/
          goto LABEL_15; /*0x51fe*/
        }
        *p_i = -1; /*0x51f6*/
      }
LABEL_29:
      *(_BYTE *)p_ia_1 = -1; /*0x5228*/
      goto LABEL_35; /*0x522c*/
    }
    if ( !p_ia_2 ) /*0x5214*/
    {
      *(_BYTE *)p_ia_1 = 8; /*0x5238*/
      goto LABEL_33; /*0x5238*/
    }
    *p_i = -1; /*0x5216*/
    if ( p_ia_2 == 9 ) /*0x521d*/
    {
      *v10 = 4; /*0x522e*/
    }
    else
    {
      *v10 = 0; /*0x521f*/
      if ( p_ia_2 != 11 ) /*0x5226*/
        goto LABEL_29; /*0x5226*/
    }
    *(_BYTE *)p_ia_1 = 8; /*0x5232*/
    goto LABEL_35; /*0x5236*/
  }
  if ( p_ia_2 == 1 ) /*0x51ab*/
  {
    *p_i = 2; /*0x51d5*/
    *(_BYTE *)p_ia_1 = 6; /*0x51d8*/
LABEL_34:
    *v10 = 0; /*0x523f*/
    goto LABEL_35; /*0x523f*/
  }
  if ( p_ia_2 == 8 ) /*0x51b0*/
  {
    *v10 = 4; /*0x51c8*/
    *p_i = 4; /*0x51cc*/
    *(_BYTE *)p_ia_1 = 4; /*0x51cf*/
    goto LABEL_35; /*0x51d3*/
  }
  if ( p_ia_2 != 10 ) /*0x51b5*/
  {
    *(_BYTE *)p_ia_1 = -1; /*0x51b7*/
LABEL_33:
    *p_i = -1; /*0x523c*/
    goto LABEL_34; /*0x523c*/
  }
  *v10 = 4; /*0x51bd*/
  *p_i = 0; /*0x51c1*/
LABEL_15:
  *(_BYTE *)p_ia_1 = 0; /*0x51c3*/
LABEL_35:
  if ( v8 ) /*0x5245*/
    return 0; /*0x5245*/
  result = (*(__int64 (__fastcall **)(const __int16 *, __int64 *, _QWORD, __int64, _BYTE *))(RuntimeServices_0 + 88))( /*0x5272*/
             L"Setup",
             &v20,
             v25,
             n814,
             v22);
  if ( result >= 0 ) /*0x5278*/
    return 0; /*0x527a*/
  return result; /*0x5284*/
}


// Function: GpioSetPadConfig @ 0x5298 (0xfe bytes)
// Index: 71/103

unsigned __int64 __fastcall GpioSetPadConfig(int n17170432, __int64 a2, __int64 a3, char a4, int *a5)
{
  unsigned int n17170432_1; // ebx
  unsigned __int64 v7; // rdi
  _DWORD *GroupInfo; // rsi
  _QWORD v10[5]; // [rsp+20h] [rbp-28h] BYREF
  unsigned int v11; // [rsp+68h] [rbp+20h] BYREF

  LOBYTE(v11) = a4; /*0x52a2*/
  n17170432_1 = (unsigned __int16)n17170432; /*0x52b1*/
  v7 = BYTE2(n17170432); /*0x52ba*/
  if ( !GpioIsPadValid(n17170432) )
  {
    DebugPrint(
      0x80000000,
      "GPIO ERROR: Incorrect GpioPad define used on this chipset (Group=%d, Pad=%d)!\n",
      (unsigned int)v7,
      n17170432_1);
    return 0x8000000000000003uLL; /*0x52e7*/
  }
  GroupInfo = GpioGetGroupInfo(v10); /*0x52f6*/
  if ( v7 >= v10[0] )
  {
    DebugPrint(0x80000000, "GPIO ERROR: Group argument (%d) exceeds GPIO group range\n", (unsigned int)v7);
    return 0x8000000000000002uLL; /*0x5321*/
  }
  if ( n17170432_1 >= GroupInfo[15 * v7 + 14] )
  {
    DebugPrint(0x80000000, "GPIO ERROR: Pin number (%d) exceeds possible range for this group\n", n17170432_1);
    return 0x8000000000000002uLL; /*0x5337*/
  }
  GpioGetPadConfig(n17170432, &v11); /*0x5341*/
  if ( v11 )
  {
    DebugPrint(
      0x80000000,
      "GPIO ERROR: Accessing pad not owned by host (Group=%d, Pad=%d)!\n",
      (unsigned int)v7,
      n17170432_1);
    return 0x8000000000000003uLL; /*0x5354*/
  }
  *a5 = *(_DWORD *)((unsigned __int16)(GroupInfo[15 * v7 + 13] + 8 * n17170432_1) /*0x537f*/
                  | ((LOBYTE(GroupInfo[15 * v7]) | 0xFD00LL) << 16))
      & 2;
  return 0; /*0x538d*/
}


// Function: GpioSetOutput @ 0x5398 (0x5b bytes)
// Index: 72/103

__int64 __fastcall GpioSetOutput(int n17170432, int *a2, __int64 a3, char a4)
{
  signed __int64 v5; // rax
  signed __int64 v6; // rdi

  v5 = GpioSetPadConfig(n17170432, (__int64)a2, a3, a4, a2); /*0x53aa*/
  v6 = v5; /*0x53af*/
  if ( v5 < 0 ) /*0x53b5*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x53c6*/
    Assert( /*0x53de*/
      (__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
      935,
      (__int64)"!EFI_ERROR (Status)");
  }
  *a2 = (unsigned int)*a2 >> 1; /*0x53e3*/
  return v6; /*0x53ed*/
}


// Function: GpioGetPadConfig @ 0x53f4 (0xdd bytes)
// Index: 73/103

unsigned __int64 __fastcall GpioGetPadConfig(int n17170432, unsigned int *a2)
{
  unsigned int n17170432_1; // ebx
  unsigned __int64 v3; // rdi
  _DWORD *GroupInfo; // rax
  __int64 n1389; // rdx
  unsigned __int64 v8; // [rsp+40h] [rbp+18h] BYREF

  n17170432_1 = (unsigned __int16)n17170432; /*0x5405*/
  v3 = BYTE2(n17170432); /*0x5410*/
  GroupInfo = GpioGetGroupInfo(&v8); /*0x5416*/
  if ( v3 >= v8 )
  {
    DebugPrint(0x80000000, "GPIO ERROR: Group argument (%d) exceeds GPIO group range\n", v3);
    n1389 = 1389; /*0x543b*/
LABEL_3:
    Assert( /*0x5440*/
      (__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
      n1389,
      (__int64)"((BOOLEAN)(0==1))");
    return 0x8000000000000002uLL; /*0x545d*/
  }
  if ( n17170432_1 >= GroupInfo[15 * (unsigned int)v3 + 14] )
  {
    DebugPrint(0x80000000, "GPIO ERROR: Pin number (%d) exceeds possible range for this group\n", n17170432_1);
    n1389 = 1398; /*0x547d*/
    goto LABEL_3; /*0x5482*/
  }
  *a2 = (*(_DWORD *)(((LOBYTE(GroupInfo[15 * (unsigned int)v3]) | 0xFD00LL) << 16) /*0x54bd*/
                   | (unsigned __int16)(LOWORD(GroupInfo[15 * (unsigned int)v3 + 1]) + 4 * (n17170432_1 >> 3)))
       & (unsigned int)(3 << (4 * (n17170432_1 & 7)))) >> (4 * (n17170432_1 & 7));
  return 0; /*0x54cb*/
}


// Function: GpioGetGroupInfo @ 0x54d4 (0x97 bytes)
// Index: 74/103

void *__fastcall GpioGetGroupInfo(_QWORD *a1)
{
  int n2; // ebx
  __int64 LpcBaseAddress; // rax
  UINT16 v4; // ax

  n2 = n2; /*0x54de*/
  if ( n2 == 2 )
  {
    LpcBaseAddress = GetLpcBaseAddress(); /*0x54ec*/
    v4 = MmioRead16(LpcBaseAddress + 2); /*0x54f5*/
    if ( ((v4 + 24128) & 0xFF70) != 0 )
    {
      DebugPrint(0x80000000, "Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", v4);
      Assert( /*0x5533*/
        (__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
        290,
        (__int64)"((BOOLEAN)(0==1))");
    }
    else
    {
      n2 = 1; /*0x553a*/
    }
    n2 = n2; /*0x553f*/
  }
  if ( n2 == 1 ) /*0x5548*/
  {
    *a1 = 13; /*0x554a*/
    return &unk_9290; /*0x5551*/
  }
  else
  {
    *a1 = 0; /*0x555a*/
    return 0; /*0x555e*/
  }
}


// Function: GpioIsPadValid @ 0x556c (0x3f bytes)
// Index: 75/103

bool __fastcall GpioIsPadValid(int n17170432)
{
  int n2; // eax

  n2 = PchStepping(); /*0x5574*/
  if ( n2 == 1 ) /*0x557c*/
    return (n17170432 & 0xFF000000) == 0x1000000; /*0x5584*/
  if ( n2 != 2 ) /*0x5593*/
    return 0; /*0x5593*/
  return (n17170432 & 0xFF000000) == 0x2000000; /*0x55a5*/
}


// Function: GetCmosData @ 0x55ac (0x4e bytes)
// Index: 76/103

__int64 GetCmosData()
{
  unsigned __int8 v0; // al
  char n3_1; // al
  char n3; // cl
  __int64 result; // rax

  v0 = __inbyte(0x70u); /*0x55b1*/
  __outbyte(0x70u, v0 & 0x80 | 0x4B); /*0x55b6*/
  n3_1 = __inbyte(0x71u); /*0x55bc*/
  n3 = n3_1; /*0x55bd*/
  if ( (unsigned __int8)n3_1 > 3u ) /*0x55c4*/
  {
    n3 = n3; /*0x55c6*/
    if ( !n3 ) /*0x55ce*/
      n3 = MEMORY[0xFDAF0490] & 2 | 1; /*0x55da*/
  }
  if ( (unsigned __int8)(n3 - 1) > 0xFDu ) /*0x55e4*/
    return 0; /*0x55f7*/
  result = 2147483718LL; /*0x55e9*/
  if ( n3 == 1 ) /*0x55f3*/
    return 2147483652LL; /*0x55f3*/
  return result; /*0x55f6*/
}


// Function: StrLen @ 0x55fc (0x93 bytes)
// Index: 77/103

UINTN __cdecl StrLen(const CHAR16 *String)
{
  const CHAR16 *v1; // rbx
  UINTN n0xF4240; // rdi

  v1 = String; /*0x560d*/
  if ( !String ) /*0x5613*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 172, (__int64)"String != ((void *) 0)"); /*0x5628*/
  if ( ((unsigned __int8)v1 & 1) != 0 ) /*0x5630*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 173, (__int64)"((UINTN) String & 0x00000001) == 0"); /*0x5645*/
  n0xF4240 = 0; /*0x564a*/
  while ( *v1 ) /*0x567a*/
  {
    if ( n0xF4240 >= 0xF4240 ) /*0x5656*/
      Assert( /*0x566b*/
        (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
        181,
        (__int64)"Length < _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength");
    ++v1; /*0x5670*/
    ++n0xF4240; /*0x5674*/
  }
  return n0xF4240; /*0x5689*/
}


// Function: StrCat @ 0x5690 (0x11c bytes)
// Index: 78/103

CHAR16 *__cdecl StrCat(CHAR16 *Destination, const CHAR16 *Source)
{
  CHAR16 *v4; // rbx
  CHAR16 v5; // ax
  char *v6; // rdi

  v4 = &Destination[StrLen(Destination)]; /*0x56be*/
  if ( !v4 ) /*0x56c5*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 56, (__int64)"Destination != ((void *) 0)"); /*0x56d4*/
  if ( ((unsigned __int8)v4 & 1) != 0 ) /*0x56dc*/
    Assert( /*0x56ed*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      57,
      (__int64)"((UINTN) Destination & 0x00000001) == 0");
  if ( v4 - Source <= StrLen(Source) ) /*0x5706*/
    Assert( /*0x5717*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      62,
      (__int64)"(UINTN)(Destination - Source) > StrLen (Source)");
  if ( Source - v4 <= StrLen(Source) ) /*0x5730*/
    Assert( /*0x5741*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      63,
      (__int64)"(UINTN)(Source - Destination) > StrLen (Source)");
  v5 = *Source; /*0x5746*/
  if ( *Source ) /*0x5746*/
  {
    v6 = (char *)((char *)Source - (char *)v4); /*0x574e*/
    do /*0x575f*/
    {
      *v4++ = v5; /*0x5751*/
      v5 = *(CHAR16 *)((char *)v4 + (_QWORD)v6); /*0x5758*/
    }
    while ( v5 ); /*0x575f*/
  }
  *v4 = 0; /*0x5764*/
  if ( 2 * StrLen(Destination) == -2 ) /*0x5778*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 378, (__int64)"StrSize (Destination) != 0"); /*0x5789*/
  return Destination; /*0x57a5*/
}


// Function: AsciiStrLen @ 0x57ac (0x6b bytes)
// Index: 79/103

UINTN __cdecl AsciiStrLen(const CHAR8 *FirstString)
{
  const CHAR8 *FirstString_1; // rbx
  UINTN i; // rdi

  FirstString_1 = FirstString; /*0x57b6*/
  if ( !FirstString ) /*0x57bc*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 1082, (__int64)"String != ((void *) 0)"); /*0x57d1*/
  for ( i = 0; *FirstString_1; ++i ) /*0x57d8*/
  {
    if ( i >= 0xF4240 ) /*0x57e4*/
      Assert( /*0x57f9*/
        (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
        1090,
        (__int64)"Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength");
    ++FirstString_1; /*0x57fe*/
  }
  return i; /*0x5811*/
}


// Function: AsciiStrnCmp @ 0x5818 (0xcd bytes)
// Index: 80/103

INTN __cdecl AsciiStrnCmp(const CHAR8 *FirstString, const CHAR8 *SecondString, UINTN Length)
{
  const CHAR8 *x_UEFI; // rsi
  UINTN Length_1; // rdi
  const CHAR8 *FirstString_1; // rbx

  x_UEFI = "x-UEFI"; /*0x5827*/
  Length_1 = Length; /*0x582e*/
  FirstString_1 = FirstString; /*0x5831*/
  if ( !Length ) /*0x5837*/
    return 0; /*0x5839*/
  if ( AsciiStrLen(FirstString) == -1 ) /*0x5849*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 1320, (__int64)"AsciiStrSize (FirstString)"); /*0x585e*/
  if ( AsciiStrLen("x-UEFI") == -1 ) /*0x586f*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 1321, (__int64)"AsciiStrSize (SecondString)"); /*0x5884*/
  if ( Length_1 > 0xF4240 ) /*0x5890*/
    Assert( /*0x58a5*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      1324,
      (__int64)"Length <= _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength");
  while ( *FirstString_1 && *x_UEFI && *FirstString_1 == *x_UEFI && Length_1 > 1 ) /*0x58b9*/
  {
    ++FirstString_1; /*0x58bb*/
    ++x_UEFI; /*0x58be*/
    --Length_1; /*0x58c1*/
  }
  return *FirstString_1 - *x_UEFI; /*0x58df*/
}


// Function: ReadUnaligned16 @ 0x58e8 (0x2d bytes)
// Index: 81/103

UINT16 __cdecl ReadUnaligned16(const UINT16 *Buffer)
{
  if ( !Buffer ) /*0x58f4*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 38, (__int64)"Buffer != ((void *) 0)"); /*0x5907*/
  return *Buffer; /*0x590f*/
}


// Function: ReadUnaligned32 @ 0x5918 (0x2e bytes)
// Index: 82/103

UINT32 __cdecl ReadUnaligned32(const UINT32 *Buffer)
{
  if ( !Buffer ) /*0x5924*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 141, (__int64)"Buffer != ((void *) 0)"); /*0x5939*/
  return *Buffer; /*0x5940*/
}


// Function: ReadUnaligned64 @ 0x5948 (0x2f bytes)
// Index: 83/103

UINT64 __cdecl ReadUnaligned64(const UINT64 *Buffer)
{
  if ( !Buffer ) /*0x5954*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, (__int64)"Buffer != ((void *) 0)"); /*0x5969*/
  return *Buffer; /*0x5971*/
}


// Function: WriteUnaligned64 @ 0x5978 (0x3e bytes)
// Index: 84/103

UINT64 __cdecl WriteUnaligned64(UINT64 *Buffer, UINT64 Value)
{
  if ( !Buffer ) /*0x598b*/
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 219, (__int64)"Buffer != ((void *) 0)"); /*0x59a0*/
  *Buffer = Value; /*0x59a5*/
  return Value; /*0x59b0*/
}


// Function: StrLenSafe @ 0x59b8 (0x56 bytes)
// Index: 85/103

unsigned __int64 __fastcall StrLenSafe(_WORD *%02d_%02d_%04d__%02d:%02d)
{
  unsigned __int64 n0xF4240; // rax

  if ( ((unsigned __int8)%02d_%02d_%04d__%02d:%02d & 1) != 0 ) /*0x59c4*/
    Assert( /*0x59d9*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
      128,
      (__int64)"((UINTN) String & 0x00000001) == 0");
  if ( !%02d_%02d_%04d__%02d:%02d ) /*0x59e3*/
    return 0; /*0x5a06*/
  n0xF4240 = 0; /*0x59e5*/
  if ( *%02d_%02d_%04d__%02d:%02d ) /*0x59e7*/
  {
    while ( n0xF4240 < 0xF4240 ) /*0x59f2*/
    {
      if ( !%02d_%02d_%04d__%02d:%02d[++n0xF4240] ) /*0x59f7*/
        return n0xF4240; /*0x59fb*/
    }
    return 1000001; /*0x59ff*/
  }
  return n0xF4240; /*0x5a08*/
}


// Function: AsciiStrLenSafe @ 0x5a10 (0x23 bytes)
// Index: 86/103

unsigned __int64 __fastcall AsciiStrLenSafe(_BYTE *%02d_%02d_%04d__%02d:%02d)
{
  unsigned __int64 n0xF4240; // rax

  n0xF4240 = 0; /*0x5a10*/
  if ( %02d_%02d_%04d__%02d:%02d && *%02d_%02d_%04d__%02d:%02d ) /*0x5a17*/
  {
    while ( n0xF4240 < 0xF4240 ) /*0x5a21*/
    {
      if ( !%02d_%02d_%04d__%02d:%02d[++n0xF4240] ) /*0x5a26*/
        return n0xF4240; /*0x5a2a*/
    }
    return 1000001; /*0x5a2d*/
  }
  return n0xF4240; /*0x5a2c*/
}


// Function: SetMemS @ 0x5a34 (0x50 bytes)
// Index: 87/103

void *__fastcall SetMemS(void *buf, unsigned __int64 n2)
{
  if ( n2 - 1 > -1 - (__int64)buf ) /*0x5a52*/
    Assert( /*0x5a67*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\SetMemWrapper.c",
      54,
      (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)Buffer)");
  return SetMemRaw(buf, n2, 255); /*0x5a7a*/
}


// Function: GetImageBase @ 0x5a84 (0x41 bytes)
// Index: 88/103

UINT64 *__fastcall GetImageBase(UINT64 *Buffer)
{
  UINT64 Unaligned64; // rax
  UINT64 Value; // rax

  Unaligned64 = ReadUnaligned64(&Buffer_); /*0x5a94*/
  WriteUnaligned64(Buffer, Unaligned64); /*0x5a9f*/
  Value = ReadUnaligned64(&Buffer__0); /*0x5aab*/
  WriteUnaligned64(Buffer + 1, Value); /*0x5ab7*/
  return Buffer; /*0x5abf*/
}


// Function: IsZeroGuid @ 0x5ac8 (0x67 bytes)
// Index: 89/103

bool __fastcall IsZeroGuid(const UINT64 *Buffer, const UINT64 *Buffer_1)
{
  __int128 v4; // rdi
  UINT64 Unaligned64; // rbx

  *((_QWORD *)&v4 + 1) = ReadUnaligned64(Buffer); /*0x5aea*/
  Unaligned64 = ReadUnaligned64(Buffer_1); /*0x5af6*/
  *(_QWORD *)&v4 = ReadUnaligned64(Buffer + 1); /*0x5b02*/
  return v4 == __PAIR128__(Unaligned64, ReadUnaligned64(Buffer_1 + 1)); /*0x5b29*/
}


// Function: CompareMemS @ 0x5b30 (0xd6 bytes)
// Index: 90/103

unsigned __int64 __fastcall CompareMemS(char *src, char *p_n2, __int64 n2)
{
  if ( src == p_n2 ) /*0x5b55*/
    return 0; /*0x5b57*/
  if ( !src ) /*0x5b61*/
    Assert( /*0x5b74*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CompareMemWrapper.c",
      60,
      (__int64)"DestinationBuffer != ((void *) 0)");
  if ( !p_n2 ) /*0x5b7c*/
    Assert( /*0x5b8f*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CompareMemWrapper.c",
      61,
      (__int64)"SourceBuffer != ((void *) 0)");
  if ( n2 - 1 > (unsigned __int64)(-1LL - (_QWORD)src) ) /*0x5ba5*/
    Assert( /*0x5bb8*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CompareMemWrapper.c",
      62,
      (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)DestinationBuffer)");
  if ( n2 - 1 > (unsigned __int64)(-1LL - (_QWORD)p_n2) ) /*0x5bc3*/
    Assert( /*0x5bd8*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CompareMemWrapper.c",
      63,
      (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)SourceBuffer)");
  return CompareMemRaw(src, p_n2, n2); /*0x5bff*/
}


// Function: LocatePcdProtocol @ 0x5c08 (0x8c bytes)
// Index: 91/103

__int64 LocatePcdProtocol()
{
  __int64 result; // rax
  __int64 v1; // rax

  result = qword_9680; /*0x5c0c*/
  if ( !qword_9680 ) /*0x5c16*/
  {
    v1 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_8BB0, 0, &qword_9680); /*0x5c2f*/
    if ( v1 < 0 ) /*0x5c38*/
    {
      DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x5c49*/
      Assert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 78, (__int64)"!EFI_ERROR (Status)"); /*0x5c61*/
    }
    result = qword_9680; /*0x5c66*/
    if ( !qword_9680 ) /*0x5c70*/
    {
      Assert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 79, (__int64)"mPcd != ((void *) 0)"); /*0x5c83*/
      return qword_9680; /*0x5c88*/
    }
  }
  return result; /*0x5c8f*/
}


// Function: InternalAllocatePool @ 0x5c94 (0x2e bytes)
// Index: 92/103

__int64 __fastcall InternalAllocatePool(__int64 a1, __int64 a2)
{
  __int64 v2; // rax
  __int64 v3; // rcx
  __int64 v5; // [rsp+40h] [rbp+18h] BYREF

  v2 = (*(__int64 (__fastcall **)(__int64, __int64, __int64 *))(BootServices_0 + 64))(4, a2, &v5); /*0x5ca9*/
  v3 = v5; /*0x5cac*/
  if ( v2 < 0 ) /*0x5cb6*/
    return 0; /*0x5cb6*/
  return v3; /*0x5cbd*/
}


// Function: AllocateZeroPool @ 0x5cc4 (0x2c bytes)
// Index: 93/103

void *__cdecl AllocateZeroPool(UINTN AllocationSize)
{
  void *buf; // rax

  buf = (void *)InternalAllocatePool(AllocationSize, AllocationSize); /*0x5cd0*/
  if ( buf ) /*0x5cd8*/
  {
    if ( AllocationSize ) /*0x5cdd*/
      return ZeroMemS((char *)buf, AllocationSize); /*0x5ce5*/
  }
  return buf; /*0x5cea*/
}


// Function: InternalReallocatePool @ 0x5cf0 (0x7f bytes)
// Index: 94/103

char *__fastcall InternalReallocatePool(__int64 count, unsigned __int64 count_3, unsigned __int64 count_2, char *src)
{
  unsigned __int64 count_1; // rdi
  char *Pool; // rax
  char *Pool_1; // rbx

  count_1 = count_2; /*0x5d0d*/
  Pool = (char *)InternalAllocatePool(count, count_2); /*0x5d10*/
  Pool_1 = Pool; /*0x5d15*/
  if ( Pool ) /*0x5d1b*/
  {
    if ( count_1 ) /*0x5d20*/
      Pool_1 = ZeroMemS(Pool, count_1); /*0x5d2d*/
    if ( Pool_1 && src ) /*0x5d38*/
    {
      if ( count_3 < count_1 ) /*0x5d43*/
        count_1 = count_3; /*0x5d43*/
      CopyMemS(Pool_1, src, count_1); /*0x5d4a*/
      FreePool(src); /*0x5d52*/
    }
  }
  return Pool_1; /*0x5d69*/
}


// Function: FreePool @ 0x5d70 (0x44 bytes)
// Index: 95/103

void __cdecl FreePool(void *Buffer)
{
  __int64 v1; // rax

  v1 = (*(__int64 (__fastcall **)(void *))(BootServices_0 + 72))(Buffer); /*0x5d7b*/
  if ( v1 < 0 ) /*0x5d81*/
  {
    DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x5d92*/
    Assert( /*0x5daa*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiMemoryAllocationLib\\MemoryAllocationLib.c",
      819,
      (__int64)"!EFI_ERROR (Status)");
  }
}


// Function: UnicodeSPrint @ 0x5db4 (0x7b bytes)
// Index: 96/103

UINTN UnicodeSPrint(CHAR16 *StartOfBuffer, UINTN BufferSize, const CHAR16 *FormatString, ...)
{
  unsigned __int16 **va; // [rsp+58h] [rbp+20h]
  va_list v7; // [rsp+60h] [rbp+28h] BYREF

  va_start(v7, FormatString);
  va = va_arg(v7, unsigned __int16 **); /*0x5db4*/
  if ( ((unsigned __int8)StartOfBuffer & 1) != 0 ) /*0x5dcf*/
    Assert( /*0x5de4*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BasePrintLib\\PrintLib.c",
      77,
      (__int64)"(((UINTN) (StartOfBuffer)) & 0x01) == 0");
  if ( ((unsigned __int8)FormatString & 1) != 0 ) /*0x5dec*/
    Assert( /*0x5e01*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BasePrintLib\\PrintLib.c",
      78,
      (__int64)"(((UINTN) (FormatString)) & 0x01) == 0");
  return InternalPrintEngine((unsigned __int64)StartOfBuffer, 0x141u, 320, (unsigned __int8 *)FormatString, va); /*0x5e29*/
}


// Function: UnicodeFillBuf @ 0x5e30 (0x33 bytes)
// Index: 97/103

_BYTE *__fastcall UnicodeFillBuf(_BYTE *_r_n, unsigned __int64 _r_n_1, __int64 i, __int16 n32, __int64 n2)
{
  __int64 j; // r10

  for ( j = 0; j < i; ++j ) /*0x5e36*/
  {
    if ( (unsigned __int64)_r_n >= _r_n_1 ) /*0x5e3b*/
      break; /*0x5e3b*/
    *_r_n = n32; /*0x5e43*/
    if ( n2 != 1 ) /*0x5e46*/
      _r_n[1] = HIBYTE(n32); /*0x5e4f*/
    _r_n += n2; /*0x5e52*/
  }
  return _r_n; /*0x5e62*/
}


// Function: Uint64ToHexString @ 0x5e64 (0x4e bytes)
// Index: 98/103

_BYTE *__fastcall Uint64ToHexString(_BYTE *_r_n, UINT64 Dividend, __int64 n16)
{
  UINT32 n16_1; // edi
  _BYTE *_r_n_1; // rbx
  int v7; // [rsp+30h] [rbp+8h]

  n16_1 = n16; /*0x5e6e*/
  *_r_n = 0; /*0x5e71*/
  _r_n_1 = _r_n; /*0x5e77*/
  do /*0x5ea2*/
  {
    Dividend = DivU64x32(Dividend, n16_1); /*0x5e89*/
    *++_r_n_1 = a0123456789abcd[v7]; /*0x5e9d*/
  }
  while ( Dividend ); /*0x5ea2*/
  return _r_n_1; /*0x5eac*/
}


// Function: InternalPrintEngine @ 0x5eb4 (0xe0f bytes)
// Index: 99/103

unsigned __int64 __fastcall InternalPrintEngine(
        unsigned __int64 _r_n,
        unsigned __int64 n0xF4240,
        __int16 n320,
        unsigned __int8 *%02d_%02d_%04d__%02d:%02d,
        unsigned __int16 **va)
{
  unsigned __int8 *%02d_%02d_%04d__%02d:%02d_2; // r14
  __int64 v6; // r12
  unsigned __int64 _r_n_1; // r13
  __int64 v9; // rdi
  const char *(Buffer____((void__)_0)); // r8
  __int64 n578; // rdx
  __int64 n0xFFFF; // rdx
  unsigned __int64 _r_n_11; // rbx
  unsigned __int64 v15; // r10
  __int64 n2_3; // rsi
  int v17; // eax
  bool v18; // zf
  unsigned __int64 n10; // rcx
  unsigned __int8 *%02d_%02d_%04d__%02d:%02d_3; // rdx
  unsigned __int8 *%02d_%02d_%04d__%02d:%02d_4; // r8
  unsigned __int64 v22; // r9
  char v23; // r11
  __int64 v24; // rdi
  const char *_r_n_3; // rbx
  unsigned __int16 **va_1; // r10
  unsigned __int8 *%02d_%02d_%04d__%02d:%02d_5; // rdx
  int v28; // eax
  unsigned __int64 n13_1; // rcx
  unsigned __int16 *v30; // rax
  int v31; // e... [32057 chars total]


// Function: DebugPrintVarArgFmt @ 0x6cc4 (0x22 bytes)
// Index: 100/103

unsigned __int64 DebugPrintVarArgFmt(
        _BYTE *_r_n,
        unsigned __int64 n38,
        __int16 n320,
        char *%02d_%02d_%04d__%02d:%02d,
        ...)
{
  va_list va; // [rsp+60h] [rbp+28h] BYREF

  va_start(va, %02d_%02d_%04d__%02d:%02d);
  return InternalPrintEngine( /*0x6ce1*/
           (unsigned __int64)_r_n,
           n38,
           n320,
           (unsigned __int8 *)%02d_%02d_%04d__%02d:%02d,
           (unsigned __int16 **)va);
}


// Function: PchStepping @ 0x6ce8 (0x97 bytes)
// Index: 101/103

__int64 PchStepping()
{
  __int64 n3; // rax
  unsigned int n3_1; // ebx
  __int64 LpcBaseAddress; // rax
  UINT16 v3; // ax
  int v4; // edx
  int n335; // eax

  n3 = (unsigned int)n3_0; /*0x6cee*/
  n3_1 = 3; /*0x6cf4*/
  if ( n3_0 == 3 )
  {
    LpcBaseAddress = GetLpcBaseAddress(); /*0x6cfd*/
    v3 = MmioRead16(LpcBaseAddress + 2); /*0x6d06*/
    v4 = v3; /*0x6d0b*/
    if ( ((v3 + 24128) & 0xFF70) != 0 )
    {
      if ( (unsigned __int16)(v3 + 25280) <= 8u && (n335 = 335, _bittest(&n335, v4 + 25280)) )
      {
        n3_1 = 2; /*0x6d36*/
      }
      else
      {
        DebugPrint(0x80000000, "Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", (unsigned __int16)v4);
        Assert( /*0x6d65*/
          (__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
          252,
          (__int64)"((BOOLEAN)(0==1))");
      }
    }
    else
    {
      n3_1 = 1; /*0x6d6c*/
    }
    n3_0 = n3_1; /*0x6d71*/
    return n3_1; /*0x6d77*/
  }
  return n3; /*0x6d79*/
}


// Function: SetMem32Raw @ 0x6dd0 (0x5d bytes)
// Index: 102/103

int *__fastcall SetMem32Raw(int *buf, int value, unsigned __int64 n100)
{
  int *buf_1; // rdi
  int value_1; // eax
  unsigned __int64 n100_1; // rcx
  __int16 value_2; // bx
  int v7; // eax
  __int64 v8; // rdx
  char n100_2; // dl
  unsigned __int64 i; // rcx

  buf_1 = buf; /*0x6dd3*/
  value_1 = value; /*0x6dd6*/
  n100_1 = n100; /*0x6dd9*/
  BYTE1(value_1) = value; /*0x6dea*/
  value_2 = value_1; /*0x6dec*/
  v7 = value_1 << 16; /*0x6def*/
  LOWORD(v7) = value_2; /*0x6df3*/
  if ( n100 >= 4 ) /*0x6dfa*/
  {
    v8 = (unsigned __int8)buf_1 & 3; /*0x6dff*/
    if ( ((unsigned __int8)buf_1 & 3) != 0 ) /*0x6e03*/
    {
      memset(buf_1, value_2, 4 - v8); /*0x6e12*/
      buf_1 = (int *)((char *)buf_1 + 4 - v8); /*0x6e12*/
      n100_1 = n100 - (4 - v8); /*0x6e14*/
    }
    n100_2 = n100_1; /*0x6e17*/
    for ( i = n100_1 >> 2; i; --i ) /*0x6e1a*/
      *buf_1++ = v7; /*0x6e1e*/
    n100_1 = n100_2 & 3; /*0x6e24*/
  }
  memset(buf_1, value_2, n100_1); /*0x6e27*/
  return buf; /*0x6e2a*/
}


// Function: CopyMemWithAsm @ 0x6e30 (0xb0 bytes)
// Index: 103/103

char *__fastcall CopyMemWithAsm(char *dst, char *src, unsigned __int64 n8)
{
  unsigned __int64 dst_1; // rdi
  unsigned __int64 n8_1; // rcx
  char v10; // dl
  char *n8_2; // rax
  unsigned __int64 count; // rax
  unsigned __int64 count_1; // rbx
  char n8_3; // al
  unsigned __int64 v15; // rcx
  unsigned __int64 n8_4; // rax

  __asm { pushf } /*0x6e33*/
  dst_1 = (unsigned __int64)dst; /*0x6e39*/
  n8_1 = n8; /*0x6e3c*/
  v10 = 0; /*0x6e3f*/
  n8_2 = &src[-dst_1]; /*0x6e44*/
  if ( (unsigned __int64)src < dst_1 ) /*0x6e47*/
  {
    n8_2 = (char *)(dst_1 - (_QWORD)src); /*0x6e4d*/
    if ( (unsigned __int64)&src[n8] >= dst_1 ) /*0x6e53*/
    {
      src += n8; /*0x6e55*/
      dst_1 += n8; /*0x6e58*/
      v10 = 1; /*0x6e5c*/
    }
  }
  if ( n8 < 8 || (unsigned __int64)n8_2 < 8 ) /*0x6e69*/
    goto LABEL_19; /*0x6e69*/
  count = (unsigned __int8)src & 7; /*0x6e71*/
  count_1 = dst_1 & 7; /*0x6e75*/
  if ( v10 ) /*0x6e7b*/
  {
    --src; /*0x6e7d*/
    --dst_1; /*0x6e80*/
  }
  if ( count == count_1 && count ) /*0x6e8b*/
  {
    if ( !v10 ) /*0x6e8f*/
      count = 8 - count; /*0x6e94*/
    qmemcpy((void *)dst_1, src, count); /*0x6e9d*/
    src += count; /*0x6e9d*/
    dst_1 += count; /*0x6e9d*/
    n8_1 = n8 - count; /*0x6e9f*/
  }
  if ( v10 ) /*0x6ea4*/
  {
    src -= 7; /*0x6ea6*/
    dst_1 -= 7LL; /*0x6eaa*/
  }
  n8_3 = n8_1; /*0x6eae*/
  v15 = n8_1 >> 3; /*0x6eb1*/
  qmemcpy((void *)dst_1, src, 8 * v15); /*0x6eb5*/
  src += 8 * v15; /*0x6eb5*/
  dst_1 += 8 * v15; /*0x6eb5*/
  n8_4 = n8_3 & 7; /*0x6eb8*/
  if ( n8_4 ) /*0x6ebc*/
  {
    if ( v10 ) /*0x6ec0*/
    {
      src += 8; /*0x6ec2*/
      dst_1 += 8LL; /*0x6ec6*/
    }
    n8_1 = n8_4; /*0x6eca*/
LABEL_19:
    if ( v10 ) /*0x6ecf*/
    {
      --src; /*0x6ed1*/
      --dst_1; /*0x6ed4*/
    }
    qmemcpy((void *)dst_1, src, n8_1); /*0x6ed7*/
  }
  __asm { popf } /*0x6ed9*/
  return dst; /*0x6edc*/
}