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

//
// IpmiRedirFru - UEFI Module
// Total functions: 50
//

// Function: InternalCopyMem @ 0x1000 (0x42 bytes)

char *__fastcall InternalCopyMem(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; /*0x1010*/
  if ( src < dst && &src[count - 1] >= dst ) /*0x1018*/
  {
    src_1 = &src[count - 1]; /*0x1030*/
    dst_2 = &dst[count - 1]; /*0x1033*/
  }
  else
  {
    count_1 = count; /*0x101a*/
    count &= 7u; /*0x101d*/
    count_1 >>= 3; /*0x1024*/
    qmemcpy(dst, src, 8 * count_1); /*0x1028*/
    src_1 = &src[8 * count_1]; /*0x1028*/
    dst_2 = &dst[8 * count_1]; /*0x1028*/
  }
  qmemcpy(dst_2, src_1, count); /*0x103c*/
  return dst_1; /*0x103f*/
}


// Function: InternalZeroMem @ 0x1050 (0x20 bytes)

char *__fastcall InternalZeroMem(char *buf, unsigned __int64 a2)
{
  memset(buf, 0, 8 * (a2 >> 3)); /*0x1066*/
  memset(&buf[8 * (a2 >> 3)], 0, a2 & 7); /*0x106b*/
  return buf; /*0x106e*/
}


// Function: _ModuleEntryPoint @ 0x1114 (0x26 bytes)

EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  double v2; // xmm2_8
  __int64 v3; // rdx
  __int64 v4; // rcx
  signed __int64 v5; // rbx

  UefiBootServicesTableLibConstructor((__int64)ImageHandle, SystemTable); /*0x111a*/
  v5 = FruDriverInit(v4, v3, v2); /*0x1124*/
  if ( v5 < 0 ) /*0x112a*/
    AssertCpuDeadLoop(); /*0x112c*/
  return v5; /*0x1134*/
}


// Function: UefiBootServicesTableLibConstructor @ 0x113c (0x41b bytes)

