Newer
Older
AMI-Aptio-BIOS-Reversed / SmbiosDataUpdateDxeNeonCityEPRP / SmbiosDataUpdateDxeNeonCityEPRP.c
@Ajax Dong Ajax Dong 2 days ago 53 KB Init
/*
 *SmbiosDataUpdateDxeNeonCityEPRP.c - Decompiled source for SmbiosDataUpdateDxeNeonCityEPRP.efi
 *
 *Copyright (c) HR650X BIOS Decompilation Project
 */

#include "SmbiosDataUpdateDxeNeonCityEPRP.h"

char *InternalZeroMem(char *buf, unsigned __int64 n24)
{
 memset(buf, 0, 8 * (n24 >> 3)); /*0x296*/
 memset(&buf[8 * (n24 >> 3)], 0, n24 & 7); /*0x29b*/
 return buf; /*0x29e*/
}

char *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; /*0x310*/
 if ( src < dst && &src[count - 1] >= dst ) /*0x318*/
 {
 src_1 = &src[count - 1]; /*0x330*/
 dst_2 = &dst[count - 1]; /*0x333*/
 }
 else
 {
 count_1 = count; /*0x31a*/
 count &= 7u; /*0x31d*/
 count_1 >>= 3; /*0x324*/
 qmemcpy(dst, src, 8 *count_1); /*0x328*/
 src_1 = &src[8 *count_1]; /*0x328*/
 dst_2 = &dst[8 *count_1]; /*0x328*/
 }
 qmemcpy(dst_2, src_1, count); /*0x33c*/
 return dst_1; /*0x33f*/
}

EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
 double v2; // xmm2_8 __int64 v4; // rdx UefiDriverEntryPoint((__int64)ImageHandle, SystemTable); /*0x379*/
 return SmbiosDataUpdateEntry(ImageHandle, v4, v2); /*0x386*/
}