void __fastcall UefiBootServicesTableLibConstructor(__int64 ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  EFI_BOOT_SERVICES *BootServices; // r10
  __int64 BootServices_1; // r10
  __int64 v5; // rax
  __int64 v6; // rax
  __int64 v7; // rbx
  signed __int64 v8; // rax
  __int64 v9; // rbx
  __int64 v10; // rax
  __int64 v11; // rax
  __int64 v12; // rbx
  _WORD *v13; // rax
  _BYTE *v14; // rax
  __int16 callerseflags_w; // bx
  bool v16; // bl
  unsigned __int32 v17; // edi
  unsigned __int32 i; // eax

  ::ImageHandle = ImageHandle; /*0x1154*/
  if ( !ImageHandle ) /*0x1168*/
    InternalDebugAssert( /*0x1177*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
      51,
      (__int64)"gImageHandle != ((void *) 0)");
  ::SystemTable = (__int64)SystemTable; /*0x117c*/
  if ( !SystemTable ) /*0x1186*/
    InternalDebugAssert( /*0x1195*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
      57,
      (__int64)"gST != ((void *) 0)");
  ::BootServices = (__int64)SystemTable->BootServices; /*0x119e*/
  if ( !::BootServices ) /*0x11a8*/
    InternalDebugAssert( /*0x11b7*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
      63,
      (__int64)"gBS != ((void *) 0)");
  RuntimeServices = (__int64)SystemTable->RuntimeServices; /*0x11c0*/
  if ( !RuntimeServices ) /*0x11ca*/
    InternalDebugAssert( /*0x11dd*/
      (__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeServicesTableLib\\UefiRuntimeServicesTableLib.c",
      47,
      (__int64)"gRT != ((void *) 0)");
  BootServices = SystemTable->BootServices; /*0x11ed*/
  RuntimeServices_0 = (__int64)SystemTable->RuntimeServices; /*0x11f4*/
  BootServices_0 = (__int64)BootServices; /*0x1207*/
  ((void (__fastcall *)(__int64, __int64, void (*)()))BootServices->CreateEvent)(513, 8, sub_3E1C); /*0x1219*/
  (*(void (__fastcall **)(__int64, __int64, __int64 (__fastcall *)(), _QWORD, __int64 *))(BootServices_0 + 80))( /*0x1241*/
    1610613250,
    8,
    InternalRuntimeCleanup,
    0,
    &qword_70D0);
  AssertCpuDeadLoop_2(); /*0x1244*/
  if ( !RuntimeServices ) /*0x1258*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 95, (__int64)"gRT != ((void *) 0)"); /*0x1267*/
  BootServices_1 = ::BootServices; /*0x126c*/
  if ( !::BootServices ) /*0x1276*/
  {
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 96, (__int64)"gBS != ((void *) 0)"); /*0x1286*/
    BootServices_1 = ::BootServices; /*0x128b*/
  }
  RuntimeServices_1 = RuntimeServices; /*0x12a0*/
  v5 = (*(__int64 (__fastcall **)(__int64, __int64, __int64 (__fastcall *)()))(BootServices_1 + 368))(512, 16, InternalRuntimeNotifySignal); /*0x12ce*/
  if ( v5 < 0 ) /*0x12eb*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x12f5*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 111, (__int64)"!EFI_ERROR (Status)"); /*0x1305*/
  }
  v6 = (*(__int64 (__fastcall **)(__int64, __int64, void (*)(), _QWORD, void *, __int64 *))(::BootServices + 368))( /*0x133b*/
         512,
         16,
         nullsub_1,
         0,
         &unk_7060,
         &qword_7140);
  v7 = v6; /*0x1341*/
  if ( v6 < 0 ) /*0x1347*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v6); /*0x1352*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 122, (__int64)"!EFI_ERROR (Status)"); /*0x1362*/
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v7); /*0x1370*/
    InternalDebugAssert( /*0x1384*/
      (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\AmiIpmiPkg\\Ipmi\\IpmiRedirFru\\IpmiRedirFru\\DEBUG\\AutoGen.c",
      382,
      (__int64)"!EFI_ERROR (Status)");
  }
  v8 = InternalGetSystemConfigurationTable(src, &qword_70F8); /*0x1397*/
  v9 = v8; /*0x139c*/
  if ( v8 < 0 ) /*0x13a2*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v8); /*0x13ad*/
    InternalDebugAssert( /*0x13c1*/
      (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
      64,
      (__int64)"!EFI_ERROR (Status)");
  }
  if ( !qword_70F8 ) /*0x13ce*/
    InternalDebugAssert( /*0x13e3*/
      (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
      65,
      (__int64)"gDS != ((void *) 0)");
  if ( v9 < 0 ) /*0x13eb*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v9); /*0x13f6*/
    InternalDebugAssert( /*0x140a*/
      (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\AmiIpmiPkg\\Ipmi\\IpmiRedirFru\\IpmiRedirFru\\DEBUG\\AutoGen.c",
      385,
      (__int64)"!EFI_ERROR (Status)");
  }
  v10 = AssertCpuDeadLoop_1(); /*0x140f*/
  qword_7110 = (*(__int64 (__fastcall **)(__int64))(v10 + 32))(5); /*0x141c*/
  v11 = (*(__int64 (__fastcall **)(__int64, __int64, __int64 (__fastcall *)(), _QWORD, void *, __int64 *))(::BootServices + 368))( /*0x1454*/
          512,
          16,
          InternalPciExpressCleanup,
          0,
          &unk_7070,
          &qword_7120);
  v12 = v11; /*0x145a*/
  if ( v11 < 0 ) /*0x1460*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v11); /*0x146b*/
    InternalDebugAssert( /*0x147f*/
      (__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
      141,
      (__int64)"!EFI_ERROR (Status)");
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v12); /*0x148d*/
    InternalDebugAssert( /*0x14a1*/
      (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\AmiIpmiPkg\\Ipmi\\IpmiRedirFru\\IpmiRedirFru\\DEBUG\\AutoGen.c",
      388,
      (__int64)"!EFI_ERROR (Status)");
  }
  if ( *(char *)InternalPciExpressRead(1024068) >= 0 ) /*0x14b6*/
  {
    v13 = (_WORD *)InternalPciExpressRead(1024064); /*0x14bb*/
    InternalIoWrite16(v13); /*0x14c3*/
    v14 = (_BYTE *)InternalPciExpressRead(1024068); /*0x14ca*/
    *v14 |= 0x80u; /*0x14d4*/
  }
  callerseflags_w = _getcallerseflags_w(); /*0x14db*/
  disable_w(); /*0x14de*/
  v16 = (callerseflags_w & 0x200) != 0; /*0x14ed*/
  v17 = InternalIoRead32(0x508u) & 0xFFFFFF; /*0x14f7*/
  _rdtsc_w(); /*0x14fd*/
  for ( i = InternalIoRead32(0x508u); ((v17 + 357 - i) & 0x800000) == 0; i = InternalIoRead32(0x508u) ) /*0x1504*/
    mm_pause_w(); /*0x1510*/
  _rdtsc_w(); /*0x1529*/
  if ( v16 ) /*0x1530*/
    enable_w(); /*0x1532*/
  else
    disable_w(); /*0x1539*/
}


// Function: AssertCpuDeadLoop @ 0x1558 (0x185 bytes)

__int64 AssertCpuDeadLoop()
{
  __int64 v0; // rax
  __int64 v1; // rbx
  __int64 BootServices; // rax
  __int64 v3; // rax
  __int64 v4; // rax
  __int64 v5; // rbx

  if ( qword_7100 ) /*0x1577*/
    AssertCpuDeadLoop_3(); /*0x1579*/
  v0 = (*(__int64 (__fastcall **)(__int64))(BootServices + 112))(qword_7120); /*0x158c*/
  v1 = v0; /*0x15a2*/
  if ( v0 < 0 ) /*0x15a8*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v0); /*0x15b2*/
    InternalDebugAssert( /*0x15c6*/
      (__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
      178,
      (__int64)"!EFI_ERROR (Status)");
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x15d3*/
    InternalDebugAssert( /*0x15e7*/
      (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\AmiIpmiPkg\\Ipmi\\IpmiRedirFru\\IpmiRedirFru\\DEBUG\\AutoGen.c",
      428,
      (__int64)"!EFI_ERROR (Status)");
  }
  BootServices = BootServices; /*0x15ec*/
  if ( !BootServices ) /*0x15f6*/
  {
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 151, (__int64)"gBS != ((void *) 0)"); /*0x160b*/
    BootServices = BootServices; /*0x1610*/
  }
  v3 = (*(__int64 (__fastcall **)(__int64))(BootServices + 112))(qword_7130); /*0x161e*/
  if ( v3 < 0 ) /*0x1624*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v3); /*0x162f*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 153, (__int64)"!EFI_ERROR (Status)"); /*0x1643*/
  }
  v4 = (*(__int64 (__fastcall **)(__int64))(BootServices + 112))(qword_7140); /*0x1656*/
  v5 = v4; /*0x1659*/
  if ( v4 < 0 ) /*0x165f*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0x166a*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeLib\\RuntimeLib.c", 156, (__int64)"!EFI_ERROR (Status)"); /*0x167e*/
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x168c*/
    InternalDebugAssert( /*0x16a0*/
      (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\AmiIpmiPkg\\Ipmi\\IpmiRedirFru\\IpmiRedirFru\\DEBUG\\AutoGen.c",
      431,
      (__int64)"!EFI_ERROR (Status)");
  }
  (*(void (__fastcall **)(__int64))(BootServices_0 + 112))(qword_70C8); /*0x16b3*/
  return (*(__int64 (__fastcall **)(__int64))(BootServices_0 + 112))(qword_70D0);
}


// Function: FruProtocolCleanup @ 0x16e0 (0x71 bytes)

__int64 FruProtocolCleanup()
{
  (*(void (__fastcall **)(_QWORD, __int64))(RuntimeServices + 64))(0, qword_7148 + 479); /*0x16fb*/
  (*(void (__fastcall **)(_QWORD, __int64))(RuntimeServices + 64))(0, qword_7148 + 487); /*0x1715*/
  (*(void (__fastcall **)(_QWORD, __int64))(RuntimeServices + 64))(0, qword_7148 + 495); /*0x172f*/
  return (*(__int64 (__fastcall **)(_QWORD, __int64))(RuntimeServices + 64))(0, qword_7148 + 503);
}


// Function: FruGetInventoryAreaInfo @ 0x1754 (0xc6 bytes)

unsigned __int64 __fastcall FruGetInventoryAreaInfo(__int64 a1, __int64 a2, char *dst, _QWORD *a4, _QWORD *a5)
{
  bool v5; // zf
  __int64 v9; // rbx
  _DWORD src[4]; // [rsp+20h] [rbp-10h] BYREF

  src[0] = 892468678; /*0x1776*/
  v5 = *(_QWORD *)(a1 - 479) == 2020766310; /*0x177d*/
  src[1] = 1288834734; /*0x178a*/
  src[2] = 1214228144; /*0x1794*/
  v9 = a1; /*0x179b*/
  src[3] = 149151648; /*0x179e*/
  if ( v5 ) /*0x17a5*/
    v9 = a1 - 479; /*0x17c1*/
  else
    InternalDebugAssert((__int64)"e:\\hs\\AmiIpmiPkg\\Ipmi\\IpmiRedirFru\\IpmiRedirFru.c", 129, (__int64)"CR has Bad Signature"); /*0x17ba*/
  if ( a2 + 1 > (unsigned __int64)*(unsigned __int8 *)(v9 + 9) ) /*0x17cf*/
    return 0x8000000000000011uLL; /*0x17d1*/
  InternalCopyMemWrapper(dst, (char *)src, 0x10u); /*0x17ea*/
  *a4 = 1; /*0x17f3*/
  *a5 = 0; /*0x17fa*/
  return 0; /*0x1814*/
}


// Function: FruReadData @ 0x181c (0xa9 bytes)

__int64 __fastcall FruReadData(__int64 a1, char *dst, _QWORD *a3, _QWORD *a4)
{
  bool v4; // zf
  __int64 v8; // rbx
  _DWORD src[4]; // [rsp+20h] [rbp-10h] BYREF

  src[0] = -1431216104; /*0x183e*/
  v4 = *(_QWORD *)(a1 - 479) == 2020766310; /*0x1845*/
  src[1] = 1147234205; /*0x1852*/
  src[2] = 216473786; /*0x185c*/
  v8 = a1; /*0x1863*/
  src[3] = -1687517449; /*0x1866*/
  if ( v4 ) /*0x186d*/
    v8 = a1 - 479; /*0x1889*/
  else
    InternalDebugAssert((__int64)"e:\\hs\\AmiIpmiPkg\\Ipmi\\IpmiRedirFru\\IpmiRedirFru.c", 169, (__int64)"CR has Bad Signature"); /*0x1882*/
  InternalCopyMemWrapper(dst, (char *)src, 0x10u); /*0x1899*/
  *a3 = 0; /*0x189e*/
  *a4 = *(unsigned __int8 *)(v8 + 9); /*0x18b5*/
  return 0; /*0x18bf*/
}


// Function: FruReadDataCompletion @ 0x18c8 (0x186 bytes)

__int64 __fastcall FruReadDataCompletion(__int64 a1, __int64 n127, __int16 a3, unsigned __int8 *a4, __int64 a5)
{
  unsigned __int8 *v5; // rbx
  unsigned __int16 v6; // r14
  char n3; // si
  __int64 v8; // rdi
  bool v9; // zf
  __int64 result; // rax
  __int16 v12; // ax
  int v13; // [rsp+28h] [rbp-D8h]
  char n127_1; // [rsp+40h] [rbp-C0h] BYREF
  __int16 v15; // [rsp+41h] [rbp-BFh]
  unsigned __int8 n127_2; // [rsp+43h] [rbp-BDh]
  unsigned __int8 n127_3; // [rsp+50h] [rbp-B0h] BYREF
  char src[255]; // [rsp+51h] [rbp-AFh] BYREF
  char v19; // [rsp+188h] [rbp+88h] BYREF

  v5 = a4; /*0x18ec*/
  n127_1 = 0; /*0x18ef*/
  v6 = 0; /*0x18f4*/
  v15 = 0; /*0x18f8*/
  n3 = 3; /*0x18fd*/
  n127_2 = 0; /*0x1900*/
  v8 = 0; /*0x1904*/
  if ( *(_QWORD *)a4 && a5 ) /*0x1917*/
  {
    v9 = *(_QWORD *)a4 == 0; /*0x191d*/
    n127_1 = n127; /*0x1920*/
    v15 = a3; /*0x1924*/
    while ( !v9 ) /*0x192a*/
    {
      if ( *(_QWORD *)v5 <= 0x7Fu ) /*0x1934*/
        n127_2 = *v5; /*0x193f*/
      else
        n127_2 = 127; /*0x1936*/
      while ( 1 ) /*0x194a*/
      {
        v19 = -1; /*0x194a*/
        LOBYTE(a4) = 17; /*0x1956*/
        LOBYTE(n127) = 10; /*0x1966*/
        LOBYTE(v13) = 4; /*0x196d*/
        result = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD, unsigned __int8 *, char *, int, unsigned __int8 *, char *))(qword_7090 + 16))( /*0x1981*/
                   qword_7090,
                   n127,
                   0,
                   a4,
                   &n127_1,
                   v13,
                   &n127_3,
                   &v19);
        if ( result < 0 ) /*0x1987*/
          goto LABEL_18; /*0x1987*/
        if ( *(_BYTE *)(qword_7090 + 8) != 0x81 ) /*0x1998*/
          break; /*0x1998*/
        if ( !n3-- ) /*0x199a*/
        {
          result = 0x8000000000000006uLL; /*0x1a0e*/
LABEL_18:
          *(_QWORD *)v5 = v8; /*0x1a18*/
          return result; /*0x1a1b*/
        }
        InternalMicroSecondDelay(0x1A37Au); /*0x19aa*/
      }
      n127 = n127_3; /*0x19b5*/
      if ( n127_3 > n127_2 ) /*0x19be*/
        n127 = n127_2; /*0x19c0*/
      v12 = *(_WORD *)v5; /*0x19c3*/
      v15 += (unsigned __int8)n127; /*0x19c9*/
      v8 += (unsigned __int8)n127; /*0x19d5*/
      *(_QWORD *)v5 = (unsigned __int16)(v12 - (unsigned __int8)n127); /*0x19db*/
      n127_3 = n127; /*0x19de*/
      if ( (_BYTE)n127 ) /*0x19e4*/
      {
        InternalCopyMemWrapper((char *)(a5 + v6), src, (unsigned __int8)n127); /*0x19f6*/
        LOBYTE(n127) = n127_3; /*0x19fb*/
      }
      v6 += (unsigned __int8)n127; /*0x1a02*/
      v9 = *(_QWORD *)v5 == 0; /*0x1a06*/
    }
    *(_QWORD *)v5 = v8; /*0x1a1d*/
    return 0; /*0x1a20*/
  }
  else
  {
    *(_QWORD *)a4 = 0; /*0x1a24*/
    return 0x8000000000000002uLL; /*0x1a27*/
  }
}


// Function: FruWriteData @ 0x1a50 (0x135 bytes)

__int64 __fastcall FruWriteData(__int64 a1, __int64 a2, __int16 a3, unsigned __int8 *a4, __int64 a5)
{
  unsigned __int8 *v5; // rbx
  unsigned __int16 v6; // r14
  char n3; // si
  __int64 v8; // rbp
  unsigned __int8 n127; // di
  char v10; // di
  __int64 result; // rax
  unsigned __int8 v13; // al
  unsigned __int8 v14; // al
  int v15; // [rsp+28h] [rbp-140h]
  char v16; // [rsp+40h] [rbp-128h] BYREF
  __int16 v17; // [rsp+41h] [rbp-127h]
  char dst[293]; // [rsp+43h] [rbp-125h] BYREF
  char v19; // [rsp+178h] [rbp+10h] BYREF
  unsigned __int8 v20; // [rsp+180h] [rbp+18h] BYREF

  v16 = a2; /*0x1a66*/
  v5 = a4; /*0x1a6a*/
  v6 = 0; /*0x1a6d*/
  n3 = 3; /*0x1a71*/
  v8 = 0; /*0x1a74*/
  v17 = a3; /*0x1a77*/
  if ( *(_QWORD *)a4 ) /*0x1a7d*/
  {
LABEL_2:
    n127 = 127; /*0x1a86*/
    if ( *(_QWORD *)v5 <= 0x7Fu ) /*0x1a8d*/
      n127 = *v5; /*0x1a8f*/
    if ( n127 ) /*0x1a99*/
      InternalCopyMemWrapper(dst, (char *)(a5 + v6), n127); /*0x1aac*/
    v10 = n127 + 3; /*0x1ab1*/
    while ( 1 ) /*0x1abd*/
    {
      v19 = 1; /*0x1abd*/
      LOBYTE(a4) = 18; /*0x1aca*/
      LOBYTE(a2) = 10; /*0x1add*/
      LOBYTE(v15) = v10; /*0x1ae4*/
      result = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD, unsigned __int8 *, char *, int, unsigned __int8 *, char *))(qword_7090 + 16))( /*0x1af8*/
                 qword_7090,
                 a2,
                 0,
                 a4,
                 &v16,
                 v15,
                 &v20,
                 &v19);
      if ( result < 0 ) /*0x1afe*/
        break; /*0x1afe*/
      if ( *(_BYTE *)(qword_7090 + 8) == 0x80 ) /*0x1b07*/
      {
        result = 0x8000000000000008uLL; /*0x1b79*/
        break; /*0x1b83*/
      }
      if ( *(_BYTE *)(qword_7090 + 8) != 0x81 ) /*0x1b11*/
      {
        v13 = *v5; /*0x1b32*/
        v8 += v20; /*0x1b34*/
        v17 += v20; /*0x1b37*/
        v14 = v13 - v20; /*0x1b3c*/
        v6 += v20; /*0x1b3e*/
        a2 = v14; /*0x1b42*/
        *(_QWORD *)v5 = v14; /*0x1b45*/
        if ( v14 ) /*0x1b4a*/
          goto LABEL_2; /*0x1b4a*/
        goto LABEL_13; /*0x1b4a*/
      }
      if ( !n3-- ) /*0x1b13*/
      {
        result = 0x8000000000000006uLL; /*0x1b6d*/
        break; /*0x1b77*/
      }
      InternalMicroSecondDelay(0x1A37Au); /*0x1b23*/
    }
  }
  else
  {
LABEL_13:
    result = 0; /*0x1b50*/
  }
  *(_QWORD *)v5 = v8; /*0x1b53*/
  return result; /*0x1b5e*/
}


// Function: FruDriverInit @ 0x1b88 (0x1b0 bytes)