__int64 UefiDriverEntryPoint(__int64 ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
 __int64 Status; // rax __int64 Status; // rax __int64 Status; // rax __int64 result; // rax __int64 Status; // rbx

 ::ImageHandle = ImageHandle; /*0x3a1*/
 if ( !ImageHandle ) /*0x3b5*/
 AssertReport( /*0x3c4*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 51,
 (__int64)"gImageHandle != ((void *) 0)");
 ::SystemTable = (__int64)SystemTable; /*0x3c9*/
 if ( !SystemTable ) /*0x3d3*/
 AssertReport( /*0x3e2*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 57,
 (__int64)"gST != ((void *) 0)");
 BootServices = (__int64)SystemTable->BootServices; /*0x3eb*/
 if ( !BootServices ) /*0x3f5*/
 AssertReport( /*0x404*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 63,
 (__int64)"gBS != ((void *) 0)");
 RuntimeServices = (__int64)SystemTable->RuntimeServices; /*0x40d*/
 if ( !RuntimeServices ) /*0x417*/
 AssertReport( /*0x42a*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeServicesTableLib\\UefiRuntimeServicesTableLib.c",
 47,
 (__int64)"gRT != ((void *) 0)");
 GetHobList(); /*0x42f*/
 Status = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_3890, 0, &qword_3928); /*0x44b*/
 if ( Status < 0 ) /*0x46e*/
 {
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x478*/
 AssertReport( /*0x488*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
 88,
 (__int64)"!EFI_ERROR (Status)");
 }
 Status = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_3880, 0, &qword_3948); /*0x4a4*/
 if ( Status < 0 ) /*0x4ad*/
 {
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x4b8*/
 AssertReport( /*0x4c8*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
 94,
 (__int64)"!EFI_ERROR (Status)");
 }
 Status = (*(__int64 ( **)(void *, _QWORD, void *))(BootServices + 320))(&unk_3860, 0, &unk_3938); /*0x4e4*/
 if ( Status < 0 ) /*0x4ed*/
 {
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x4f8*/
 AssertReport( /*0x508*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
 100,
 (__int64)"!EFI_ERROR (Status)");
 }
 (*(void ( **)(void *, _QWORD, void *))(BootServices + 320))(&unk_38C0, 0, &unk_3930); /*0x524*/
 (*(void ( **)(void *, _QWORD, void *))(BootServices + 320))(&unk_3870, 0, &unk_3940); /*0x541*/
 result = EfiGetSystemConfigurationTable(&TableGuid__0, (void **)&Table__0); /*0x555*/
 Status = result; /*0x55a*/
 if ( result < 0 ) /*0x560*/
 {
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", result); /*0x56b*/
 result = AssertReport( /*0x57f*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
 64,
 (__int64)"!EFI_ERROR (Status)");
 }
 if ( !Table__0 ) /*0x58c*/
 result = AssertReport( /*0x5a1*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
 65,
 (__int64)"gDS != ((void *) 0)");
 if ( Status < 0 ) /*0x5a9*/
 {
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x5b4*/
 result = AssertReport( /*0x5c8*/
 (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\PurleyRpPkg\\Uba\\UbaMain\\Dxe\\TypeNeonCityEPRP\\S"
 "mbiosDataUpdateDxe\\SmbiosDataUpdateDxe\\DEBUG\\AutoGen.c",
 295,
 (__int64)"!EFI_ERROR (Status)");
 }
 if ( !qword_3980 ) /*0x5d5*/
 {
 result = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_31D0, 0, &qword_3980); /*0x5ee*/
 if ( result < 0 ) /*0x5f7*/
 {
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", result); /*0x602*/
 result = AssertReport( /*0x616*/
 (__int64)"e:\\hs\\CpRcPkg\\Library\\DxeMmPciBaseLib\\DxeMmPciBaseLib.c",
 52,
 (__int64)"!EFI_ERROR (Status)");
 }
 if ( !qword_3980 ) /*0x623*/
 return AssertReport( /*0x638*/
 (__int64)"e:\\hs\\CpRcPkg\\Library\\DxeMmPciBaseLib\\DxeMmPciBaseLib.c",
 53,
 (__int64)"mPciUsra != ((void *) 0)");
 }
 return result; /*0x64c*/
}

__int64 SmbiosDataUpdateEntry(EFI_HANDLE ImageHandle, __int64 a2, double a3)
{
 __int64 result; // rax __int64 Protocol; // rbx __int64 Buffer; // rax _DWORD Buffer[4]; // [rsp+20h] [rbp-28h] BYREF __int64 (*SmbiosDataUpdateCallback_1)(); // [rsp+30h] [rbp-18h]
 EFI_HANDLE ImageHandle_1; // [rsp+50h] [rbp+8h] BYREF __int64 Result; // [rsp+58h] [rbp+10h] BYREF Result = a2; /*0x654*/
 ImageHandle_1 = ImageHandle; /*0x671*/
 result = (*(__int64 ( **)(EFI_HANDLE, void *, __int64 *))(BootServices + 152))(ImageHandle, &unk_31A0, &Result); /*0x676*/
 if ( result >= 0 ) /*0x67f*/
 {
 Protocol = *(_QWORD *)(Result + 32); /*0x696*/
 DebugPrintAssertLog(0x80000000LL, "UBA:SmbiosDataUpdateEntry Image GUID=%g\n", a3); /*0x69e*/
 CopyGuid(&DestinationGuid_, (const GUID *)(Protocol + 4)); /*0x6ae*/
 qword_38F0 = (__int64)HiiAddPackages(&DestinationGuid_, &ImageHandle_1, &unk_31F0, 0); /*0x6ce*/
 if ( !qword_38F0 ) /*0x6d8*/
 AssertReport( /*0x6ed*/
 (__int64)"e:\\hs\\PurleyRpPkg\\Uba\\UbaMain\\Dxe\\TypeNeonCityEPRP\\SmbiosDataUpdateDxe\\SmbiosDataUpdateDxe.c",
 625,
 (__int64)"gSmbiosStringPackHandle != ((void *) 0)");
 ZeroMem(Buffer, 0x18u); /*0x6fe*/
 Buffer[3] = 0; /*0x703*/
 Buffer[2] = 0; /*0x70f*/
 SmbiosDataUpdateCallback_1 = SmbiosDataUpdateCallback; /*0x714*/
 Buffer = qword_3960; /*0x719*/
 if ( !qword_3960 ) /*0x723*/
 {
 result = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_31E0, 0, &qword_3960); /*0x73c*/
 if ( result < 0 ) /*0x745*/
 return result; /*0x745*/
 Buffer = qword_3960; /*0x747*/
 }
 Buffer[0] = 1112363856; /*0x751*/
 Buffer[1] = 1; /*0x75e*/
 return (*(__int64 ( **)(__int64, void *, _DWORD *, __int64))(Buffer + 16))(Buffer, &unk_38E0, Buffer, 24); /*0x770*/
 }
 return result; /*0x773*/
}

__int64 UpdateSmbiosType9SystemSlots(_WORD *ZeroPool, __int64 a2, const CHAR8 *i)
{
 unsigned __int64 v4; // rbx char Buffer; // cl unsigned __int8 Buffer; // si unsigned __int8 Buffer; // r14 EFI_STRING_ID StringId; // dx char Buffer; // cl EFI_STRING Buffer_2; // rax __int64 v11; // rdx EFI_STRING Buffer; // rdi unsigned __int64 Buffer; // r8 EFI_STRING_ID StringId_1; // dx EFI_STRING Buffer_3; // rax __int64 v16; // rdx EFI_STRING Buffer_1; // rbx int n2; // [rsp+20h] [rbp-99h]
 int n134283264; // [rsp+24h] [rbp-95h]
 _BYTE Buffer[2]; // [rsp+28h] [rbp-91h]
 int n3; // [rsp+2Ah] [rbp-8Fh]
 int n134283264_1; // [rsp+2Eh] [rbp-8Bh]
 char n8; // [rsp+32h] [rbp-87h]
 int n4; // [rsp+34h] [rbp-85h]
 int n302055424; // [rsp+38h] [rbp-81h]
 char n16; // [rsp+3Ch] [rbp-7Dh]
 int n5; // [rsp+3Eh] [rbp-7Bh]
 int n302055424_1; // [rsp+42h] [rbp-77h]
 char n16_1; // [rsp+46h] [rbp-73h]
 int n6; // [rsp+48h] [rbp-71h]
 int n302055424_2; // [rsp+4Ch] [rbp-6Dh]
 char n16_2; // [rsp+50h] [rbp-69h]
 int n7; // [rsp+52h] [rbp-67h]
 int n117506048; // [rsp+56h] [rbp-63h]
 char n28; // [rsp+5Ah] [rbp-5Fh]
 int n8_1; // [rsp+5Ch] [rbp-5Dh]
 int n117506048_1; // [rsp+60h] [rbp-59h]
 char n28_1; // [rsp+64h] [rbp-55h]
 int n9; // [rsp+66h] [rbp-53h]
 int n184614912; // [rsp+6Ah] [rbp-4Fh]
 char n31; // [rsp+6Eh] [rbp-4Bh]
 int n10; // [rsp+70h] [rbp-49h]
 int n184614912_1; // [rsp+74h] [rbp-45h]
 char n31_1; // [rsp+78h] [rbp-41h]
 int n11; // [rsp+7Ah] [rbp-3Fh]
 int n184614912_2; // [rsp+7Eh] [rbp-3Bh]
 char n31_2; // [rsp+82h] [rbp-37h]
 int n12; // [rsp+84h] [rbp-35h]
 int n4609; // [rsp+88h] [rbp-31h]
 char n16_3; // [rsp+8Ch] [rbp-2Dh]
 int n13; // [rsp+8Eh] [rbp-2Bh]
 int n4609_1; // [rsp+92h] [rbp-27h]
 char n16_4; // [rsp+96h] [rbp-23h]
 int n14; // [rsp+98h] [rbp-21h]
 int n65281; // [rsp+9Ch] [rbp-1Dh]
 char v56; // [rsp+A0h] [rbp-19h]
 int n15; // [rsp+A2h] [rbp-17h]
 int n8705; // [rsp+A6h] [rbp-13h]
 char n32; // [rsp+AAh] [rbp-Fh]
 int n16_5; // [rsp+ACh] [rbp-Dh]
 int n8705_1; // [rsp+B0h] [rbp-9h]
 char n32_1; // [rsp+B4h] [rbp-5h]
 int n17; // [rsp+B6h] [rbp-3h]
 int n8705_2; // [rsp+BAh] [rbp+1h]
 char n32_2; // [rsp+BEh] [rbp+5h]
 int n18; // [rsp+C0h] [rbp+7h]
 int n8705_3; // [rsp+C4h] [rbp+Bh]
 char n32_3; // [rsp+C8h] [rbp+Fh]
 int n19; // [rsp+CAh] [rbp+11h]
 int n8705_4; // [rsp+CEh] [rbp+15h]
 char n32_4; // [rsp+D2h] [rbp+19h]
 int n20; // [rsp+D4h] [rbp+1Bh]
 int n8705_5; // [rsp+D8h] [rbp+1Fh]
 char n32_5; // [rsp+DCh] [rbp+23h]
 int n21; // [rsp+DEh] [rbp+25h]
 int n8705_6; // [rsp+E2h] [rbp+29h]
 char n32_6; // [rsp+E6h] [rbp+2Dh]
 int n22; // [rsp+E8h] [rbp+2Fh]
 int n8705_7; // [rsp+ECh] [rbp+33h]
 char n33; // [rsp+F0h] [rbp+37h]
 _BYTE *ZeroPool_1; // [rsp+120h] [rbp+67h]

 ZeroPool_1 = ZeroPool; /*0x78b*/
 n2 = 2; /*0x7a5*/
 n134283264 = 134283264; /*0x7ad*/
 Buffer[0] = 8; /*0x7b5*/
 n3 = 3; /*0x7ba*/
 n134283264_1 = 134283264; /*0x7c6*/
 n8 = 8; /*0x7d2*/
 n4 = 4; /*0x7da*/
 n302055424 = 302055424; /*0x7e2*/
 n16 = 16; /*0x7ea*/
 n5 = 5; /*0x7ee*/
 n302055424_1 = 302055424; /*0x7f5*/
 n16_1 = 16; /*0x7fc*/
 n6 = 6; /*0x800*/
 n302055424_2 = 302055424; /*0x807*/
 n16_2 = 16; /*0x80e*/
 n7 = 7; /*0x812*/
 n117506048 = 117506048; /*0x819*/
 n28 = 28; /*0x820*/
 n8_1 = 8; /*0x824*/
 n117506048_1 = 117506048; /*0x828*/
 n28_1 = 28; /*0x82f*/
 n9 = 9; /*0x833*/
 n184614912 = 184614912; /*0x836*/
 n31 = 31; /*0x83d*/
 n10 = 10; /*0x841*/
 n184614912_1 = 184614912; /*0x848*/
 n31_1 = 31; /*0x84f*/
 n11 = 11; /*0x853*/
 n184614912_2 = 184614912; /*0x85a*/
 n31_2 = 31; /*0x861*/
 n12 = 12; /*0x865*/
 n4609 = 4609; /*0x86c*/
 n16_3 = 16; /*0x873*/
 n13 = 13; /*0x877*/
 n4609_1 = 4609; /*0x87e*/
 n16_4 = 16; /*0x885*/
 n14 = 14; /*0x889*/
 n65281 = 65281; /*0x890*/
 v56 = -1; /*0x897*/
 n15 = 15; /*0x89b*/
 n8705 = 8705; /*0x8a2*/
 n32 = 32; /*0x8a9*/
 n16_5 = 16; /*0x8ad*/
 n8705_1 = 8705; /*0x8b1*/
 n32_1 = 32; /*0x8b8*/
 n17 = 17; /*0x8bc*/
 n8705_2 = 8705; /*0x8c3*/
 n32_2 = 32; /*0x8ca*/
 n18 = 18; /*0x8ce*/
 n8705_3 = 8705; /*0x8d5*/
 n32_3 = 32; /*0x8dc*/
 n19 = 19; /*0x8e0*/
 n8705_4 = 8705; /*0x8e7*/
 n32_4 = 32; /*0x8ee*/
 n20 = 20; /*0x8f2*/
 n8705_5 = 8705; /*0x8f9*/
 n32_5 = 32; /*0x900*/
 n21 = 21; /*0x904*/
 n8705_6 = 8705; /*0x907*/
 n32_6 = 32; /*0x90e*/
 n22 = 22; /*0x912*/
 n8705_7 = 8705; /*0x919*/
 n33 = 33; /*0x920*/
 if ( (unsigned __int64)i >= 0x15 ) /*0x927*/
 return 0x8000000000000002uLL; /*0x933*/
 ZeroPool[1] = -2; /*0x93d*/
 *(_BYTE *)ZeroPool = 8; /*0x945*/
 *((_BYTE *)ZeroPool + 1) = 9; /*0x94c*/
 v4 = 5LL * (_QWORD)i; /*0x94f*/
 Buffer = Buffer[10 * (_QWORD)i - 3]; /*0x957*/
 Buffer = Buffer[10 * (_QWORD)i - 4]; /*0x95b*/
 Buffer = Buffer[10 * (_QWORD)i - 2]; /*0x960*/
 StringId = *((_WORD *)&n2 + 5 * (_QWORD)i); /*0x965*/
 ZeroPool_1[4] = Buffer; /*0x96a*/
 ZeroPool_1[5] = Buffer; /*0x972*/
 Buffer = Buffer[10 * (_QWORD)i - 1]; /*0x979*/
 ZeroPool_1[6] = Buffer; /*0x97d*/
 ZeroPool_1[7] = Buffer; /*0x985*/
 LOBYTE(ZeroPool) = Buffer[10 * (_QWORD)i]; /*0x98c*/
 ZeroPool_1[8] = (_BYTE)ZeroPool; /*0x990*/
 if ( StringId ) /*0x996*/
 {
 Buffer_2 = HiiGetString(ZeroPool, StringId, i); /*0x998*/
 Buffer = Buffer_2; /*0x99d*/
 if ( !Buffer_2 ) /*0x9a3*/
 return 0x8000000000000009uLL; /*0x9af*/
 Buffer = Buffer; /*0x9b8*/
 if ( !Buffer ) /*0x9bf*/
 Buffer = Buffer; /*0x9c1*/
 UbaSmbiosUpdateStringReplace((__int64)ZeroPool_1, v11, Buffer, (__int64)Buffer_2); /*0x9c5*/
 AllocateZeroPool_1(Buffer); /*0x9cd*/
 }
 StringId_1 = *((_WORD *)&n2 + v4 + 1); /*0x9d2*/
 if ( StringId_1 ) /*0x9da*/
 {
 Buffer_3 = HiiGetString(ZeroPool, StringId_1, i); /*0x9dc*/
 Buffer_1 = Buffer_3; /*0x9e1*/
 if ( !Buffer_3 ) /*0x9e7*/
 return 0x8000000000000009uLL; /*0x9e7*/
 UbaSmbiosUpdateStringReplace((__int64)ZeroPool_1, v16, Buffer, (__int64)Buffer_3); /*0x9f4*/
 AllocateZeroPool_1(Buffer_1); /*0x9fc*/
 }
 return 0; /*0xa17*/
}

__int64 UpdateSmbiosType41OnboardDevices(_WORD *ZeroPool, __int64 a2, unsigned __int64 j)
{
 __int64 v3; // r8 __int64 v4; // r8 __int64 v5; // r8 __int64 v6; // r8 __int64 Device; // rax unsigned int *v9; // rax const CHAR8 *Language; // r8 EFI_STRING_ID Buffer; // dx __int64 Device; // rax unsigned int *v13; // rax void *HiiHandle; // rcx char Device; // r14 __int64 Handle; // rax __int64 Device; // rax unsigned int *v18; // rax char Buffer; // r8 __int64 Device; // rax CHAR16 *Buffer; // rax __int64 v22; // rdx CHAR16 *Buffer_1; // rbx ZeroPool[1] = -2; /*0xa43*/
 *(_BYTE *)ZeroPool = 9; /*0xa52*/
 *((_BYTE *)ZeroPool + 1) = 17; /*0xa59*/
 *((_BYTE *)ZeroPool + 15) = 0; /*0xa61*/
 *((_BYTE *)ZeroPool + 4) = 1; /*0xa69*/
 *((_BYTE *)ZeroPool + 8) = 4; /*0xa70*/
 *((_BYTE *)ZeroPool + 11) |= 4u; /*0xa77*/
 *((_BYTE *)ZeroPool + 12) |= 1u; /*0xa7e*/
 *((_BYTE *)ZeroPool + 12) |= 4u; /*0xa85*/
 *(_WORD *)((char *)ZeroPool + 13) = 0; /*0xa8c*/
 if ( !j ) /*0xa94*/
 {
 Buffer = 0; /*0xd01*/
 *(_WORD *)((char *)ZeroPool + 9) = 1; /*0xd04*/
 *((_BYTE *)ZeroPool + 5) = -74; /*0xd10*/
 *((_BYTE *)ZeroPool + 6) = 13; /*0xd18*/
 *((_BYTE *)ZeroPool + 15) = 0; /*0xd20*/
 *((_BYTE *)ZeroPool + 16) = 24; /*0xd28*/
 goto LABEL_21; /*0xd28*/
 }
 v3 = j - 1; /*0xa9a*/
 if ( !v3 ) /*0xa9d*/
 {
 *(_WORD *)((char *)ZeroPool + 9) = 3; /*0xcb2*/
 *((_BYTE *)ZeroPool + 5) = -75; /*0xcbe*/
 *((_BYTE *)ZeroPool + 6) = 11; /*0xcc6*/
 *((_BYTE *)ZeroPool + 15) = 0; /*0xcce*/
 *((_BYTE *)ZeroPool + 16) = 26; /*0xcd6*/
 if ( *(_DWORD *)PciWriteMmPciUsra(0, 3, 2) == -1 ) /*0xce4*/
 return 0x8000000000000007uLL; /*0xce4*/
 Buffer = 2; /*0xcf5*/
LABEL_21:
 Device = PciWriteMmPciUsra(0, 3, Buffer); /*0xd2c*/
 v9 = (unsigned int *)PciWriteMmPciUsra(*(_BYTE *)(Device + 25), 0, 0); /*0xd3e*/
 Buffer = 23; /*0xd43*/
LABEL_22:
 HiiHandle = (void *)*v9; /*0xd48*/
 LOBYTE(HiiHandle) = ((_DWORD)HiiHandle != -1) + 3; /*0xd50*/
 goto LABEL_23; /*0xd50*/
 }
 v4 = v3 - 1; /*0xaa3*/
 if ( !v4 ) /*0xaa6*/
 {
 *(_WORD *)((char *)ZeroPool + 9) = 4; /*0xc50*/
 *((_BYTE *)ZeroPool + 5) = -74; /*0xc5d*/
 *((_BYTE *)ZeroPool + 6) = 13; /*0xc65*/
 *((_BYTE *)ZeroPool + 15) = 0x80; /*0xc6d*/
 *((_BYTE *)ZeroPool + 16) = 8; /*0xc75*/
 Device = PciWriteMmPciUsra(0x80u, 1, 0); /*0xc7d*/
 v18 = (unsigned int *)PciWriteMmPciUsra(*(_BYTE *)(Device + 25), 0, 0); /*0xc8b*/
 Buffer = 24; /*0xc90*/
 HiiHandle = (void *)*v18; /*0xc95*/
 LOBYTE(HiiHandle) = ((_DWORD)HiiHandle != -1) + 3; /*0xc9d*/
 goto LABEL_23; /*0xca0*/
 }
 v5 = v4 - 1; /*0xaac*/
 if ( !v5 ) /*0xaaf*/
 {
 *(_WORD *)((char *)ZeroPool + 9) = 6; /*0xba7*/
 *((_BYTE *)ZeroPool + 5) = -75; /*0xbb5*/
 *((_BYTE *)ZeroPool + 6) = 11; /*0xbbd*/
 *((_BYTE *)ZeroPool + 15) = 0x80; /*0xbc5*/
 *((_BYTE *)ZeroPool + 16) = 16; /*0xbcd*/
 Device = *(_BYTE *)(PciWriteMmPciUsra(0x80u, 2, 0) + 400); /*0xbdb*/
 if ( Device == 3 ) /*0xbe5*/
 {
 *(_WORD *)((char *)ZeroPool + 9) = 5; /*0xbee*/
 *((_BYTE *)ZeroPool + 5) = -74; /*0xbf6*/
 *((_BYTE *)ZeroPool + 6) = 11; /*0xbfe*/
 }
 Handle = PciWriteMmPciUsra(0x80u, 2, 0); /*0xc0c*/
 HiiHandle = (void *)*(unsigned int *)PciWriteMmPciUsra(*(_BYTE *)(Handle + 25), 0, 0); /*0xc1f*/
 LOBYTE(HiiHandle) = ((_DWORD)HiiHandle != -1) + 3; /*0xc2b*/
 *((_BYTE *)ZeroPool + 7) = (_BYTE)HiiHandle; /*0xc2d*/
 if ( Device == 3 ) /*0xc33*/
 Buffer = 26; /*0xc35*/
 else Buffer = 25; /*0xc3f*/
 goto LABEL_24; /*0xc3a*/
 }
 v6 = v5 - 1; /*0xab5*/
 if ( v6 ) /*0xab8*/
 {
 if ( v6 != 1 ) /*0xabd*/
 return 0x8000000000000002uLL; /*0xac9*/
 *(_WORD *)((char *)ZeroPool + 9) = 8; /*0xad7*/
 *((_BYTE *)ZeroPool + 5) = -75; /*0xaeb*/
 *((_BYTE *)ZeroPool + 6) = 11; /*0xaf3*/
 *((_BYTE *)ZeroPool + 15) = 0x80; /*0xafb*/
 *((_BYTE *)ZeroPool + 16) = 26; /*0xb03*/
 Device = PciWriteMmPciUsra(0x80u, 3, 2); /*0xb07*/
 v9 = (unsigned int *)PciWriteMmPciUsra(*(_BYTE *)(Device + 25), 0, 0); /*0xb15*/
 Buffer = 27; /*0xb1a*/
 goto LABEL_22; /*0xb1d*/
 }
 *(_WORD *)((char *)ZeroPool + 9) = 7; /*0xb2b*/
 *((_BYTE *)ZeroPool + 5) = -76; /*0xb3c*/
 *((_BYTE *)ZeroPool + 6) = 10; /*0xb44*/
 *((_BYTE *)ZeroPool + 15) = 0x80; /*0xb4c*/
 *((_BYTE *)ZeroPool + 16) = 18; /*0xb54*/
 if ( *(_DWORD *)PciWriteMmPciUsra(0x80u, 2, 2) == -1 ) /*0xb62*/
 return 0x8000000000000007uLL; /*0xcf0*/
 Device = PciWriteMmPciUsra(0x80u, 2, 2); /*0xb73*/
 v13 = (unsigned int *)PciWriteMmPciUsra(*(_BYTE *)(Device + 25), 0, 0); /*0xb81*/
 Buffer = 25; /*0xb86*/
 HiiHandle = (void *)*v13; /*0xb8b*/
 LOBYTE(HiiHandle) = ((_DWORD)HiiHandle != -1) + 3; /*0xb93*/
LABEL_23:
 *((_BYTE *)ZeroPool + 7) = (_BYTE)HiiHandle; /*0xd52*/
LABEL_24:
 Buffer = HiiGetString(HiiHandle, Buffer, Language); /*0xd59*/
 Buffer_1 = Buffer; /*0xd5e*/
 if ( Buffer ) /*0xd64*/
 {
 UbaSmbiosUpdateStringReplace(ZeroPool, v22, *((unsigned __int8 *)ZeroPool + 4), Buffer); /*0xd72*/
 AllocateZeroPool_1(Buffer_1); /*0xd7a*/
 }
 return 0; /*0xd90*/
}

__int64 UpdateSmbiosTypeUnknownExtended(char *ZeroPool, __int64 a2, unsigned __int64 k)
{
 __int64 v3; // r8 __int64 v4; // r8 unsigned int *v6; // rax const CHAR8 *Language; // r8 EFI_STRING_ID Buffer; // dx void *HiiHandle; // rcx unsigned __int8 Buffer; // bl unsigned int *v11; // rax char Buffer; // dl unsigned int *v13; // rax char Buffer; // dl char Buffer; // di unsigned int *v16; // rax CHAR16 *Buffer; // rax __int64 v18; // rdx CHAR16 *Buffer_1; // rbx

 *((_WORD *)ZeroPool + 1) = -2; /*0xdbb*/
 *ZeroPool = 41; /*0xdc3*/
 ZeroPool[1] = 11; /*0xdca*/
 ZeroPool[4] = 1; /*0xdd2*/
 *(_WORD *)(ZeroPool + 7) = 0; /*0xdda*/
 if ( !k ) /*0xde2*/
 {
 Buffer = 3; /*0xecb*/
 Buffer = *(_BYTE *)(PciWriteMmPciUsra(0, 28, 3) + 25); /*0xee2*/
 v16 = (unsigned int *)PciWriteMmPciUsra(Buffer, 0, 0); /*0xee8*/
 Buffer = 28; /*0xeed*/
 HiiHandle = (void *)*v16; /*0xef2*/
 if ( (_DWORD)HiiHandle != -1 ) /*0xefc*/
 Buffer = -125; /*0xefc*/
 ZeroPool[5] = Buffer; /*0xf03*/
 goto LABEL_18; /*0xf03*/
 }
 v3 = k - 1; /*0xde8*/
 if ( !v3 ) /*0xdec*/
 {
 Buffer = *(_BYTE *)(PciWriteMmPciUsra(0, 2, 2) + 25); /*0xea0*/
 v13 = (unsigned int *)PciWriteMmPciUsra(Buffer, 0, 0); /*0xea6*/
 Buffer = 5; /*0xeab*/
 HiiHandle = (void *)*v13; /*0xeb0*/
 if ( (_DWORD)HiiHandle != -1 ) /*0xeba*/
 Buffer = -123; /*0xeba*/
 ZeroPool[5] = Buffer; /*0xec1*/
 Buffer = 29; /*0xec4*/
 goto LABEL_18; /*0xec9*/
 }
 v4 = v3 - 1; /*0xdf2*/
 if ( !v4 ) /*0xdf6*/
 {
 Buffer = *(_BYTE *)(PciWriteMmPciUsra(0, 1, 0) + 25); /*0xe61*/
 v11 = (unsigned int *)PciWriteMmPciUsra(Buffer, 0, 0); /*0xe67*/
 Buffer = 10; /*0xe6c*/
 HiiHandle = (void *)*v11; /*0xe71*/
 if ( (_DWORD)HiiHandle != -1 ) /*0xe7b*/
 Buffer = -118; /*0xe7b*/
 ZeroPool[5] = Buffer; /*0xe82*/
 Buffer = 30; /*0xe85*/
LABEL_18:
 ZeroPool[9] = Buffer; /*0xf07*/
 ZeroPool[10] = 0; /*0xf12*/
 goto LABEL_19; /*0xf12*/
 }
 if ( v4 != 1 ) /*0xdfc*/
 return 0x8000000000000002uLL; /*0xe08*/
 v6 = (unsigned int *)PciWriteMmPciUsra(0, 31, 2); /*0xe1a*/
 Language = (_BYTE *)(&word_8 + 1); /*0xe1f*/
 Buffer = 31; /*0xe23*/
 HiiHandle = (void *)*v6; /*0xe25*/
 if ( (_DWORD)HiiHandle != -1 ) /*0xe2d*/
 Language = byte_40 + 73; /*0xe2d*/
 ZeroPool[5] = (char)Language; /*0xe35*/
 ZeroPool[9] = 0; /*0xe3d*/
 ZeroPool[10] = -6; /*0xe45*/
LABEL_19:
 Buffer = HiiGetString(HiiHandle, Buffer, Language); /*0xf16*/
 Buffer_1 = Buffer; /*0xf1b*/
 if ( Buffer ) /*0xf21*/
 {
 UbaSmbiosUpdateStringReplace(ZeroPool, v18, 1u, Buffer); /*0xf30*/
 AllocateZeroPool_1(Buffer_1); /*0xf38*/
 }
 return 0; /*0xf4e*/
}

__int64 SmbiosDataUpdateCallback()
{
 void *ZeroPool; // rbx unsigned __int64 i; // rdi __int64 v2; // rdx unsigned __int64 j; // rdi __int64 v4; // rdx unsigned __int64 k; // rdi __int64 v6; // rdx __int64 updated; // rsi ZeroPool = AllocateZeroPool(0x300u); /*0xf74*/
 for ( i = 0; i < 0x1E; ++i ) /*0xf77*/
 {
 ZeroMem(ZeroPool, 0x300u); /*0xf84*/
 if ( UpdateSmbiosType9SystemSlots((__int64)ZeroPool, v2, i) >= 0 ) /*0xf97*/
 UbaSmbiosFlushStringPack((__int64)ZeroPool); /*0xf9c*/
 }
 UbaSmbiosDeleteAllKeysOfType(9); /*0xfac*/
 for ( j = 0; j < 8; ++j ) /*0xfb1*/
 {
 ZeroMem(ZeroPool, 0x300u); /*0xfbe*/
 if ( UpdateSmbiosType41OnboardDevices((__int64)ZeroPool, v4, j) >= 0 ) /*0xfd1*/
 UbaSmbiosFlushStringPack((__int64)ZeroPool); /*0xfd6*/
 }
 UbaSmbiosDeleteAllKeysOfType(41); /*0xfe6*/
 for ( k = 0; k < 4; ++k ) /*0xfeb*/
 {
 ZeroMem(ZeroPool, 0x300u); /*0xff8*/
 updated = UpdateSmbiosTypeUnknownExtended((__int64)ZeroPool, v6, k); /*0x1008*/
 if ( updated >= 0 ) /*0x100e*/
 updated = UbaSmbiosFlushStringPack((__int64)ZeroPool); /*0x1018*/
 }
 AllocateZeroPool_1(ZeroPool); /*0x1027*/
 return updated; /*0x103e*/
}

__int64 GetHiiDatabaseProtocol()
{
 __int64 result; // rax unsigned __int64 n0x10; // rbx __int64 v2; // rax __int64 Result; // rcx result = qword_3918; /*0x104e*/
 if ( !qword_3918 ) /*0x105a*/
 {
 n0x10 = (*(__int64 ( **)(__int64))(BootServices + 24))(31); /*0x1073*/
 (*(void ( **)(unsigned __int64))(BootServices + 32))(n0x10); /*0x1076*/
 if ( n0x10 <= 0x10 ) /*0x107d*/
 {
 v2 = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_31C0, 0, &qword_3918); /*0x109a*/
 Result = qword_3918; /*0x10a0*/
 if ( v2 < 0 ) /*0x10aa*/
 Result = 0; /*0x10aa*/
 qword_3918 = Result; /*0x10ae*/
 return Result; /*0x10b5*/
 }
 else
 {
 return 0; /*0x107f*/
 }
 }
 return result; /*0x10bd*/
}

char DebugPrintAssertLog(__int64 a1, const char *a2, ...)
{
 __int64 HiiDatabaseProtocol; // rax __int64 v4; // r8 char ( **HiiDatabaseProtocol_1)(__int64, const char *, __int64 *); // r9 unsigned __int8 v6; // al char n3_1; // al char Protocol; // cl va_list va; // [rsp+40h] [rbp+18h] BYREF va_start(va, a2);
 HiiDatabaseProtocol = GetHiiDatabaseProtocol(); /*0x10db*/
 v4 = 0; /*0x10e0*/
 HiiDatabaseProtocol_1 = (char ( **)(__int64, const char *, __int64 *))HiiDatabaseProtocol; /*0x10e3*/
 if ( HiiDatabaseProtocol ) /*0x10e9*/
 {
 v6 = __inbyte(0x70u); /*0x10ef*/
 __outbyte(0x70u, v6 & 0x80 | 0x4B); /*0x10f4*/
 n3_1 = __inbyte(0x71u); /*0x10f9*/
 Protocol = n3_1; /*0x10fa*/
 if ( (unsigned __int8)n3_1 > 3u ) /*0x1100*/
 {
 Protocol = Protocol; /*0x1102*/
 if ( !Protocol ) /*0x110a*/
 Protocol = MEMORY[0xFDAF0490] & 2 | 1; /*0x1116*/
 }
 LOBYTE(HiiDatabaseProtocol) = Protocol - 1; /*0x111a*/
 if ( (unsigned __int8)(Protocol - 1) <= 0xFDu ) /*0x111e*/
 {
 LOBYTE(HiiDatabaseProtocol) = 4; /*0x1122*/
 v4 = 2147483718LL; /*0x1127*/
 if ( Protocol == 1 ) /*0x112d*/
 v4 = 2147483652LL; /*0x112d*/
 }
 if ( (v4 & a1) != 0 ) /*0x1134*/
 LOBYTE(HiiDatabaseProtocol) = (*HiiDatabaseProtocol_1)(a1, a2, (__int64 *)va); /*0x1143*/
 }
 return HiiDatabaseProtocol; /*0x1146*/
}

__int64 AssertReport(__int64 a1, __int64 a2, __int64 a3)
{
 __int64 result; // rax result = GetHiiDatabaseProtocol(); /*0x1164*/
 if ( result ) /*0x116c*/
 return (*(__int64 ( **)(__int64, __int64, __int64))(result + 8))(a1, a2, a3); /*0x1177*/
 return result; /*0x1184*/
}

GUID *CopyGuid(GUID *DestinationGuid, const GUID *SourceGuid)
{
 UINT64 Unaligned64; // rax UINT64 Value; // rax Unaligned64 = ReadUnaligned64((const UINT64 *)&SourceGuid->Data1); /*0x119f*/
 WriteUnaligned64((UINT64 *)&DestinationGuid->Data1, Unaligned64); /*0x11aa*/
 Value = ReadUnaligned64((const UINT64 *)SourceGuid->Data4); /*0x11b3*/
 WriteUnaligned64((UINT64 *)DestinationGuid->Data4, Value); /*0x11bf*/
 return DestinationGuid; /*0x11cc*/
}

BOOLEAN CompareGuid(const GUID *Guid1, const GUID *Guid2)
{
 __int128 Result; // rdi UINT64 Unaligned64; // rbx

 *((_QWORD *)&Result + 1) = ReadUnaligned64((const UINT64 *)&Guid1->Data1); /*0x11f6*/
 Unaligned64 = ReadUnaligned64((const UINT64 *)&Guid2->Data1); /*0x1202*/
 *(_QWORD *)&Result = ReadUnaligned64((const UINT64 *)Guid1->Data4); /*0x120e*/
 return Result == __PAIR128__(Unaligned64, ReadUnaligned64((const UINT64 *)Guid2->Data4)); /*0x1235*/
}

void *ZeroMem(void *Buffer, UINTN Length)
{
 if ( !Length ) /*0x124f*/
 return Buffer; /*0x1251*/
 if ( !Buffer ) /*0x1259*/
 AssertReport( /*0x126c*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
 53,
 (__int64)"Buffer != ((void *) 0)");
 if ( Length > -(__int64)Buffer ) /*0x127a*/
 AssertReport( /*0x128f*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
 54,
 (__int64)"Length <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)Buffer + 1)");
 return InternalZeroMem((char *)Buffer, Length); /*0x12a4*/
}

UINT32 ReadUnaligned32(const UINT32 *Buffer)
{
 if ( !Buffer ) /*0x12b8*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 141, (__int64)"Buffer != ((void *) 0)"); /*0x12cd*/
 return *Buffer; /*0x12d4*/
}

UINT64 ReadUnaligned64(const UINT64 *Buffer)
{
 if ( !Buffer ) /*0x12e8*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, (__int64)"Buffer != ((void *) 0)"); /*0x12fd*/
 return *Buffer; /*0x1305*/
}

UINT64 WriteUnaligned64(UINT64 *Buffer, UINT64 Value)
{
 if ( !Buffer ) /*0x131f*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 219, (__int64)"Buffer != ((void *) 0)"); /*0x1334*/
 *Buffer = Value; /*0x1339*/
 return Value; /*0x1344*/
}

void *AllocatePool(UINTN AllocationSize)
{
 __int64 v1; // rdx __int64 v2; // rax void *Result; // rcx void *v5; // [rsp+40h] [rbp+18h] BYREF v2 = (*(__int64 ( **)(__int64, __int64, void **))(BootServices + 64))(4, v1, &v5); /*0x1361*/
 Result = v5; /*0x1364*/
 if ( v2 < 0 ) /*0x136e*/
 return 0; /*0x136e*/
 return Result; /*0x1375*/
}

void *AllocateZeroPool(UINTN AllocationSize)
{
 void *Buffer; // rax Buffer = AllocatePool(AllocationSize); /*0x1388*/
 if ( Buffer ) /*0x1390*/
 return ZeroMem(Buffer, AllocationSize); /*0x1398*/
 return Buffer; /*0x139d*/
}

void AllocateZeroPool_1(void *Buffer)
{
 __int64 Status; // rax Status = (*(__int64 ( **)(void *))(BootServices + 72))(Buffer); /*0x13af*/
 if ( Status < 0 ) /*0x13b5*/
 {
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x13c6*/
 AssertReport( /*0x13de*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiMemoryAllocationLib\\MemoryAllocationLib.c",
 819,
 (__int64)"!EFI_ERROR (Status)");
 }
}

EFI_STATUS EfiGetSystemConfigurationTable(EFI_GUID *TableGuid, void **Table)
{
 __int64 SystemTable; // rdi __int64 Index; // rbx __int64 i; // r14 if ( !TableGuid ) /*0x140a*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 97, (__int64)"TableGuid != ((void *) 0)"); /*0x141d*/
 if ( !Table ) /*0x1425*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 98, (__int64)"Table != ((void *) 0)"); /*0x1438*/
 SystemTable = SystemTable; /*0x143d*/
 Index = 0; /*0x1444*/
 *Table = 0; /*0x1446*/
 if ( !*(_QWORD *)(SystemTable + 104) ) /*0x144a*/
 return 0x800000000000000EuLL; /*0x1473*/
 for ( i = 0; !CompareGuid(TableGuid, (const GUID *)(i + *(_QWORD *)(SystemTable + 112))); i += 24 ) /*0x1450*/
 {
 if ( (unsigned __int64)++Index >= *(_QWORD *)(SystemTable + 104) ) /*0x1471*/
 return 0x800000000000000EuLL; /*0x1471*/
 }
 *Table = *(void **)(*(_QWORD *)(SystemTable + 112) + 24 *Index + 16); /*0x14a7*/
 return 0; /*0x1491*/
}

__int64 GetPlatformLangVariable(__int64 a1, __int64 *p_HiiHandle, unsigned __int64 n24)
{
 __int64 RuntimeServices; // rax UINTN AllocationSize; // rcx __int64 Result; // rdi void *Pool; // rax unsigned __int64 n24_1; // [rsp+50h] [rbp+18h] BYREF n24_1 = n24; /*0x14b1*/
 if ( !p_HiiHandle ) /*0x14c1*/
 AssertReport( /*0x14d6*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c",
 1401,
 (__int64)"Name != ((void *) 0) && Guid != ((void *) 0) && Value != ((void *) 0)");
 RuntimeServices = RuntimeServices; /*0x14db*/
 n24_1 = 0; /*0x14e7*/
 *p_HiiHandle = 0; /*0x14f4*/
 Result = (*(__int64 ( **)(const __int16 *, void *, _QWORD, unsigned __int64 *, _QWORD))(RuntimeServices + 72))( /*0x150b*/
 L"PlatformLang",
 &unk_31B0,
 0,
 &n24_1,
 0);
 if ( Result == 0x8000000000000005uLL ) /*0x151b*/
 {
 Pool = AllocatePool(AllocationSize); /*0x1522*/
 *p_HiiHandle = (__int64)Pool; /*0x1527*/
 if ( !Pool ) /*0x152d*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 1421, (__int64)"*Value != ((void *) 0)"); /*0x1542*/
 if ( *p_HiiHandle ) /*0x1547*/
 {
 Result = (*(__int64 ( **)(const __int16 *, void *, _QWORD, unsigned __int64 *, _QWORD))(RuntimeServices + 72))( /*0x1580*/
 L"PlatformLang",
 &unk_31B0,
 0,
 &n24_1,
 *p_HiiHandle);
 if ( Result < 0 ) /*0x1586*/
 {
 AllocateZeroPool_1((void *)*p_HiiHandle); /*0x158b*/
 *p_HiiHandle = 0; /*0x1590*/
 }
 }
 else
 {
 return 0x8000000000000009uLL; /*0x154f*/
 }
 }
 return Result; /*0x159c*/
}

CHAR8 *GetBestLanguage(const CHAR8 *SupportedLanguages, BOOLEAN Iso639Language, ...)
{
 CHAR8 *v4; // rsi CHAR8 **v5; // r15 UINTN n3; // rbp UINTN n3_1; // rbx CHAR8 n59_1; // al const CHAR8 *SupportedLanguages_1; // rdi CHAR8 n59; // al void *ZeroPool; // rax CHAR8 *String; // [rsp+70h] [rbp+18h] BYREF va_list va1; // [rsp+78h] [rbp+20h] BYREF va_list Stringa; // [rsp+70h] [rbp+18h]

 va_start(va1, Iso639Language);
 va_start(Stringa, Iso639Language);
 String = va_arg(va1, CHAR8 *); /*0x15a4*/
 if ( !SupportedLanguages ) /*0x15c9*/
 AssertReport( /*0x15de*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c",
 1528,
 (__int64)"SupportedLanguages != ((void *) 0)");
 v4 = String; /*0x15e3*/
 if ( String ) /*0x15eb*/
 {
 va_copy((va_list)v5, Stringa); /*0x15f1*/
 do /*0x16aa*/
 {
 n3 = 3; /*0x15f9*/
 if ( AsciiStrLen(v4) <= 3 ) /*0x1606*/
 n3_1 = AsciiStrLen(v4); /*0x1614*/
 else n3_1 = 3; /*0x1608*/
 if ( Iso639Language ) /*0x161a*/
 {
LABEL_29:
 while ( n3_1 ) /*0x16a4*/
 {
 SupportedLanguages_1 = SupportedLanguages; /*0x163d*/
 if ( *SupportedLanguages ) /*0x1638*/
 {
 while ( 1 ) /*0x1645*/
 {
 if ( Iso639Language ) /*0x1645*/
 goto LABEL_36; /*0x1645*/
 while ( *SupportedLanguages_1 == 59 ) /*0x1654*/
 ++SupportedLanguages_1; /*0x164d*/
 n59 = *SupportedLanguages_1; /*0x1656*/
 n3 = 0; /*0x1658*/
 while ( n59 && n59 != 59 ) /*0x165e*/
 n59 = SupportedLanguages_1[++n3]; /*0x1663*/
 if ( n3_1 <= n3 ) /*0x166d*/
 {
LABEL_36:
 if ( !sub_21B4(SupportedLanguages_1, v4, n3_1) ) /*0x1678*/
 break; /*0x1678*/
 }
 SupportedLanguages_1 += n3; /*0x1682*/
 if ( !*SupportedLanguages_1 ) /*0x1685*/
 goto LABEL_25; /*0x1688*/
 }
 ZeroPool = AllocateZeroPool(n3 + 1); /*0x16cb*/
 if ( ZeroPool ) /*0x16d3*/
 return (CHAR8 *)CopyMem(ZeroPool, SupportedLanguages_1, n3); /*0x16de*/
 return 0; /*0x16d3*/
 }
LABEL_25:
 if ( Iso639Language ) /*0x168d*/
 break; /*0x168d*/
 if ( !--n3_1 ) /*0x1693*/
 break; /*0x1693*/
 do /*0x169f*/
 {
 if ( v4[n3_1] == 45 ) /*0x1699*/
 break; /*0x1699*/
 --n3_1; /*0x169b*/
 }
 while ( n3_1 ); /*0x169f*/
 }
 }
 else
 {
 n59_1 = *v4; /*0x1620*/
 n3_1 = 0; /*0x1622*/
 if ( *v4 ) /*0x1620*/
 {
 do /*0x1634*/
 {
 if ( n59_1 == 59 ) /*0x162a*/
 break; /*0x162a*/
 n59_1 = v4[++n3_1]; /*0x162f*/
 }
 while ( n59_1 ); /*0x1634*/
 goto LABEL_29; /*0x1634*/
 }
 }
 v4 = *++v5; /*0x16aa*/
 }
 while ( *v5 ); /*0x16aa*/
 }
 return 0; /*0x16b8*/
}

void *GetHobList()
{
 void *Table_; // rax signed __int64 SystemConfigurationTable; // rax Table_ = (void *)Table_; /*0x16ec*/
 if ( !Table_ ) /*0x16f6*/
 {
 SystemConfigurationTable = EfiGetSystemConfigurationTable(&TableGuid_, (void **)&Table_); /*0x1706*/
 if ( SystemConfigurationTable < 0 ) /*0x170e*/
 {
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", SystemConfigurationTable); /*0x171f*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 54, (__int64)"!EFI_ERROR (Status)"); /*0x1737*/
 }
 Table_ = (void *)Table_; /*0x173c*/
 if ( !Table_ ) /*0x1746*/
 {
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 55, (__int64)"mHobList != ((void *) 0)"); /*0x1759*/
 return (void *)Table_; /*0x175e*/
 }
 }
 return Table_; /*0x1765*/
}

EFI_STRING HiiGetString(EFI_HII_HANDLE HiiHandle, EFI_STRING_ID StringId, const CHAR8 *Language)
{
 void *HiiHandle_2; // rsi void *ZeroPool; // rbx __int64 v6; // rcx CHAR8 *SupportedLanguages; // rbp unsigned __int64 n24; // r8 void *HiiHandle_3; // r9 CHAR8 *BestLanguage; // rdi EFI_HII_HANDLE HiiHandle_1; // [rsp+70h] [rbp+8h] BYREF const CHAR8 *Language_1; // [rsp+80h] [rbp+18h] BYREF UINTN AllocationSize; // [rsp+88h] [rbp+20h] BYREF Language_1 = Language; /*0x1771*/
 HiiHandle_1 = HiiHandle; /*0x1776*/
 HiiHandle_2 = (void *)::HiiHandle; /*0x1786*/
 if ( !::HiiHandle ) /*0x1797*/
 AssertReport( /*0x17ac*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiString.c",
 238,
 (__int64)"HiiHandle != ((void *) 0)");
 if ( !StringId ) /*0x17b5*/
 AssertReport((__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiString.c", 239, (__int64)"StringId != 0"); /*0x17ca*/
 HiiHandle_1 = 0; /*0x17d2*/
 ZeroPool = 0; /*0x17d7*/
 SupportedLanguages = HiiGetSupportedLanguages(HiiHandle_2); /*0x17df*/
 if ( SupportedLanguages ) /*0x17e5*/
 {
 GetPlatformLangVariable(v6, (__int64 *)&HiiHandle_1, n24); /*0x17f0*/
 HiiHandle_3 = &unk_2AFA; /*0x1801*/
 if ( HiiHandle_1 ) /*0x1809*/
 HiiHandle_3 = HiiHandle_1; /*0x1809*/
 BestLanguage = GetBestLanguage(SupportedLanguages, 0, &unk_2AFA, HiiHandle_3, SupportedLanguages, 0); /*0x181e*/
 if ( BestLanguage ) /*0x1824*/
 {
 AllocationSize = 0; /*0x1848*/
 if ( (*(__int64 ( **)(__int64, CHAR8 *, void *, _QWORD, const CHAR8 **, UINTN *, _QWORD))(qword_3928 + 8))( /*0x1875*/
 qword_3928,
 BestLanguage,
 HiiHandle_2,
 StringId,
 &Language_1,
 &AllocationSize,
 0) == 0x8000000000000005uLL )
 {
 ZeroPool = AllocateZeroPool(AllocationSize); /*0x1884*/
 if ( ZeroPool ) /*0x188a*/
 {
 if ( (*(__int64 ( **)(__int64, CHAR8 *, void *, _QWORD, void *, UINTN *, _QWORD))(qword_3928 + 8))( /*0x18be*/
 qword_3928,
 BestLanguage,
 HiiHandle_2,
 StringId,
 ZeroPool,
 &AllocationSize,
 0) < 0 )
 {
 AllocateZeroPool_1(ZeroPool); /*0x18c3*/
 ZeroPool = 0; /*0x18c8*/
 }
 }
 }
 }
 AllocateZeroPool_1(SupportedLanguages); /*0x18ce*/
 if ( HiiHandle_1 ) /*0x18d8*/
 AllocateZeroPool_1(HiiHandle_1); /*0x18df*/
 if ( BestLanguage ) /*0x18e7*/
 AllocateZeroPool_1(BestLanguage); /*0x18ec*/
 }
 return (EFI_STRING)ZeroPool; /*0x18f9*/
}

EFI_HII_HANDLE HiiAddPackages(const EFI_GUID *PackageListGuid, EFI_HANDLE DeviceHandle, ...)
{
 UINT32 *Buffer_1; // rsi int Size; // ebx UINT32 *Buffer_2; // rax UINT32 **v7; // rdi unsigned int AllocationSize; // ebx GUID *ZeroPool; // rax GUID *ZeroPool_1; // rdi unsigned __int16 *p_Data2; // rbp UINT32 **v12; // r15 UINTN Length; // rbx __int64 Protocol; // rax __int64 v15; // rcx __int64 Handle[9]; // [rsp+20h] [rbp-48h] BYREF UINT32 *Buffer; // [rsp+80h] [rbp+18h] BYREF va_list va1; // [rsp+88h] [rbp+20h] BYREF va_list Buffera; // [rsp+80h] [rbp+18h]

 va_start(va1, DeviceHandle);
 va_start(Buffera, DeviceHandle);
 Buffer = va_arg(va1, UINT32 *); /*0x1908*/
 if ( !PackageListGuid ) /*0x1931*/
 AssertReport( /*0x1946*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLib.c",
 160,
 (__int64)"PackageListGuid != ((void *) 0)");
 Buffer_1 = Buffer; /*0x194b*/
 Size = 0; /*0x1953*/
 Buffer_2 = Buffer; /*0x1956*/
 if ( !Buffer ) /*0x195c*/
 return 0; /*0x195c*/
 va_copy((va_list)v7, Buffera); /*0x1962*/
 do /*0x197b*/
 {
 ++v7; /*0x1975*/
 Size += ReadUnaligned32(Buffer_2) - 4; /*0x1979*/
 Buffer_2 = *v7; /*0x197b*/
 }
 while ( *v7 ); /*0x197b*/
 if ( !Size ) /*0x1985*/
 return 0; /*0x1985*/
 AllocationSize = Size + 24; /*0x198b*/
 ZeroPool = (GUID *)AllocateZeroPool(AllocationSize); /*0x1990*/
 ZeroPool_1 = ZeroPool; /*0x1995*/
 if ( !ZeroPool ) /*0x199b*/
 return 0; /*0x1a30*/
 CopyGuid(ZeroPool, PackageListGuid); /*0x19a7*/
 ZeroPool_1[1].Data1 = AllocationSize; /*0x19ac*/
 p_Data2 = &ZeroPool_1[1].Data2; /*0x19af*/
 va_copy((va_list)v12, Buffera); /*0x19b3*/
 do /*0x19de*/
 {
 Length = ReadUnaligned32(Buffer_1) - 4; /*0x19d0*/
 CopyMem(p_Data2, Buffer_1 + 1, Length); /*0x19d2*/
 ++v12; /*0x19d7*/
 p_Data2 = (unsigned __int16 *)((char *)p_Data2 + Length); /*0x19db*/
 Buffer_1 = *v12; /*0x19de*/
 }
 while ( *v12 ); /*0x19de*/
 CopyMem(p_Data2, &SourceBuffer_, 4u); /*0x19f4*/
 Protocol = (*(__int64 ( **)(__int64, GUID *, EFI_HANDLE, __int64 *))qword_3948)( /*0x1a0e*/
 qword_3948,
 ZeroPool_1,
 DeviceHandle,
 Handle);
 v15 = Handle[0]; /*0x1a10*/
 if ( Protocol < 0 ) /*0x1a18*/
 v15 = 0; /*0x1a18*/
 Handle[0] = v15; /*0x1a1c*/
 AllocateZeroPool_1(ZeroPool_1); /*0x1a24*/
 return (EFI_HII_HANDLE)Handle[0]; /*0x1a32*/
}

CHAR8 *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 ) /*0x1a54*/
 AssertReport( /*0x1a67*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiLib\\HiiLanguage.c",
 47,
 (__int64)"HiiHandle != ((void *) 0)");
 AllocationSize = 0; /*0x1a78*/
 if ( (*(__int64 ( **)(__int64, EFI_HII_HANDLE, char *, UINTN *))(qword_3928 + 24))( /*0x1a99*/
 qword_3928,
 HiiHandle,
 &v5,
 &AllocationSize) != 0x8000000000000005uLL )
 return 0; /*0x1a99*/
 ZeroPool = AllocateZeroPool(AllocationSize); /*0x1aa4*/
 ZeroPool_1 = ZeroPool; /*0x1aa9*/
 if ( !ZeroPool ) /*0x1aaf*/
 return 0; /*0x1aaf*/
 if ( (*(__int64 ( **)(__int64, EFI_HII_HANDLE, void *, UINTN *))(qword_3928 + 24))( /*0x1acc*/
 qword_3928,
 HiiHandle,
 ZeroPool,
 &AllocationSize) < 0 )
 {
 AllocateZeroPool_1(ZeroPool_1); /*0x1ad1*/
 return 0; /*0x1a9d*/
 }
 return (CHAR8 *)ZeroPool_1; /*0x1ae0*/
}

unsigned __int64 UbaSmbiosUpdateStringReplace(
 char *ZeroPool,
 __int64 a2,
 unsigned __int64 a3,
 const CHAR16 *Buffer)
{
 UINTN AllocationSize; // r14 CHAR16 *SourceBuffer; // rax CHAR8 *SourceBuffer_1; // rdi UINTN v10; // r15 __int64 v11; // rcx __int64 v12; // r14 CHAR8 *SourceBuffer_3; // rbx unsigned __int64 v14; // rax UINTN v15; // rax UINTN v16; // rsi UINTN n0xF4240; // rsi const char *(Destination____((void__)_0)); // r8 __int64 n1820; // rdx unsigned __int64 v20; // rbx UINTN n0xF4240_1; // rax UINTN n0xF4240_2; // r14 CHAR8 v23; // al signed __int64 v24; // rdi char *DestinationBuffer; // rax char *SourceBuffer_2; // rbx UINTN Length; // [rsp+20h] [rbp-10h] BYREF __int64 ZeroPool_1; // [rsp+28h] [rbp-8h] BYREF __int64 p_ZeroPool; // [rsp+60h] [rbp+30h] BYREF __int64 p_Length; // [rsp+68h] [rbp+38h] BYREF p_ZeroPool = (__int64)ZeroPool; /*0x1af2*/
 p_Length = 0; /*0x1b05*/
 Length = 0; /*0x1b0f*/
 AllocationSize = StrLen(Buffer) + 1; /*0x1b22*/
 SourceBuffer = (CHAR16 *)AllocateZeroPool(AllocationSize); /*0x1b29*/
 SourceBuffer_1 = (CHAR8 *)SourceBuffer; /*0x1b2e*/
 if ( !SourceBuffer ) /*0x1b34*/
 {
 AssertReport( /*0x1b47*/
 (__int64)"e:\\hs\\PurleyPlatPkg\\Library\\UbaPlatLib\\UbaSmbiosUpdateLib.c",
 120,
 (__int64)"AsciiString != ((void *) 0)");
 return 0x8000000000000009uLL; /*0x1b56*/
 }
 StrToAsciiStr(Buffer, SourceBuffer, AllocationSize); /*0x1b64*/
 v10 = AsciiStrLen(SourceBuffer_1); /*0x1b75*/
 UbaSmbiosFindStringBlockEnd(&p_ZeroPool, &p_Length); /*0x1b7c*/
 v11 = 1; /*0x1b85*/
 v12 = 0; /*0x1b8a*/
 SourceBuffer_3 = (CHAR8 *)(p_ZeroPool + *(unsigned __int8 *)(p_ZeroPool + 1)); /*0x1b91*/
 if ( a3 > 1 ) /*0x1b97*/
 {
 do /*0x1bb0*/
 {
 v14 = v11 + 1; /*0x1b9c*/
 if ( *SourceBuffer_3 ) /*0x1b99*/
 v14 = v11; /*0x1ba0*/
 ++SourceBuffer_3; /*0x1ba4*/
 ++v12; /*0x1ba7*/
 v11 = v14; /*0x1baa*/
 }
 while ( v14 < a3 ); /*0x1bb0*/
 }
 v15 = AsciiStrLen(SourceBuffer_3); /*0x1bb5*/
 v16 = v15; /*0x1bba*/
 if ( v10 != v15 ) /*0x1bc0*/
 {
 DestinationBuffer = (char *)AllocateZeroPool(0x300u); /*0x1d0c*/
 ZeroPool_1 = (__int64)DestinationBuffer; /*0x1d11*/
 SourceBuffer_2 = DestinationBuffer; /*0x1d15*/
 if ( !DestinationBuffer ) /*0x1d1b*/
 return 0x8000000000000009uLL; /*0x1d1b*/
 CopyMem(DestinationBuffer, (const void *)p_ZeroPool, v12 + *(unsigned __int8 *)(p_ZeroPool + 1)); /*0x1d30*/
 CopyMem(&SourceBuffer_2[*(unsigned __int8 *)(p_ZeroPool + 1) + v12], SourceBuffer_1, v10 + 1); /*0x1d4a*/
 CopyMem( /*0x1d83*/
 &SourceBuffer_2[*(unsigned __int8 *)(p_ZeroPool + 1) + 1 + v12 + v10],
 (const void *)(v12 + *(unsigned __int8 *)(p_ZeroPool + 1) + v16 + p_ZeroPool + 1),
 p_Length - *(unsigned __int8 *)(p_ZeroPool + 1) - v16 - v12 - 1);
 UbaSmbiosFindStringBlockEnd(&ZeroPool_1, &Length); /*0x1d90*/
 CopyMem((void *)p_ZeroPool, SourceBuffer_2, Length); /*0x1da0*/
 AllocateZeroPool_1(SourceBuffer_2); /*0x1da8*/
 AllocateZeroPool_1(SourceBuffer_1); /*0x1db0*/
 return 0; /*0x1db0*/
 }
 n0xF4240 = v15 + 1; /*0x1bc6*/
 if ( !SourceBuffer_3 ) /*0x1bcc*/
 {
 (Destination____((void__)_0)) = "(Destination != ((void *) 0))"; /*0x1bce*/
 n1820 = 1820; /*0x1bd5*/
LABEL_11:
 AssertReport( /*0x1bda*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
 n1820,
 (__int64)(Destination____((void__)_0)));
 v20 = 0x8000000000000002uLL; /*0x1be6*/
LABEL_28:
 DebugPrintAssertLog(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v20); /*0x1cb6*/
 AssertReport( /*0x1cdd*/
 (__int64)"e:\\hs\\PurleyPlatPkg\\Library\\UbaPlatLib\\UbaSmbiosUpdateLib.c",
 148,
 (__int64)"!EFI_ERROR (Status)");
 return v20; /*0x1ce5*/
 }
 if ( n0xF4240 > 0xF4240 ) /*0x1bfc*/
 {
 (Destination____((void__)_0)) = "(DestMax <= (_gPcd_FixedAtBuild_PcdMaximumAsciiStringLength))"; /*0x1bfe*/
 n1820 = 1827; /*0x1c05*/
 goto LABEL_11; /*0x1c0a*/
 }
 if ( v15 == -1 ) /*0x1c0f*/
 {
 (Destination____((void__)_0)) = "(DestMax != 0)"; /*0x1c11*/
 n1820 = 1833; /*0x1c18*/
 goto LABEL_11; /*0x1c1d*/
 }
 n0xF4240_1 = AsciiStrnLenS(SourceBuffer_1, n0xF4240); /*0x1c25*/
 n0xF4240_2 = n0xF4240_1; /*0x1c2a*/
 if ( n0xF4240 <= n0xF4240_1 ) /*0x1c30*/
 {
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", 1839, (__int64)"(DestMax > SourceLen)"); /*0x1c45*/
 v20 = 0x8000000000000005uLL; /*0x1c4a*/
 goto LABEL_28; /*0x1c54*/
 }
 if ( SourceBuffer_1 > SourceBuffer_3 ) /*0x1c59*/
 goto LABEL_21; /*0x1c59*/
 if ( SourceBuffer_3 >= &SourceBuffer_1[n0xF4240_1 + 1] ) /*0x1c65*/
 {
 if ( SourceBuffer_3 > SourceBuffer_1 ) /*0x1c6a*/
 goto LABEL_24; /*0x1c6a*/
LABEL_21:
 if ( SourceBuffer_1 >= &SourceBuffer_3[n0xF4240] ) /*0x1c73*/
 goto LABEL_23; /*0x1c73*/
 }
 AssertReport( /*0x1c75*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
 1844,
 (__int64)"InternalSafeStringNoAsciiStrOverlap (Destination, DestMax, (CHAR8 *)Source, SourceLen + 1)");
LABEL_23:
 if ( SourceBuffer_1 <= SourceBuffer_3 ) /*0x1c90*/
 {
LABEL_24:
 if ( SourceBuffer_3 < &SourceBuffer_1[n0xF4240_2 + 1] ) /*0x1c9c*/
 {
LABEL_27:
 v20 = 0x800000000000000FuLL; /*0x1cac*/
 goto LABEL_28; /*0x1cac*/
 }
 if ( SourceBuffer_1 < SourceBuffer_3 ) /*0x1ca1*/
 goto LABEL_29; /*0x1ca1*/
 }
 if ( SourceBuffer_1 < &SourceBuffer_3[n0xF4240] ) /*0x1caa*/
 goto LABEL_27; /*0x1caa*/
LABEL_29:
 v23 = *SourceBuffer_1; /*0x1cea*/
 if ( *SourceBuffer_1 ) /*0x1cea*/
 {
 v24 = SourceBuffer_1 - SourceBuffer_3; /*0x1cf0*/
 do /*0x1cfd*/
 {
 *SourceBuffer_3++ = v23; /*0x1cf3*/
 v23 = SourceBuffer_3[v24]; /*0x1cf8*/
 }
 while ( v23 ); /*0x1cfd*/
 }
 *SourceBuffer_3 = 0; /*0x1cff*/
 return 0; /*0x1dbc*/
}

unsigned __int64 UbaSmbiosFindStringBlockEnd(__int64 *p_ZeroPool, _QWORD *p_Length)
{
 __int64 ZeroPool; // rax __int64 Size; // rcx _BYTE *v4; // r8 unsigned __int64 i; // rax ZeroPool = *p_ZeroPool; /*0x1dc8*/
 Size = *(unsigned __int8 *)(*p_ZeroPool + 1); /*0x1dcb*/
 *p_Length = Size; /*0x1dcf*/
 v4 = (_BYTE *)(Size + ZeroPool); /*0x1dd2*/
 while ( 1 ) /*0x1dd8*/
 {
 if ( !*v4 ) /*0x1dd8*/
 {
 if ( !*++v4 ) /*0x1de3*/
 {
 *p_Length += 2LL; /*0x1e08*/
 return 0; /*0x1e0e*/
 }
 ++*p_Length; /*0x1de5*/
 }
 for ( i = 0; i < 0x40; ++i ) /*0x1de8*/
 {
 if ( !v4[i] ) /*0x1deb*/
 break; /*0x1def*/
 }
 if ( i == 64 ) /*0x1dfe*/
 break; /*0x1dfe*/
 v4 += i; /*0x1e00*/
 *p_Length += i; /*0x1e03*/
 }
 return 0x8000000000000002uLL; /*0x1e0e*/
}

__int64 UbaSmbiosFlushStringPack(void *ZeroPool)
{
 void ( **v1)(_QWORD, _QWORD, __int16 *, void *); // rax __int64 result; // rax void *ZeroPool_1; // [rsp+30h] [rbp+8h]
 __int16 Buffer; // [rsp+38h] [rbp+10h] BYREF ZeroPool_1 = ZeroPool; /*0x1e1c*/
 v1 = (void ( **)(_QWORD, _QWORD, __int16 *, void *))qword_3970; /*0x1e25*/
 if ( !qword_3970 ) /*0x1e2f*/
 {
 result = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_3850, 0, &qword_3970); /*0x1e48*/
 if ( result < 0 ) /*0x1e51*/
 return result; /*0x1e51*/
 ZeroPool = ZeroPool_1; /*0x1e53*/
 v1 = (void ( **)(_QWORD, _QWORD, __int16 *, void *))qword_3970; /*0x1e58*/
 }
 Buffer = -2; /*0x1e69*/
 (*v1)(v1, 0, &Buffer, ZeroPool); /*0x1e76*/
 return 0; /*0x1e7a*/
}

__int64 UbaSmbiosGetVariable(char a1, __int64 a2, __int64 a3, _WORD *a4)
{
 __int64 Index; // rbx __int64 result; // rax __int64 v8; // rax _BYTE v9[40]; // [rsp+30h] [rbp-28h] BYREF __int64 v10; // [rsp+68h] [rbp+10h] BYREF __int64 v11; // [rsp+70h] [rbp+18h] BYREF v11 = a3; /*0x1e85*/
 v10 = a2; /*0x1e8a*/
 Index = 0; /*0x1e96*/
 if ( !a4 ) /*0x1ea1*/
 return 0x8000000000000002uLL; /*0x1ead*/
 v8 = qword_3958; /*0x1eb2*/
 if ( !qword_3958 ) /*0x1ebc*/
 {
 result = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_3850, 0, &qword_3958); /*0x1ed5*/
 if ( result < 0 ) /*0x1ede*/
 return result; /*0x1ede*/
 v8 = qword_3958; /*0x1ee0*/
 }
 LOBYTE(v11) = a1; /*0x1eec*/
 LOWORD(v10) = -2; /*0x1ef1*/
 while ( (*(__int64 ( **)(__int64, __int64 *, __int64 *, _BYTE *, _QWORD))(v8 + 24))(v8, &v10, &v11, v9, 0) >= 0 /*0x1f1e*/
 && (_WORD)v10 != 0xFFFE )
 {
 if ( ++Index == 1 ) /*0x1f27*/
 {
 *a4 = v10; /*0x1f32*/
 return 0; /*0x1f37*/
 }
 v8 = qword_3958; /*0x1f29*/
 }
 return 0x800000000000000EuLL; /*0x1f48*/
}

__int64 UbaSmbiosSetVariableIfNotExist(__int64 a1, __int64 a2, __int64 a3)
{
 char Result; // bl __int64 result; // rax __int64 Result; // [rsp+38h] [rbp+10h] BYREF Result = a2; /*0x1f50*/
 Result = a1; /*0x1f62*/
 if ( qword_3978 /*0x1f86*/
 || (result = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_3850, 0, &qword_3978),
 result >= 0) )
 {
 result = UbaSmbiosGetVariable(Result, a2, a3, &Result); /*0x1f8f*/
 if ( result >= 0 ) /*0x1f97*/
 return (*(__int64 ( **)(__int64, _QWORD))(qword_3978 + 16))(qword_3978, (unsigned __int16)Result); /*0x1fa8*/
 }
 return result; /*0x1fab*/
}

__int64 UbaSmbiosDeleteAllKeysOfType(char n9)
{
 __int64 v1; // rax __int64 Index; // rdi __int64 v4; // rdx __int64 Result; // rcx __int64 v6; // rbx __int64 v7; // r8 __int64 Index; // rdi __int64 result; // rax char n9_1; // [rsp+58h] [rbp+10h] BYREF __int16 v11; // [rsp+60h] [rbp+18h] BYREF char v12; // [rsp+68h] [rbp+20h] BYREF v1 = qword_3968; /*0x1fbc*/
 Index = 0; /*0x1fc3*/
 if ( !qword_3968 ) /*0x1fcb*/
 {
 v6 = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_3850, 0, &qword_3968); /*0x1fea*/
 if ( v6 < 0 ) /*0x1ff0*/
 goto LABEL_9; /*0x1ff0*/
 v1 = qword_3968; /*0x1ff2*/
 }
 n9_1 = n9; /*0x1ffe*/
 v11 = -2; /*0x2003*/
 while ( (*(__int64 ( **)(__int64, __int16 *, char *, char *, _QWORD))(v1 + 24))(v1, &v11, &n9_1, &v12, 0) >= 0 /*0x202d*/
 && v11 != -2 )
 {
 v1 = qword_3968; /*0x202f*/
 ++Index; /*0x2036*/
 }
 v6 = Index; /*0x203b*/
LABEL_9:
 Index = 0; /*0x203e*/
 if ( !v6 ) /*0x2043*/
 return 0; /*0x205a*/
 while ( 1 ) /*0x2045*/
 {
 LOBYTE(Result) = n9; /*0x2045*/
 result = UbaSmbiosSetVariableIfNotExist(Result, v4, v7); /*0x2048*/
 if ( result < 0 ) /*0x2050*/
 break; /*0x2050*/
 if ( ++Index >= (unsigned __int64)v6 ) /*0x2058*/
 return 0; /*0x2058*/
 }
 return result; /*0x205c*/
}

__int64 PciWriteMmPciUsra(unsigned __int8 a1, char a2, char a3)
{
 _DWORD Status[6]; // [rsp+20h] [rbp-18h] BYREF Status[3] = 0; /*0x2068*/
 Status[1] = 0; /*0x2070*/
 Status[2] = 512; /*0x2086*/
 Status[0] = (a3 & 7 | (8 * (a2 & 0x1F | (32 *a1)))) << 12; /*0x2097*/
 return (*(__int64 ( **)(_DWORD *))(qword_3980 + 24))(Status); /*0x20a5*/
}

void *CopyMem(void *DestinationBuffer, const void *SourceBuffer, UINTN Length)
{
 void *DestinationBuffer_1; // rax unsigned __int64 Size; // rbp DestinationBuffer_1 = DestinationBuffer; /*0x20c9*/
 if ( Length ) /*0x20cf*/
 {
 Size = Length - 1; /*0x20d1*/
 if ( Length - 1 > ~(unsigned __int64)DestinationBuffer ) /*0x20db*/
 AssertReport( /*0x20f0*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
 56,
 (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)DestinationBuffer)");
 if ( Size > ~(unsigned __int64)SourceBuffer ) /*0x20fe*/
 AssertReport( /*0x2113*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
 57,
 (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)SourceBuffer)");
 if ( DestinationBuffer == SourceBuffer ) /*0x211b*/
 return DestinationBuffer; /*0x211d*/
 else return InternalCopyMem((char *)DestinationBuffer, (char *)SourceBuffer, Length); /*0x212b*/
 }
 return DestinationBuffer_1; /*0x213f*/
}

UINTN AsciiStrLen(const CHAR8 *String)
{
 const CHAR8 *v1; // rbx UINTN i; // rdi v1 = String; /*0x2152*/
 if ( !String ) /*0x2158*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 1082, (__int64)"String != ((void *) 0)"); /*0x216d*/
 for ( i = 0; *v1; ++i ) /*0x2174*/
 {
 if ( i >= 0xF4240 ) /*0x2180*/
 AssertReport( /*0x2195*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
 1090,
 (__int64)"Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength");
 ++v1; /*0x219a*/
 }
 return i; /*0x21ad*/
}

__int64 sub_21B4(const CHAR8 *SupportedLanguages, const CHAR8 *a2, unsigned __int64 n3)
{
 unsigned __int64 n3_1; // rdi const CHAR8 *SupportedLanguages_1; // rbx n3_1 = n3; /*0x21c3*/
 SupportedLanguages_1 = SupportedLanguages; /*0x21c9*/
 if ( !n3 ) /*0x21cf*/
 return 0; /*0x21d1*/
 if ( AsciiStrLen(SupportedLanguages) == -1 ) /*0x21e1*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 1320, (__int64)"AsciiStrSize (FirstString)"); /*0x21f6*/
 if ( AsciiStrLen(a2) == -1 ) /*0x2207*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 1321, (__int64)"AsciiStrSize (SecondString)"); /*0x221c*/
 if ( n3_1 > 0xF4240 ) /*0x2228*/
 AssertReport( /*0x223d*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
 1324,
 (__int64)"Length <= _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength");
 while ( *SupportedLanguages_1 && *a2 && *SupportedLanguages_1 == *a2 && n3_1 > 1 ) /*0x2251*/
 {
 ++SupportedLanguages_1; /*0x2253*/
 ++a2; /*0x2256*/
 --n3_1; /*0x2259*/
 }
 return *SupportedLanguages_1 - *a2; /*0x2277*/
}

UINTN StrLen(const CHAR16 *Buffer)
{
 UINTN v1; // rdx UINTN Result; // rdi UINTN result; // rax Result = v1; /*0x228a*/
 if ( ((unsigned __int8)Buffer & 1) != 0 ) /*0x2293*/
 AssertReport( /*0x22a8*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
 128,
 (__int64)"((UINTN) String & 0x00000001) == 0");
 if ( !Buffer || !Result ) /*0x22b7*/
 return 0; /*0x22d9*/
 result = 0; /*0x22b9*/
 if ( *Buffer ) /*0x22bb*/
 {
 while ( result < Result - 1 ) /*0x22c7*/
 {
 if ( !Buffer[++result] ) /*0x22cc*/
 return result; /*0x22d0*/
 }
 return Result; /*0x22d4*/
 }
 return result; /*0x22e0*/
}

UINTN AsciiStrnLenS(const CHAR8 *SourceBuffer, UINTN MaxSize)
{
 UINTN result; // rax if ( !SourceBuffer || !MaxSize ) /*0x22f0*/
 return 0; /*0x230f*/
 result = 0; /*0x22f2*/
 if ( *SourceBuffer ) /*0x22f4*/
 {
 while ( result < MaxSize - 1 ) /*0x22ff*/
 {
 if ( !SourceBuffer[++result] ) /*0x2304*/
 return result; /*0x2308*/
 }
 return MaxSize; /*0x230b*/
 }
 return result; /*0x230a*/
}

unsigned __int64 StrToAsciiStr(const CHAR16 *Buffer, CHAR16 *SourceBuffer, UINTN n0xF4240)
{
 const CHAR16 *Buffer_1; // rbx const char *(Destination____((void__)_0)); // r8 __int64 n2682; // rdx UINTN n0xF4240_1; // rax UINTN n0xF4240_2; // rbp Buffer_1 = Buffer; /*0x2339*/
 if ( ((unsigned __int8)Buffer & 1) != 0 ) /*0x233f*/
 AssertReport( /*0x2350*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
 2677,
 (__int64)"((UINTN) Source & 0x00000001) == 0");
 if ( !SourceBuffer ) /*0x235b*/
 {
 (Destination____((void__)_0)) = "(Destination != ((void *) 0))"; /*0x235d*/
 n2682 = 2682; /*0x2364*/
LABEL_5:
 AssertReport( /*0x2369*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
 n2682,
 (__int64)(Destination____((void__)_0)));
 return 0x8000000000000002uLL; /*0x237b*/
 }
 if ( !Buffer_1 ) /*0x2383*/
 {
 (Destination____((void__)_0)) = "(Source != ((void *) 0))"; /*0x2385*/
 n2682 = 2683; /*0x238c*/
 goto LABEL_5; /*0x2391*/
 }
 if ( n0xF4240 > 0xF4240 ) /*0x239a*/
 {
 (Destination____((void__)_0)) = "(DestMax <= (_gPcd_FixedAtBuild_PcdMaximumAsciiStringLength))"; /*0x239c*/
 n2682 = 2689; /*0x23a3*/
 goto LABEL_5; /*0x23a8*/
 }
 if ( !n0xF4240 ) /*0x23ad*/
 {
 (Destination____((void__)_0)) = "(DestMax != 0)"; /*0x23af*/
 n2682 = 2698; /*0x23b6*/
 goto LABEL_5; /*0x23bb*/
 }
 n0xF4240_1 = StrLen(Buffer_1); /*0x23c3*/
 n0xF4240_2 = n0xF4240_1; /*0x23c8*/
 if ( n0xF4240 <= n0xF4240_1 ) /*0x23ce*/
 {
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", 2704, (__int64)"(DestMax > SourceLen)"); /*0x23df*/
 return 0x8000000000000005uLL; /*0x23ee*/
 }
 if ( Buffer_1 > SourceBuffer ) /*0x23f6*/
 goto LABEL_17; /*0x23f6*/
 if ( SourceBuffer >= &Buffer_1[n0xF4240_1 + 1] ) /*0x2403*/
 {
 if ( SourceBuffer > Buffer_1 ) /*0x2408*/
 goto LABEL_20; /*0x2408*/
LABEL_17:
 if ( Buffer_1 >= (CHAR16 *)((char *)SourceBuffer + n0xF4240) ) /*0x2411*/
 goto LABEL_19; /*0x2411*/
 }
 AssertReport( /*0x2413*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
 2709,
 (__int64)"!InternalSafeStringIsOverlap (Destination, DestMax, (void *)Source, (SourceLen + 1) *sizeof(CHAR16))");
LABEL_19:
 if ( Buffer_1 > SourceBuffer ) /*0x242a*/
 {
LABEL_22:
 if ( Buffer_1 < (CHAR16 *)((char *)SourceBuffer + n0xF4240) ) /*0x2445*/
 return 0x800000000000000FuLL; /*0x2445*/
 goto LABEL_27; /*0x2445*/
 }
LABEL_20:
 if ( SourceBuffer < &Buffer_1[n0xF4240_2 + 1] ) /*0x2437*/
 return 0x800000000000000FuLL; /*0x2451*/
 if ( Buffer_1 >= SourceBuffer ) /*0x243c*/
 goto LABEL_22; /*0x243c*/
LABEL_27:
 while ( *Buffer_1 ) /*0x2482*/
 {
 if ( *Buffer_1 >= 0x100u ) /*0x245b*/
 AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", 2719, (__int64)"*Source < 0x100"); /*0x246c*/
 *(_BYTE *)SourceBuffer = *(_BYTE *)Buffer_1; /*0x2473*/
 SourceBuffer = (CHAR16 *)((char *)SourceBuffer + 1); /*0x2475*/
 ++Buffer_1; /*0x2478*/
 }
 *(_BYTE *)SourceBuffer = 0; /*0x2484*/
 return 0; /*0x2498*/
}