unsigned __int64 __fastcall FruDriverInit(__int64 a1, __int64 a2, double a3)
{
  char *v3; // rax
  __int64 v5; // rdx
  __int64 v6; // rdi
  __int64 v7; // r9
  char v8; // bl
  __int64 v9; // [rsp+40h] [rbp-38h]
  _QWORD v10[2]; // [rsp+48h] [rbp-30h] BYREF
  char v11; // [rsp+58h] [rbp-20h] BYREF
  __int64 v12; // [rsp+59h] [rbp-1Fh]
  int v13; // [rsp+61h] [rbp-17h]
  __int16 v14; // [rsp+65h] [rbp-13h]
  __int64 v15; // [rsp+A8h] [rbp+30h] BYREF
  char v16; // [rsp+B0h] [rbp+38h]
  __int16 v17; // [rsp+B8h] [rbp+40h]

  v15 = a2; /*0x1b88*/
  v17 = 0; /*0x1ba5*/
  LOWORD(v9) = 0; /*0x1bae*/
  *(_DWORD *)((char *)&v9 + 2) = 0; /*0x1bb2*/
  v16 = -1; /*0x1bb8*/
  v11 = 0; /*0x1bbc*/
  v12 = 0; /*0x1bc0*/
  v13 = 0; /*0x1bc4*/
  v14 = 0; /*0x1bc7*/
  LOBYTE(v15) = 15; /*0x1bcb*/
  v10[1] = 0; /*0x1bcf*/
  v3 = InternalAllocateZeroPool(6, 0x1FFu); /*0x1bd3*/
  qword_7148 = (__int64)v3; /*0x1bd8*/
  if ( !v3 ) /*0x1be2*/
    return 0x8000000000000009uLL; /*0x1be4*/
  *((_WORD *)v3 + 4) = 67; /*0x1bfa*/
  *(_QWORD *)(v3 + 479) = FruGetInventoryAreaInfo; /*0x1c00*/
  *(_QWORD *)v3 = 2020766310; /*0x1c15*/
  *(_QWORD *)(v3 + 487) = FruReadData; /*0x1c1c*/
  *(_QWORD *)(v3 + 495) = FruReadDataCompletion; /*0x1c2c*/
  *(_QWORD *)(v3 + 503) = FruWriteData; /*0x1c3a*/
  v6 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_7040, 0, &qword_7090); /*0x1c55*/
  v8 = 1; /*0x1c58*/
  if ( v6 >= 0 ) /*0x1c5d*/
  {
    LOBYTE(v7) = 1; /*0x1c63*/
    LOBYTE(v5) = 6; /*0x1c72*/
    v6 = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD, __int64, _QWORD, _BYTE, char *, __int64 *, __int64))(qword_7090 + 16))( /*0x1c90*/
           qword_7090,
           v5,
           0,
           v7,
           0,
           0,
           &v11,
           &v15,
           v9);
    if ( v6 >= 0 ) /*0x1c96*/
    {
      v8 = 0; /*0x1c98*/
      v10[0] = 0; /*0x1cbb*/
      v6 = (*(__int64 (__fastcall **)(_QWORD *, void *, _QWORD, __int64))(BootServices + 128))( /*0x1cc8*/
             v10,
             &unk_7030,
             0,
             qword_7148 + 479);
    }
  }
  LOBYTE(v5) = v8; /*0x1cd2*/
  FruProtocolProcess(qword_7148 + 479, v5, a3); /*0x1cdb*/
  if ( v6 >= 0 ) /*0x1ce3*/
    (*(void (__fastcall **)(__int64, __int64, __int64 (__fastcall *)()))(BootServices + 368))(512, 16, FruProtocolCleanup); /*0x1d22*/
  else
    AssertCpuDeadLoop_3(); /*0x1cec*/
  Assert(); /*0x1d28*/
  return 0; /*0x1d2f*/
}


// Function: IpmiRedirFruTimerCallback @ 0x1d38 (0x9e9 bytes)

char __fastcall IpmiRedirFruTimerCallback(__int64 a1)
{
  __int64 v2; // rbx
  _WORD *v3; // rax
  __int64 v4; // rdi
  __int64 v5; // rax
  char *src_1; // rbx
  __int64 v7; // rax
  __int16 *LENOVO_2; // rbx
  __int16 *LENOVO; // rsi
  __int16 *LENOVO_1; // r14
  __int64 v11; // rax
  __int16 *ThinkSystem__1; // rbx
  unsigned __int8 n16; // al
  unsigned __int64 v14; // rax
  __int64 v15; // rax
  __int16 *LENOVO_4; // rbx
  __int16 *LENOVO_3; // r14
  __int64 v18; // rax
  __int16 *LENOVO_6; // rbx
  __int16 *LENOVO_5; // r14
  _BYTE *v21; // rdi
  __int16 v22; // ax
  __int64 v23; // rax
  __int16 *LENOVO_8; // rbx
  __int16 *LENOVO_7; // r14
  __int64 v26; // rax
  __int16 *LENOVO_10; // rbx
  __int16 *LENOVO_9; // r14
  __int64 v29; // rax
  __int16 *LENOVO_12; // rbx
  __int16 *LENOVO_11; // r14
  __int64 v32; // rax
  __int16 *LENOVO_14; // rbx
  __int16 *LENOVO_13; // r14
  __int64 v35; // rax
  __int16 *LENOVO_16; // rbx
  __int16 *LENOVO_15; // r14
  __int64 v38; // rdi
  __int64 v39; // ra... [16543 chars total]


// Function: Assert @ 0x2724 (0xc4 bytes)

__int64 Assert()
{
  __int64 v0; // rax
  __int64 v1; // rax
  __int64 v3; // [rsp+40h] [rbp+8h]
  char v4; // [rsp+48h] [rbp+10h] BYREF

  v0 = (*(__int64 (__fastcall **)(__int64, __int64, char (__fastcall *)(__int64)))(BootServices + 80))(512, 8, IpmiRedirFruTimerCallback); /*0x274e*/
  if ( v0 < 0 ) /*0x2759*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v0); /*0x2767*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 167, (__int64)"!EFI_ERROR (Status)"); /*0x277f*/
  }
  v1 = (*(__int64 (__fastcall **)(void *, __int64, char *))(BootServices + 168))(&unk_7020, v3, &v4); /*0x279c*/
  if ( v1 < 0 ) /*0x27a5*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x27b4*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 179, (__int64)"!EFI_ERROR (Status)"); /*0x27cc*/
  }
  (*(void (__fastcall **)(__int64))(BootServices + 104))(v3); /*0x27dd*/
  return 0; /*0x27e2*/
}


// Function: InternalBase64Encode @ 0x27e8 (0xce bytes)

_WORD *__fastcall InternalBase64Encode(_WORD *a1, unsigned int *a2, unsigned __int64 i)
{
  unsigned __int64 v4; // r10
  _WORD *v5; // r11
  unsigned int *v6; // rbx
  unsigned __int64 v7; // rdi
  unsigned int v8; // edx
  __int64 n4; // rbp
  char v10; // al
  unsigned __int64 v11; // rbx
  unsigned int v12; // r11d
  unsigned __int64 v13; // r8
  _WORD *v14; // rdx
  char v15; // al

  v4 = 0; /*0x2815*/
  if ( i / 3 ) /*0x281b*/
  {
    v5 = a1; /*0x2820*/
    v6 = a2; /*0x2823*/
    v7 = i / 3; /*0x2826*/
    v4 = i / 3; /*0x2829*/
    do /*0x2857*/
    {
      v8 = *v6; /*0x282c*/
      n4 = 4; /*0x282e*/
      do /*0x284d*/
      {
        v10 = v8; /*0x2833*/
        v8 >>= 6; /*0x2835*/
        *v5++ = (v10 & 0x3F) + 32; /*0x2841*/
        --n4; /*0x2849*/
      }
      while ( n4 ); /*0x284d*/
      v6 = (unsigned int *)((char *)v6 + 3); /*0x284f*/
      --v7; /*0x2853*/
    }
    while ( v7 ); /*0x2857*/
  }
  v11 = 0; /*0x285d*/
  v12 = *(unsigned int *)((char *)a2 + 2 * v4 + v4); /*0x2860*/
  v13 = i % 3; /*0x2868*/
  if ( v13 ) /*0x286b*/
  {
    v14 = &a1[4 * v4]; /*0x286d*/
    v11 = v13; /*0x2871*/
    do /*0x288f*/
    {
      v15 = v12; /*0x2874*/
      v12 >>= 6; /*0x2877*/
      *v14++ = (v15 & 0x3F) + 32; /*0x2884*/
      --v13; /*0x288b*/
    }
    while ( v13 ); /*0x288f*/
  }
  a1[4 * v4 + v11] = 0; /*0x28a9*/
  return a1; /*0x28b1*/
}


// Function: InternalEncodeToDisplayString @ 0x28b8 (0xd6 bytes)

unsigned __int64 __fastcall InternalEncodeToDisplayString(__int64 a1, char **a2, char n2, unsigned __int8 i)
{
  __int64 v7; // rbx
  char *v9; // rax
  unsigned __int64 j; // rcx
  unsigned int v11; // eax
  char *v12; // rax

  if ( n2 == 2 ) /*0x28d8*/
  {
    v11 = (unsigned __int64)(11453246128LL * i) >> 32; /*0x2943*/
    v12 = InternalAllocateZeroPool(6, (int)(v11 + 2 + (v11 >> 31))); /*0x2950*/
    *a2 = v12; /*0x2955*/
    v7 = 0; /*0x2958*/
    if ( v12 ) /*0x295d*/
    {
      InternalBase64Encode(v12, (unsigned int *)(a1 + 1), i); /*0x296a*/
      return v7; /*0x296f*/
    }
    return 0x8000000000000009uLL; /*0x295d*/
  }
  if ( n2 != 3 ) /*0x28de*/
    return 0x8000000000000003uLL; /*0x28ea*/
  v9 = InternalAllocateZeroPool(6, 2LL * i + 2); /*0x2900*/
  *a2 = v9; /*0x2905*/
  v7 = 0; /*0x290b*/
  if ( !v9 ) /*0x2910*/
    return 0x8000000000000009uLL; /*0x2971*/
  for ( j = 0; j < i; ++j ) /*0x2917*/
    *(_WORD *)&v9[2 * j] = *(unsigned __int8 *)(a1 + j + 1); /*0x291e*/
  *(_WORD *)&v9[2 * j] = 0; /*0x292a*/
  return v7; /*0x2988*/
}


// Function: FruProtocolProcess @ 0x2990 (0xc64 bytes)

__int64 __fastcall FruProtocolProcess(__int64 a1, __int64 a2, double a3)
{
  __int64 v3; // r14
  _WORD *v4; // r12
  _WORD *v5; // r13
  _WORD *v6; // rdi
  __int64 result; // rax
  __int64 v8; // r15
  int v9; // eax
  __int16 v10; // bx
  char *v11; // rax
  char *v12; // rsi
  signed __int64 v13; // rax
  __int64 v14; // rax
  unsigned __int8 n16_2; // bl
  unsigned __int64 v16; // rbx
  char *v17; // rcx
  unsigned __int64 v18; // rax
  unsigned __int64 v19; // rax
  __int64 v20; // rdx
  unsigned __int64 v21; // r14
  char *v22; // rcx
  signed __int64 v23; // rax
  __int64 v24; // rax
  unsigned __int8 n16_3; // bl
  unsigned __int64 v26; // r14
  signed __int64 v27; // rax
  _WORD *v28; // rdi
  __int64 v29; // rax
  unsigned __int8 n16_4; // bl
  unsigned __int64 v31; // r14
  signed __int64 v32; // rax
  __int64 v33; // rax
  unsigned __int8 n16_5; // bl
  char *v35; // rcx
  signed __int64 v36; // rax
  char v37; // cl
  int v38; // eax
  __int16 v39; // bx
  char *v40; // rax
  char ... [20203 chars total]


// Function: AssertCpuDeadLoop_1 @ 0x35f4 (0x8c bytes)

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

  result = qword_70B8; /*0x35f8*/
  if ( !qword_70B8 ) /*0x3602*/
  {
    v1 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_7010, 0, &qword_70B8); /*0x361b*/
    if ( v1 < 0 ) /*0x3624*/
    {
      InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0x3635*/
      InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 78, (__int64)"!EFI_ERROR (Status)"); /*0x364d*/
    }
    result = qword_70B8; /*0x3652*/
    if ( !qword_70B8 ) /*0x365c*/
    {
      InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 79, (__int64)"mPcd != ((void *) 0)"); /*0x366f*/
      return qword_70B8; /*0x3674*/
    }
  }
  return result; /*0x367b*/
}


// Function: InternalPcdGetPtr @ 0x3680 (0x7c bytes)

__int64 __fastcall InternalPcdGetPtr(__int64 a1, _QWORD *a2, __int64 a3)
{
  __int64 v6; // rax

  if ( !a2 ) /*0x369b*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 1000, (__int64)"SizeOfBuffer != ((void *) 0)"); /*0x36b0*/
  if ( *a2 && !a3 ) /*0x36be*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 1003, (__int64)"Buffer != ((void *) 0)"); /*0x36d3*/
  v6 = AssertCpuDeadLoop_1(); /*0x36d8*/
  return (*(__int64 (__fastcall **)(__int64, _QWORD *, __int64))(v6 + 152))(a1, a2, a3);
}


// Function: InternalCopyMemWrapper @ 0x36fc (0x9e bytes)

char *__fastcall InternalCopyMemWrapper(char *dst, char *src, unsigned __int64 count)
{
  unsigned __int64 v3; // rbp

  v3 = count - 1; /*0x3719*/
  if ( count - 1 > -1 - (__int64)dst ) /*0x372f*/
    InternalDebugAssert( /*0x3742*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
      56,
      (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)DestinationBuffer)");
  if ( v3 > -1 - (__int64)src ) /*0x374d*/
    InternalDebugAssert( /*0x3762*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
      57,
      (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)SourceBuffer)");
  if ( dst == src ) /*0x376a*/
    return dst; /*0x376c*/
  else
    return InternalCopyMem(dst, src, count); /*0x377a*/
}


// Function: InternalZeroMemWrapper @ 0x379c (0x6e bytes)

char *__fastcall InternalZeroMemWrapper(char *buf, unsigned __int64 a2)
{
  if ( !a2 ) /*0x37af*/
    return buf; /*0x37b1*/
  if ( !buf ) /*0x37b9*/
    InternalDebugAssert( /*0x37cc*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
      53,
      (__int64)"Buffer != ((void *) 0)");
  if ( a2 > -(__int64)buf ) /*0x37da*/
    InternalDebugAssert( /*0x37ef*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
      54,
      (__int64)"Length <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)Buffer + 1)");
  return InternalZeroMem(buf, a2); /*0x3804*/
}


// Function: InternalCompareGuid @ 0x380c (0x67 bytes)

bool __fastcall InternalCompareGuid(char *src, char *src_1)
{
  __int128 v4; // rdi
  __int64 v5; // rbx

  *((_QWORD *)&v4 + 1) = InternalReadUnaligned64(src); /*0x382e*/
  v5 = InternalReadUnaligned64(src_1); /*0x383a*/
  *(_QWORD *)&v4 = InternalReadUnaligned64(src + 8); /*0x3846*/
  return v4 == __PAIR128__(v5, InternalReadUnaligned64(src_1 + 8)); /*0x386d*/
}


// Function: InternalStrCpy @ 0x3874 (0xd6 bytes)

__int64 __fastcall InternalStrCpy(_WORD *ThinkSystem_, __int16 *a2)
{
  __int64 ThinkSystem__1; // rbx
  __int64 ThinkSystem__2; // rax

  ThinkSystem__1 = (__int64)ThinkSystem_; /*0x3888*/
  if ( !ThinkSystem_ ) /*0x388e*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 56, (__int64)"Destination != ((void *) 0)"); /*0x38a1*/
  if ( (ThinkSystem__1 & 1) != 0 ) /*0x38a9*/
    InternalDebugAssert( /*0x38be*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      57,
      (__int64)"((UINTN) Destination & 0x00000001) == 0");
  if ( (ThinkSystem__1 - (__int64)a2) >> 1 <= InternalStrLen(a2) ) /*0x38d7*/
    InternalDebugAssert( /*0x38ec*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      62,
      (__int64)"(UINTN)(Destination - Source) > StrLen (Source)");
  if ( ((__int64)a2 - ThinkSystem__1) >> 1 <= InternalStrLen(a2) ) /*0x3905*/
    InternalDebugAssert( /*0x391a*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      63,
      (__int64)"(UINTN)(Source - Destination) > StrLen (Source)");
  ThinkSystem__2 = ThinkSystem__1; /*0x391f*/
  while ( *a2 ) /*0x3935*/
  {
    *(_WORD *)ThinkSystem__1 = *a2++; /*0x3924*/
    ThinkSystem__1 += 2; /*0x392b*/
  }
  *(_WORD *)ThinkSystem__1 = 0; /*0x3937*/
  return ThinkSystem__2; /*0x3944*/
}


// Function: InternalStrLen @ 0x394c (0x93 bytes)

unsigned __int64 __fastcall InternalStrLen(_WORD *a1)
{
  _WORD *v1; // rbx
  unsigned __int64 n0xF4240; // rdi

  v1 = a1; /*0x395d*/
  if ( !a1 ) /*0x3963*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 172, (__int64)"String != ((void *) 0)"); /*0x3978*/
  if ( ((unsigned __int8)v1 & 1) != 0 ) /*0x3980*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 173, (__int64)"((UINTN) String & 0x00000001) == 0"); /*0x3995*/
  n0xF4240 = 0; /*0x399a*/
  while ( *v1 ) /*0x39ca*/
  {
    if ( n0xF4240 >= 0xF4240 ) /*0x39a6*/
      InternalDebugAssert( /*0x39bb*/
        (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
        181,
        (__int64)"Length < _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength");
    ++v1; /*0x39c0*/
    ++n0xF4240; /*0x39c4*/
  }
  return n0xF4240; /*0x39d9*/
}


// Function: InternalStrCmp @ 0x39e0 (0x9e bytes)

__int64 __fastcall InternalStrCmp(_WORD *a1, _WORD *a2)
{
  _WORD *v3; // rbx

  v3 = a1; /*0x39f2*/
  if ( 2 * InternalStrLen(a1) == -2 ) /*0x3a05*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 252, (__int64)"StrSize (FirstString) != 0"); /*0x3a1a*/
  if ( 2 * InternalStrLen(a2) == -2 ) /*0x3a32*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 253, (__int64)"StrSize (SecondString) != 0"); /*0x3a47*/
  while ( *v3 && *v3 == *a2 ) /*0x3a51*/
  {
    ++v3; /*0x3a53*/
    ++a2; /*0x3a57*/
  }
  return (unsigned __int16)*v3 - (unsigned __int16)*a2; /*0x3a78*/
}


// Function: InternalUnicodeToAscii @ 0x3a80 (0x13a bytes)

_BYTE *__fastcall InternalUnicodeToAscii(_WORD *a1, _BYTE *a2)
{
  _BYTE *v2; // rdi
  _BYTE *v4; // rsi

  v2 = a2; /*0x3aa3*/
  if ( !a2 ) /*0x3aac*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 900, (__int64)"Destination != ((void *) 0)"); /*0x3abd*/
  if ( 2 * InternalStrLen(a1) == -2 ) /*0x3ad5*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 906, (__int64)"StrSize (Source) != 0"); /*0x3ae6*/
  if ( v2 - (_BYTE *)a1 < 2 * InternalStrLen(a1) + 2 ) /*0x3b04*/
    InternalDebugAssert( /*0x3b15*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      911,
      (__int64)"(UINTN) (Destination - (CHAR8 *) Source) >= StrSize (Source)");
  if ( (char *)a1 - v2 <= InternalStrLen(a1) ) /*0x3b2b*/
    InternalDebugAssert( /*0x3b3c*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
      912,
      (__int64)"(UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source)");
  v4 = v2; /*0x3b41*/
  while ( *a1 ) /*0x3b75*/
  {
    if ( *a1 >= 0x100u ) /*0x3b4e*/
      InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 921, (__int64)"*Source < 0x100"); /*0x3b5f*/
    *v2++ = *(_BYTE *)a1++; /*0x3b66*/
  }
  *v2 = 0; /*0x3b7a*/
  if ( InternalAsciiStrLen(v4) == -1 ) /*0x3b86*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 931, (__int64)"AsciiStrSize (ReturnValue) != 0"); /*0x3b97*/
  return v4; /*0x3bb3*/
}


// Function: InternalAsciiStrLen @ 0x3bbc (0x6b bytes)

unsigned __int64 __fastcall InternalAsciiStrLen(_BYTE *a1)
{
  _BYTE *v1; // rbx
  unsigned __int64 i; // rdi

  v1 = a1; /*0x3bc6*/
  if ( !a1 ) /*0x3bcc*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 1082, (__int64)"String != ((void *) 0)"); /*0x3be1*/
  for ( i = 0; *v1; ++i ) /*0x3be8*/
  {
    if ( i >= 0xF4240 ) /*0x3bf4*/
      InternalDebugAssert( /*0x3c09*/
        (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
        1090,
        (__int64)"Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength");
    ++v1; /*0x3c0e*/
  }
  return i; /*0x3c21*/
}


// Function: InternalCheckSumByte @ 0x3c28 (0x7c bytes)

char __fastcall InternalCheckSumByte(__int64 p_n3, unsigned __int64 n8)
{
  char v2; // bl
  unsigned __int64 i; // rax

  v2 = 0; /*0x3c37*/
  if ( !p_n3 ) /*0x3c42*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\CheckSum.c", 46, (__int64)"Buffer != ((void *) 0)"); /*0x3c55*/
  if ( n8 > -p_n3 ) /*0x3c63*/
    InternalDebugAssert( /*0x3c78*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\CheckSum.c",
      47,
      (__int64)"Length <= (0xFFFFFFFFFFFFFFFFULL - ((UINTN) Buffer) + 1)");
  for ( i = 0; i < n8; ++i ) /*0x3c83*/
    v2 += *(_BYTE *)(i + p_n3); /*0x3c85*/
  return -v2; /*0x3c9e*/
}


// Function: InternalReadUnaligned64 @ 0x3ca4 (0x2f bytes)

__int64 __fastcall InternalReadUnaligned64(char *src)
{
  if ( !src ) /*0x3cb0*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, (__int64)"Buffer != ((void *) 0)"); /*0x3cc5*/
  return *(_QWORD *)src; /*0x3ccd*/
}


// Function: InternalGetDebugProtocol @ 0x3cd4 (0x86 bytes)

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

  result = qword_70E0; /*0x3cde*/
  if ( !qword_70E0 ) /*0x3cea*/
  {
    if ( BootServices_0 /*0x3d18*/
      && (n0x10 = (*(__int64 (__fastcall **)(__int64))(BootServices_0 + 24))(31),
          (*(void (__fastcall **)(unsigned __int64))(BootServices_0 + 32))(n0x10),
          n0x10 <= 0x10) )
    {
      v2 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_7000, 0, &qword_70E0); /*0x3d31*/
      v3 = qword_70E0; /*0x3d37*/
      if ( v2 < 0 ) /*0x3d41*/
        v3 = 0; /*0x3d41*/
      qword_70E0 = v3; /*0x3d45*/
      return v3; /*0x3d4c*/
    }
    else
    {
      return 0; /*0x3cf8*/
    }
  }
  return result; /*0x3d54*/
}


// Function: InternalDebugPrint @ 0x3d5c (0x80 bytes)

__int64 InternalDebugPrint(__int64 a1, const char *a2, ...)
{
  __int64 result; // rax
  __int64 v4; // r8
  __int64 (__fastcall **v5)(__int64, const char *, __int64 *); // r9
  unsigned __int8 v6; // al
  unsigned __int8 n3; // al
  int n113; // edx
  va_list va; // [rsp+40h] [rbp+18h] BYREF

  va_start(va, a2);
  result = InternalGetDebugProtocol(); /*0x3d73*/
  v4 = 0; /*0x3d78*/
  v5 = (__int64 (__fastcall **)(__int64, const char *, __int64 *))result; /*0x3d7b*/
  if ( result ) /*0x3d81*/
  {
    v6 = __inbyte(0x70u); /*0x3d87*/
    __outbyte(0x70u, v6 & 0x80 | 0x4B); /*0x3d8c*/
    n113 = 113; /*0x3d8d*/
    n3 = __inbyte(0x71u); /*0x3d91*/
    LOBYTE(n113) = n3; /*0x3d92*/
    if ( n3 > 3u ) /*0x3d96*/
    {
      n113 = 3; /*0x3d9f*/
      if ( n113 ) /*0x3da5*/
        n113 = (unsigned __int8)n113; /*0x3da5*/
    }
    result = (unsigned int)(n113 - 1); /*0x3da8*/
    if ( (unsigned __int8)(n113 - 1) <= 0xFDu ) /*0x3dad*/
    {
      result = 2147483652LL; /*0x3db2*/
      v4 = 2147483718LL; /*0x3db7*/
      if ( (_BYTE)n113 == 1 ) /*0x3dbd*/
        v4 = 2147483652LL; /*0x3dbd*/
    }
    if ( (v4 & a1) != 0 ) /*0x3dc4*/
      return (*v5)(a1, a2, (__int64 *)va); /*0x3dd3*/
  }
  return result; /*0x3dd6*/
}


// Function: InternalDebugAssert @ 0x3ddc (0x3e bytes)

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

  result = InternalGetDebugProtocol(); /*0x3df4*/
  if ( result ) /*0x3dfc*/
    return (*(__int64 (__fastcall **)(__int64, __int64, __int64))(result + 8))(a1, a2, a3); /*0x3e07*/
  return result; /*0x3e14*/
}


// Function: InternalRuntimeCleanup @ 0x3e28 (0x26 bytes)

__int64 InternalRuntimeCleanup()
{
  __int64 result; // rax

  if ( qword_70E0 ) /*0x3e34*/
    return (*(__int64 (__fastcall **)(_QWORD, __int64 *))(RuntimeServices_0 + 64))(0, &qword_70E0); /*0x3e46*/
  return result; /*0x3e49*/
}


// Function: InternalAllocateZeroPool @ 0x3e50 (0x44 bytes)

char *__fastcall InternalAllocateZeroPool(__int64 a1, unsigned __int64 a2)
{
  __int64 v3; // rax
  char *buf; // rcx
  char *buf_1; // [rsp+40h] [rbp+18h] BYREF

  v3 = (*(__int64 (__fastcall **)(__int64, unsigned __int64, char **))(BootServices + 64))(a1, a2, &buf_1); /*0x3e65*/
  buf = buf_1; /*0x3e68*/
  if ( v3 < 0 ) /*0x3e72*/
    buf = 0; /*0x3e72*/
  buf_1 = buf; /*0x3e76*/
  if ( buf ) /*0x3e7e*/
    return InternalZeroMemWrapper(buf, a2); /*0x3e88*/
  return buf; /*0x3e8e*/
}


// Function: AssertCpuDeadLoop_3 @ 0x3e94 (0x44 bytes)

__int64 AssertCpuDeadLoop_3()
{
  __int64 result; // rax

  result = (*(__int64 (**)(void))(BootServices + 72))(); /*0x3e9f*/
  if ( result < 0 ) /*0x3ea5*/
  {
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", result); /*0x3eb6*/
    return InternalDebugAssert( /*0x3ece*/
             (__int64)"e:\\hs\\MdePkg\\Library\\UefiMemoryAllocationLib\\MemoryAllocationLib.c",
             819,
             (__int64)"!EFI_ERROR (Status)");
  }
  return result; /*0x3ed3*/
}


// Function: InternalGetSystemConfigurationTable @ 0x3ed8 (0xc4 bytes)

unsigned __int64 __fastcall InternalGetSystemConfigurationTable(char *src, _QWORD *a2)
{
  __int64 SystemTable; // rdi
  __int64 v5; // rbx
  __int64 i; // r14

  if ( !src ) /*0x3efa*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 97, (__int64)"TableGuid != ((void *) 0)"); /*0x3f0d*/
  if ( !a2 ) /*0x3f15*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 98, (__int64)"Table != ((void *) 0)"); /*0x3f28*/
  SystemTable = SystemTable; /*0x3f2d*/
  v5 = 0; /*0x3f34*/
  *a2 = 0; /*0x3f36*/
  if ( !*(_QWORD *)(SystemTable + 104) ) /*0x3f3a*/
    return 0x800000000000000EuLL; /*0x3f63*/
  for ( i = 0; !InternalCompareGuid(src, (char *)(i + *(_QWORD *)(SystemTable + 112))); i += 24 ) /*0x3f40*/
  {
    if ( (unsigned __int64)++v5 >= *(_QWORD *)(SystemTable + 104) ) /*0x3f61*/
      return 0x800000000000000EuLL; /*0x3f61*/
  }
  *a2 = *(_QWORD *)(*(_QWORD *)(SystemTable + 112) + 24 * v5 + 16); /*0x3f97*/
  return 0; /*0x3f81*/
}


// Function: AssertCpuDeadLoop_2 @ 0x3f9c (0x82 bytes)

__int64 AssertCpuDeadLoop_2()
{
  __int64 result; // rax
  signed __int64 _L_; // rax

  result = qword_70E8; /*0x3fa0*/
  if ( !qword_70E8 ) /*0x3faa*/
  {
    _L_ = InternalGetSystemConfigurationTable(&asc_7050, &qword_70E8); // "L" /*0x3fba*/
    if ( _L_ < 0 ) /*0x3fc2*/
    {
      InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", _L_); /*0x3fd3*/
      InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 54, (__int64)"!EFI_ERROR (Status)"); /*0x3feb*/
    }
    result = qword_70E8; /*0x3ff0*/
    if ( !qword_70E8 ) /*0x3ffa*/
    {
      InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 55, (__int64)"mHobList != ((void *) 0)"); /*0x400d*/
      return qword_70E8; /*0x4012*/
    }
  }
  return result; /*0x4019*/
}


// Function: InternalRuntimeNotifySignal @ 0x4024 (0x23 bytes)

__int64 InternalRuntimeNotifySignal()
{
  __int64 result; // rax

  result = (*(__int64 (__fastcall **)(_QWORD, __int64 *))(RuntimeServices + 64))(0, &RuntimeServices_1); /*0x4038*/
  byte_70F0 = 1; /*0x403b*/
  return result; /*0x4042*/
}


// Function: InternalPciExpressCleanup @ 0x4048 (0x6d bytes)

__int64 InternalPciExpressCleanup()
{
  __int64 result; // rax
  unsigned __int64 v1; // rbx
  __int64 v2; // rdi

  result = qword_7100; /*0x4052*/
  v1 = 0; /*0x4059*/
  if ( qword_7100 ) /*0x405e*/
  {
    if ( qword_7108 ) /*0x4067*/
    {
      v2 = 0; /*0x4069*/
      while ( 1 ) /*0x407b*/
      {
        (*(void (__fastcall **)(_QWORD, __int64))(RuntimeServices + 64))(0, v2 + result + 8); /*0x407b*/
        ++v1; /*0x407e*/
        v2 += 16; /*0x4081*/
        if ( v1 >= qword_7108 ) /*0x408c*/
          break; /*0x408c*/
        result = qword_7100; /*0x408e*/
      }
    }
    return (*(__int64 (__fastcall **)(_QWORD, __int64 *))(RuntimeServices + 64))(0, &qword_7100); /*0x40a7*/
  }
  return result; /*0x40af*/
}


// Function: InternalPciExpressRead @ 0x40b8 (0xc2 bytes)

__int64 __fastcall InternalPciExpressRead(__int64 n1024064)
{
  __int64 v2; // rbx
  unsigned __int64 v3; // rax
  _QWORD *v4; // rcx

  if ( (n1024064 & 0xFFFFFFFFF0000000uLL) != 0 ) /*0x40c8*/
    InternalDebugAssert( /*0x40dd*/
      (__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
      203,
      (__int64)"((Address) & ~0xfffffff) == 0");
  v2 = qword_7110 + n1024064; /*0x40e2*/
  v3 = 0; /*0x40e9*/
  if ( byte_70F0 ) /*0x40f1*/
  {
    if ( *(_QWORD *)(qword_7100 + 16 * qword_7118) == (v2 & 0xFFFFFFFFFFFFF000uLL) ) /*0x4112*/
    {
      return *(_QWORD *)(qword_7100 + 16 * qword_7118 + 8) + (v2 & 0xFFF); /*0x411a*/
    }
    else
    {
      if ( !qword_7108 ) /*0x412b*/
      {
LABEL_10:
        InternalDebugAssert( /*0x4141*/
          (__int64)"e:\\hs\\MdePkg\\Library\\DxeRuntimePciExpressLib\\PciExpressLib.c",
          246,
          (__int64)"((BOOLEAN)(0==1))");
        __debugbreak(); /*0x4159*/
      }
      v4 = (_QWORD *)qword_7100; /*0x412d*/
      while ( *v4 != (v2 & 0xFFFFFFFFFFFFF000uLL) ) /*0x4133*/
      {
        ++v3; /*0x4135*/
        v4 += 2; /*0x4138*/
        if ( v3 >= qword_7108 ) /*0x413f*/
          goto LABEL_10; /*0x413f*/
      }
      qword_7118 = v3; /*0x4163*/
      return *(_QWORD *)(qword_7100 + 16 * v3 + 8) + (v2 & 0xFFF); /*0x4173*/
    }
  }
  return v2; /*0x415d*/
}


// Function: InternalMicroSecondDelay @ 0x417c (0x73 bytes)

__int64 __fastcall InternalMicroSecondDelay(unsigned int n107386)
{
  unsigned int v1; // ebx
  unsigned int n0x400000; // edi
  unsigned __int32 v3; // esi
  __int64 result; // rax

  v1 = n107386 >> 22; /*0x4194*/
  n0x400000 = n107386 & 0x3FFFFF; /*0x419c*/
  do /*0x41d8*/
  {
    v3 = n0x400000 + (InternalIoRead32(0x508u) & 0xFFFFFF); /*0x41b2*/
    n0x400000 = 0x400000; /*0x41b4*/
    while ( ((v3 - InternalIoRead32(0x508u)) & 0x800000) == 0 ) /*0x41d0*/
      mm_pause_w(); /*0x41bb*/
    result = v1--; /*0x41d2*/
  }
  while ( (_DWORD)result ); /*0x41d8*/
  return result; /*0x41e9*/
}


// Function: AssertCpuDeadLoop_0 @ 0x41f0 (0x155 bytes)

__int64 __fastcall AssertCpuDeadLoop_0(unsigned __int16 a1, __int64 a2, double a3)
{
  __int64 v4; // rax
  __int64 v5; // rdi
  __int64 n62; // rdx
  __int64 v7; // rax
  __int64 v8; // rax
  char v10; // [rsp+58h] [rbp+10h] BYREF
  char v11; // [rsp+59h] [rbp+11h]
  unsigned __int8 v12; // [rsp+5Ah] [rbp+12h]
  __int64 v13; // [rsp+60h] [rbp+18h] BYREF
  __int64 n5; // [rsp+68h] [rbp+20h] BYREF

  v13 = 0; /*0x41f8*/
  InternalDebugPrint(64, "%a: Start\n", a3);
  v4 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_7030, 0, &v13); /*0x422e*/
  v5 = v4; /*0x4234*/
  if ( v4 >= 0 )
  {
    n5 = 5; /*0x4279*/
    while ( 1 )
    {
      v7 = (*(__int64 (__fastcall **)(__int64, _QWORD, _QWORD, __int64 *, char *))(v13 + 16))(v13, 0, a1, &n5, &v10); /*0x429b*/
      v5 = v7; /*0x429e*/
      if ( v7 < 0 ) /*0x42a4*/
        break; /*0x42a4*/
      if ( v10 == -64 )
      {
        v8 = AssertCpuDeadLoop_1(); /*0x42c1*/
        (*(void (__fastcall **)(__int64, _QWORD))(v8 + 128))(189, a1); /*0x42ce*/
        v5 = a1; /*0x42e4*/
        InternalDebugPrint(64, "Misc Area offset: %x \n", a1);
        return v5; /*0x42ec*/
      }
      a1 += v12 + 5; /*0x42b5*/
      if ( v11 < 0 ) /*0x42bd*/
        return v5; /*0x42bd*/
    }
    InternalDebugPrint(0x80000000LL, "%a: Failed to get FRU data[0x%x]. Status = %r\n", "UpdateMiscOffsetPcd", a1, v7);
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x431d*/
    n62 = 62; /*0x4322*/
  }
  else
  {
    InternalDebugPrint(0x80000000LL, "%a: Failed to locate EfiRedirFruProtocol. Status = %r\n", "UpdateMiscOffsetPcd", v4);
    InternalDebugPrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0x4265*/
    n62 = 47; /*0x426a*/
  }
  InternalDebugAssert( /*0x4335*/
    (__int64)"e:\\hs\\LenovoPlatformPkg\\Library\\OemMiscOffsetDxeLib\\OemMiscOffsetDxeLib.c",
    n62,
    (__int64)"!EFI_ERROR (Status)");
  return v5; /*0x433d*/
}


// Function: InternalIoWrite16 @ 0x4348 (0x34 bytes)

__int64 __fastcall InternalIoWrite16(_WORD *a1)
{
  if ( ((unsigned __int8)a1 & 1) != 0 ) /*0x4354*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c", 183, (__int64)"(Address & 1) == 0"); /*0x4369*/
  *a1 = 1280; /*0x4373*/
  return 1280; /*0x4376*/
}


// Function: InternalIoRead32 @ 0x437c (0x30 bytes)

unsigned __int32 __fastcall InternalIoRead32(unsigned __int16 n1288)
{
  if ( (n1288 & 3) != 0 ) /*0x4388*/
    InternalDebugAssert((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c", 193, (__int64)"(Port & 3) == 0"); /*0x439d*/
  return __indword(n1288); /*0x43a6*/
}