Newer
Older
AMI-Aptio-BIOS-Reversed / SetupDefaultLoad / SetupDefaultLoad.c
@Ajax Dong Ajax Dong 2 days ago 50 KB Init
/*
 *SetupDefaultLoad - Decompiled SetupDefaultLoad
 *Source: Auto-generated from IDA Pro decompilation
 *
 *Decompiled from port 13437
 */

#include "SetupDefaultLoad.h"

/*
 *sub_2A0 at 0x2a0
 */
void *sub_2A0(void *buf, unsigned __int64 count, char value)
{
 memset(buf, value, count); /*0x2aa*/
 return buf; /*0x2af*/
}

/*
 *_mm_pause_w at 0x300
 */
void sub_300()
{
 _mm_pause(); /*0x300*/
}

/*
 *__rdtsc_w at 0x310
 */
unsigned __int64 sub_310()
{
 return __rdtsc(); /*0x319*/
}

/*
 *_enable_w at 0x320
 */
void sub_320()
{
 _enable(); /*0x320*/
}

/*
 *_disable_w at 0x330
 */
void sub_330()
{
 _disable(); /*0x330*/
}

/*
 *__getcallerseflags_w at 0x340
 */
unsigned __int64 _getcallerseflags_w()
{
 return __getcallerseflags(); /*0x342*/
}

/*
 *sub_350 at 0x350
 */
char *sub_350(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; /*0x360*/
 if ( src < dst && &src[count - 1] >= dst ) /*0x368*/
 {
 src_1 = &src[count - 1]; /*0x380*/
 dst_2 = &dst[count - 1]; /*0x383*/
 }
 else
 {
 count_1 = count; /*0x36a*/
 count &= 7u; /*0x36d*/
 count_1 >>= 3; /*0x374*/
 qmemcpy(dst, src, 8 *count_1); /*0x378*/
 src_1 = &src[8 *count_1]; /*0x378*/
 dst_2 = &dst[8 *count_1]; /*0x378*/
 }
 qmemcpy(dst_2, src_1, count); /*0x38c*/
 return dst_1; /*0x38f*/
}

/*
 *_ModuleEntryPoint at 0x3e0
 */
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
 __int64 n2; // rcx SetupDefaultLoadDriverEntry((__int64)ImageHandle, SystemTable); /*0x3e9*/
 return SetupDefaultLoadMain(n2, SystemTable); /*0x3f6*/
}

/*
 *SetupDefaultLoadDriverEntry at 0x3fc
 */
// DXE driver entry point called from _ModuleEntryPoint. Initializes the driver, registers for setup variable notifications.
void SetupDefaultLoadDriverEntry(__int64 ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
 signed __int64 Status; // rax __int64 Status; // rbx __int64 Status; // rax __int64 v6; // rax __int64 v7; // rax char *src; // rbx __int64 v9; // rax __int64 Size; // rax unsigned __int64 count; // rax __int64 v12; // rcx __int64 Status; // rax __int64 Status; // rax __int64 Status; // rax _WORD *v16; // rax _BYTE *v17; // rax __int16 callerseflags_w; // bx bool v19; // bl unsigned __int32 v20; // edi unsigned __int32 i; // eax

 ::ImageHandle = ImageHandle; /*0x415*/
 if ( !ImageHandle ) /*0x429*/
 VPrintWrapper( /*0x438*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 51,
 (__int64)"gImageHandle != ((void *) 0)");
 SystemTable_0 = (__int64)SystemTable; /*0x43d*/
 if ( !SystemTable ) /*0x447*/
 VPrintWrapper( /*0x456*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 57,
 (__int64)"gST != ((void *) 0)");
 BootServices_0 = (__int64)SystemTable->BootServices; /*0x45f*/
 if ( !BootServices_0 ) /*0x469*/
 VPrintWrapper( /*0x478*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
 63,
 (__int64)"gBS != ((void *) 0)");
 RuntimeServices_0 = (__int64)SystemTable->RuntimeServices; /*0x481*/
 if ( !RuntimeServices_0 ) /*0x48b*/
 VPrintWrapper( /*0x49e*/
 (__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeServicesTableLib\\UefiRuntimeServicesTableLib.c",
 47,
 (__int64)"gRT != ((void *) 0)");
 Status = GetNvStorageData((__int64)&unk_7490, &qword_7950); /*0x4b1*/
 Status = Status; /*0x4bd*/
 if ( Status < 0 ) /*0x4cf*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x4d9*/
 VPrintWrapper( /*0x4ed*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
 64,
 (__int64)"!EFI_ERROR (Status)");
 }
 if ( !qword_7950 ) /*0x4fa*/
 VPrintWrapper( /*0x50f*/
 (__int64)"e:\\hs\\MdePkg\\Library\\DxeServicesTableLib\\DxeServicesTableLib.c",
 65,
 (__int64)"gDS != ((void *) 0)");
 if ( Status < 0 ) /*0x517*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x522*/
 VPrintWrapper( /*0x536*/
 (__int64)"e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\X64\\LenovoServerPkg\\SetupDefaults\\SetupDefaultLoad\\DEBUG\\AutoGen.c",
 450,
 (__int64)"!EFI_ERROR (Status)");
 }
 if ( !qword_7958 ) /*0x543*/
 {
 Status = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_73C0, 0, &qword_7958); /*0x55c*/
 if ( Status < 0 ) /*0x565*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x570*/
 VPrintWrapper( /*0x584*/
 (__int64)"e:\\hs\\CpRcPkg\\Library\\DxeMmPciBaseLib\\DxeMmPciBaseLib.c",
 52,
 (__int64)"!EFI_ERROR (Status)");
 }
 if ( !qword_7958 ) /*0x591*/
 VPrintWrapper( /*0x5a6*/
 (__int64)"e:\\hs\\CpRcPkg\\Library\\DxeMmPciBaseLib\\DxeMmPciBaseLib.c",
 53,
 (__int64)"mPciUsra != ((void *) 0)");
 }
 LogSetupError(); /*0x5ab*/
 v6 = LogStatusCode(); /*0x5b0*/
 qword_7968 = (*(__int64 ( **)(__int64))(v6 + 32))(5); /*0x5bd*/
 v7 = LogStatusCode(); /*0x5c4*/
 src = (char *)(*(__int64 ( **)(__int64))(v7 + 40))(7); /*0x5d5*/
 v9 = LogStatusCode(); /*0x5d8*/
 if ( (unsigned __int64)(*(__int64 ( **)(__int64))(v9 + 56))(7) > 0x48 ) /*0x5e7*/
 VPrintWrapper( /*0x5fb*/
 (__int64)"e:\\hs\\AmiCRBPkg\\Library\\AmiPcieSegBusLib\\AmiPcieSegBusDxeSmm.c",
 60,
 (__int64)"sizeof (PCIE_SEG_BUS_TABLE) >= LibPcdGetSize(7U)");
 Size = LogStatusCode(); /*0x600*/
 count = (*(__int64 ( **)(__int64))(Size + 56))(7); /*0x608*/
 CopyConfiguredBuffer(v12, src, count); /*0x611*/
 Status = (*(__int64 ( **)(void *, _QWORD, void *))(BootServices_0 + 320))(&unk_7440, 0, &unk_79D0); /*0x62d*/
 if ( Status < 0 ) /*0x63d*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x648*/
 VPrintWrapper( /*0x658*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
 88,
 (__int64)"!EFI_ERROR (Status)");
 }
 Status = (*(__int64 ( **)(void *, _QWORD, void *))(BootServices_0 + 320))(&unk_7420, 0, &unk_79F0); /*0x674*/
 if ( Status < 0 ) /*0x67d*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x688*/
 VPrintWrapper( /*0x698*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
 94,
 (__int64)"!EFI_ERROR (Status)");
 }
 Status = (*(__int64 ( **)(void *, _QWORD, void *))(BootServices_0 + 320))(&unk_73F0, 0, &unk_79E0); /*0x6b4*/
 if ( Status < 0 ) /*0x6bd*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x6c8*/
 VPrintWrapper( /*0x6d8*/
 (__int64)"e:\\hs\\MdeModulePkg\\Library\\UefiHiiServicesLib\\UefiHiiServicesLib.c",
 100,
 (__int64)"!EFI_ERROR (Status)");
 }
 (*(void ( **)(void *, _QWORD, void *))(BootServices_0 + 320))(&unk_74D0, 0, &unk_79D8); /*0x6f4*/
 (*(void ( **)(void *, _QWORD, void *))(BootServices_0 + 320))(&unk_7400, 0, &unk_79E8); /*0x711*/
 if ( *(char *)GetSetupDataSize(1024068) >= 0 ) /*0x727*/
 {
 v16 = (_WORD *)GetSetupDataSize(1024064); /*0x72c*/
 GetStringHeight(v16); /*0x734*/
 v17 = (_BYTE *)GetSetupDataSize(1024068); /*0x73b*/
 *v17 |= 0x80u; /*0x745*/
 }
 callerseflags_w = _getcallerseflags_w(); /*0x74c*/
 disable_w(); /*0x74f*/
 v19 = (callerseflags_w & 0x200) != 0; /*0x75e*/
 v20 = CalculateCheckSum(0x508u) & 0xFFFFFF; /*0x768*/
 _rdtsc_w(); /*0x76e*/
 for ( i = CalculateCheckSum(0x508u); ((v20 + 357 - i) & 0x800000) == 0; i = CalculateCheckSum(0x508u) ) /*0x775*/
 mm_pause_w(); /*0x782*/
 _rdtsc_w(); /*0x79c*/
 if ( v19 ) /*0x7a3*/
 enable_w(); /*0x7a5*/
 else disable_w(); /*0x7ac*/
}

/*
 *ValidateInputParameters at 0x7cc
 */
char ValidateInputParameters(
 __int64 SizeValue,
 __int64 DataPointer,
 __int64 ReturnData,
 __int64 OffsetValue)
{
 __int64 FunctionResult; // rax __int64 v6; // rax char v7; // cl char n3; // [rsp+50h] [rbp+8h] BYREF char v9; // [rsp+58h] [rbp+10h] BYREF char n2; // [rsp+60h] [rbp+18h] BYREF FunctionResult = FunctionResult; /*0x7d0*/
 if ( !FunctionResult ) /*0x7da*/
 {
 if ( (*(__int64 ( **)(void *, _QWORD, __int64 *, __int64))(BootServices + 320))( /*0x7fc*/
 &unk_7450,
 0,
 &FunctionResult,
 OffsetValue) < 0 )
 {
 FunctionResult = 0; /*0x7fe*/
 return 85; /*0x80b*/
 }
 FunctionResult = FunctionResult; /*0x80d*/
 }
 n2 = 2; /*0x819*/
 LOBYTE(OffsetValue) = 69; /*0x823*/
 n3 = 3; /*0x82b*/
 LOBYTE(DataPointer) = 46; /*0x847*/
 v6 = (*(__int64 ( **)(__int64, __int64, _QWORD, __int64, char *, char, char *, char *))(FunctionResult + 16))( /*0x84c*/
 FunctionResult,
 DataPointer,
 0,
 OffsetValue,
 &n2,
 1,
 &v9,
 &n3);
 v7 = v9; /*0x84f*/
 if ( v6 < 0 ) /*0x85c*/
 return 85; /*0x85c*/
 return v7; /*0x861*/
}

/*
 *ProcessSetupConfig at 0x868
 */
__int64 ProcessSetupConfig(char a1, _BYTE *a2, __int64 a3, __int64 a4)
{
 __int64 Result; // rax _BYTE *v5; // rbx __int64 result; // rax _BYTE v8[24]; // [rsp+40h] [rbp-18h] BYREF char n3; // [rsp+70h] [rbp+18h] BYREF char v10; // [rsp+78h] [rbp+20h] BYREF Result = qword_7920; /*0x872*/
 v5 = a2; /*0x879*/
 if ( !qword_7920 ) /*0x882*/
 {
 result = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_7450, 0, &qword_7920); /*0x89b*/
 if ( result < 0 ) /*0x8a4*/
 {
 qword_7920 = 0; /*0x8a6*/
 return result; /*0x8ae*/
 }
 Result = qword_7920; /*0x8b0*/
 }
 v8[0] = a1; /*0x8bc*/
 LOBYTE(a4) = 44; /*0x8c6*/
 n3 = 3; /*0x8ce*/
 LOBYTE(a2) = 46; /*0x8ea*/
 result = (*(__int64 ( **)(__int64, _BYTE *, _QWORD, __int64, _BYTE *, char, char *, char *))(Result + 16))( /*0x8ef*/
 Result,
 a2,
 0,
 a4,
 v8,
 1,
 &v10,
 &n3);
 if ( result >= 0 ) /*0x8f5*/
 {
 *v5 = v10; /*0x8fb*/
 return 0; /*0x8fd*/
 }
 return result; /*0x904*/
}

/*
 *UpdateSetupData at 0x90c
 */
__int64 UpdateSetupData(char a1, __int64 a2, __int64 a3, __int64 a4)
{
 __int64 v4; // rax char v5; // bl __int64 result; // rax _BYTE v8[24]; // [rsp+40h] [rbp-18h] BYREF char n3; // [rsp+70h] [rbp+18h] BYREF char v10; // [rsp+78h] [rbp+20h] BYREF v4 = qword_7920; /*0x916*/
 v5 = a2; /*0x91d*/
 if ( !qword_7920 ) /*0x925*/
 {
 result = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_7450, 0, &qword_7920); /*0x93e*/
 if ( result < 0 ) /*0x947*/
 {
 qword_7920 = 0; /*0x949*/
 return result; /*0x951*/
 }
 v4 = qword_7920; /*0x953*/
 }
 v8[0] = a1; /*0x95f*/
 LOBYTE(a4) = 43; /*0x969*/
 v8[1] = v5; /*0x971*/
 LOBYTE(a2) = 46; /*0x98c*/
 n3 = 3; /*0x991*/
 return (*(__int64 ( **)(__int64, __int64, _QWORD, __int64, _BYTE *, char, char *, char *))(v4 + 16))( /*0x99e*/
 v4,
 a2,
 0,
 a4,
 v8,
 2,
 &v10,
 &n3);
}

/*
 *CopySetupBuffer at 0x9a4
 */
__int64 CopySetupBuffer(char *p_nn, __int64 ProtocolGuid, __int64 n4, __int64 ProtocolInterface)
{
 __int64 FunctionResult; // r10 __int64 result; // rax unsigned __int8 Index; // di int v8; // [rsp+28h] [rbp-20h]
 char v9; // [rsp+58h] [rbp+10h] BYREF char v10; // [rsp+60h] [rbp+18h] BYREF char nn; // [rsp+68h] [rbp+20h] BYREF unsigned __int8 v12; // [rsp+69h] [rbp+21h]
 char v13; // [rsp+6Ah] [rbp+22h]
 char v14; // [rsp+6Bh] [rbp+23h]

 FunctionResult = FunctionResult; /*0x9ae*/
 result = 0; /*0x9b5*/
 if ( !FunctionResult ) /*0x9bd*/
 {
 result = (*(__int64 ( **)(void *, _QWORD, __int64 *, __int64))(BootServices + 320))( /*0x9d6*/
 &unk_7450,
 0,
 &FunctionResult,
 ProtocolInterface);
 if ( result < 0 ) /*0x9df*/
 {
 FunctionResult = 0; /*0x9e1*/
 return result; /*0x9e1*/
 }
 FunctionResult = FunctionResult; /*0x9f4*/
 }
 Index = 0; /*0x9fb*/
 if ( p_nn[1] ) /*0x9fe*/
 {
 while ( 1 ) /*0xa06*/
 {
 LOBYTE(ProtocolInterface) = 18; /*0xa06*/
 nn = *p_nn; /*0xa09*/
 LOBYTE(ProtocolGuid) = 56; /*0xa14*/
 v12 = Index; /*0xa16*/
 v14 = 0; /*0xa1b*/
 v9 = 1; /*0xa20*/
 v13 = p_nn[Index + 2]; /*0xa42*/
 LOBYTE(v8) = 4; /*0xa49*/
 result = (*(__int64 ( **)(__int64, __int64, _QWORD, __int64, char *, int, char *, char *))(FunctionResult + 16))( /*0xa53*/
 FunctionResult,
 ProtocolGuid,
 0,
 ProtocolInterface,
 &nn,
 v8,
 &v10,
 &v9);
 if ( ++Index >= (unsigned __int8)p_nn[1] ) /*0xa5e*/
 break; /*0xa5e*/
 FunctionResult = FunctionResult; /*0xa60*/
 }
 }
 return result; /*0x9ee*/
}

/*
 *GetConfigAccess at 0xa6c
 */
// Gets the UEFI Setup configuration access protocol (gEfiSetupConfigAccessProtocolGuid). References the Setup string to locate protocol interface.
__int64 GetConfigAccess(unsigned __int8 nn)
{
 int nn_1; // ebx __int64 ProtocolGuid; // rdx __int64 ConfigData; // r8 __int64 ProtocolInterface; // r9 __int64 SetupBuffer; // rdi __int64 VariableName; // rsi __int64 AttributeValue; // rbx char OptionValue; // al __int64 SetupBuffer_1; // rax char p_n2_2; // cl char p_n2_1; // al __int64 AttributeValue_1; // rax char DataType; // cl __int64 VariableName_1; // rax char StatusFlag; // dl char nn_2; // [rsp+30h] [rbp-D0h] BYREF char n8; // [rsp+31h] [rbp-CFh]
 char p_n2; // [rsp+32h] [rbp-CEh] BYREF char DataType_1; // [rsp+33h] [rbp-CDh]
 char v21; // [rsp+34h] [rbp-CCh]
 char n2; // [rsp+35h] [rbp-CBh]
 char StatusFlag_1; // [rsp+36h] [rbp-CAh]
 char v24; // [rsp+37h] [rbp-C9h]
 char v25; // [rsp+38h] [rbp-C8h]
 char v26; // [rsp+39h] [rbp... [9893 chars total]

/*
 *InitDefaultConfigData at 0x101c
 */
// Initializes the default configuration data buffer. Allocates memory and populates with factory default settings.
char InitDefaultConfigData()
{
 __int64 ProtocolInterface; // rax __int64 ConfigDataSize; // rcx __int64 DataBuffer; // r8 _BYTE *StatusValue; // rdx unsigned __int16 BufferSize; // ax __int64 IndexCount; // rdx __int64 v6; // r9 unsigned __int8 LoopIndex; // bl __int64 DataPtr; // r9 __int64 v9; // rdx int v11; // [rsp+28h] [rbp-D8h]
 _BYTE v12[6688]; // [rsp+40h] [rbp-C0h] BYREF char n2; // [rsp+1A70h] [rbp+1970h] BYREF unsigned __int16 BufferSize_1; // [rsp+1A78h] [rbp+1978h] BYREF __int16 BufferSize_2; // [rsp+1A80h] [rbp+1980h] BYREF __int64 n6668; // [rsp+1A88h] [rbp+1988h] BYREF if ( FunctionResult /*0x1058*/
 || (ProtocolInterface = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices + 320))(
 &unk_7450,
 0,
 &FunctionResult),
 ProtocolInterface >= 0) )
 {
 n6668 = 6668; /*0x106c*/
 ProtocolInterface = (*(__int64 ( **)(const __int16 *, void *, _QWORD, __int64 *, _BYTE *))(RuntimeServices + 72))( /*0x109b*/
 L"SocketIioConfig",
 &unk_7470,
 0,
 &n6668,
 v12);
 if ( ProtocolInterface >= 0 ) /*0x10a1*/
 {
 ProcessSetupDefaults(ConfigDataSize); /*0x10a7*/
 BufferSize_1 = 0; /*0x10ac*/
 n6668 = 49; /*0x10bb*/
 if ( OptionByte && byte_7D60[0] ) /*0x10d0*/
 {
 DataBuffer = (unsigned __int8)byte_7D60[0]; /*0x10d2*/
 StatusValue = &unk_7D61; /*0x10d6*/
 BufferSize = BufferSize_1; /*0x10dd*/
 do /*0x1126*/
 {
 if ( StatusValue[1] <= 0x17u /*0x110e*/
 && *StatusValue <= 0xBu
 && v12[((unsigned __int64)(unsigned __int8)StatusValue[1] >> 2) + 4266] == 1
 && v12[(unsigned __int8)StatusValue[1] + 4278] == 1 )
 {
 BufferSize |= 1 << (*StatusValue & 0xF); /*0x1113*/
 BufferSize_1 = BufferSize; /*0x1117*/
 }
 StatusValue += 2; /*0x111e*/
 --DataBuffer; /*0x1122*/
 }
 while ( DataBuffer ); /*0x1126*/
 }
 else
 {
 BufferSize = BufferSize_1; /*0x112a*/
 }
 ConsolePrint(64, "SendVmdCommandToBp %x to BMC\n", BufferSize); /*0x1141*/
 for ( LoopIndex = 0; LoopIndex < 0xAu; ++LoopIndex ) /*0x1146*/
 {
 n2 = 0; /*0x114f*/
 LOBYTE(v6) = 96; /*0x115b*/
 LOBYTE(v11) = 2; /*0x116b*/
 LOBYTE(IndexCount) = 46; /*0x1178*/
 ProtocolInterface = (*(__int64 ( **)(__int64, __int64, _QWORD, __int64, unsigned __int16 *, int, _QWORD, char *))(FunctionResult + 16))( /*0x1184*/
 FunctionResult,
 IndexCount,
 0,
 v6,
 &BufferSize_1,
 v11,
 0,
 &n2);
 if ( ProtocolInterface >= 0 ) /*0x118a*/
 {
 (*(void ( **)(__int64))(BootServices + 248))(5000); /*0x1198*/
 BufferSize_2 = 0; /*0x119e*/
 LOBYTE(DataPtr) = 97; /*0x11b2*/
 n2 = 2; /*0x11bc*/
 LOBYTE(v9) = 46; /*0x11d2*/
 LOBYTE(v11) = 0; /*0x11d4*/
 ProtocolInterface = (*(__int64 ( **)(__int64, __int64, _QWORD, __int64, _QWORD, int, __int16 *, char *))(FunctionResult + 16))( /*0x11e2*/
 FunctionResult,
 v9,
 0,
 DataPtr,
 0,
 v11,
 &BufferSize_2,
 &n2);
 if ( ProtocolInterface < 0 ) /*0x11e8*/
 break; /*0x11e8*/
 LOBYTE(ProtocolInterface) = BufferSize_1; /*0x11ea*/
 if ( (_BYTE)BufferSize_2 == (_BYTE)BufferSize_1 ) /*0x11f6*/
 {
 LOBYTE(ProtocolInterface) = HIBYTE(BufferSize_1); /*0x11f8*/
 if ( HIBYTE(BufferSize_2) == HIBYTE(BufferSize_1) ) /*0x1204*/
 break; /*0x1204*/
 }
 }
 }
 }
 }
 else
 {
 FunctionResult = 0; /*0x105a*/
 }
 return ProtocolInterface; /*0x1211*/
}

/*
 *GetSetupVariableData at 0x121c
 */
// Retrieves setup variable data from UEFI variables using GetVariable. References the Setup string for variable name lookup.
unsigned __int64 GetSetupVariableData(unsigned __int8 *a1)
{
 __int64 VariableSize; // rdx int CrcValue; // ecx int CheckSum; // ecx int DataOffset; // ecx int AttributeFlag; // ecx int IndexValue; // ecx unsigned __int8 StatusByte; // cl char n2_1; // al __int64 DataTable_1; // r9 _BYTE *BufferPtr; // rax void *ProtocolPtr; // rdx const __int16 *SocketProcessorCoreConfig; // rcx unsigned __int8 n4_1; // cl char ConfigByte; // al unsigned __int8 ResultByte; // al __int64 DataTable; // rdi unsigned __int8 Remaining; // cl char n7_1; // al unsigned __int8 v21; // al bool v22; // zf _BYTE v23[72]; // [rsp+30h] [rbp-D0h] BYREF char n7; // [rsp+78h] [rbp-88h]
 _BYTE BufferPtr_2[11]; // [rsp+200h] [rbp+100h] BYREF char n3; // [rsp+20Bh] [rbp+10Bh]
 _BYTE BufferPtr_4[52]; // [rsp+2E0h] [rbp+1E0h] BYREF char n4... [11465 chars total]

/*
 *GetBootOptionValue at 0x1914
 */
// Gets the boot option value based on a switch/case table. Maps option IDs to their corresponding byte values.
char GetBootOptionValue(char n7, char n8, char DefaultId, char a4, char a5, char a6, char TempByte)
{
 char BootOption; // al __int64 OptionByte; // rdx BootOption = 0; /*0x1919*/
 switch ( n7 ) /*0x1926*/
 {
 case 0: /*0x1926*/
 if ( !a4 ) /*0x19c6*/
 return BootOption; /*0x19c6*/
 BootOption = ::BootOption; /*0x19c8*/
 goto LABEL_25; /*0x19c8*/
 case 1: /*0x1926*/
 if ( !a4 ) /*0x19b9*/
 return BootOption; /*0x19b9*/
 BootOption = BootOption_0; /*0x19bb*/
 goto LABEL_25; /*0x19c1*/
 case 2: /*0x1926*/
 if ( !a5 ) /*0x19ac*/
 return BootOption; /*0x19ac*/
 BootOption = BootOption_1; /*0x19ae*/
 goto LABEL_25; /*0x19b4*/
 case 3: /*0x1926*/
 if ( !a5 ) /*0x199e*/
 return BootOption; /*0x199e*/
 BootOption = BootOption_2; /*0x19a0*/
 goto LABEL_25; /*0x19a6*/
 case 4: /*0x1926*/
 if ( !a6 ) /*0x1990*/
 return BootOption; /*0x1990*/
 BootOption = BootOption_3; /*0x1992*/
 goto LABEL_25; /*0x1998*/
 case 5: /*0x1926*/
 if ( !a6 ) /*0x1982*/
 return BootOption; /*0x1982*/
 BootOption = BootOption_4; /*0x1984*/
 goto LABEL_25; /*0x198a*/
 case 6: /*0x1926*/
 if ( !TempByte ) /*0x1974*/
 return BootOption; /*0x1974*/
 BootOption = BootOption_5; /*0x1976*/
 goto LABEL_25; /*0x197c*/
 }
 if ( n7 == 7 && TempByte ) /*0x1962*/
 {
 BootOption = BootOption_6; /*0x1968*/
LABEL_25:
 OptionByte = (unsigned __int8)OptionByte; /*0x19ce*/
 byte_7D60[2 * (unsigned __int8)OptionByte + 1] = DefaultId + n7 - n8; /*0x19e2*/
 byte_7D60[2 *OptionByte + 2] = BootOption; /*0x19e7*/
 OptionByte = OptionByte + 1; /*0x19ee*/
 }
 return BootOption; /*0x19f9*/
}

/*
 *ProcessSetupMenuOption at 0x19fc
 */
char ProcessSetupMenuOption(unsigned __int8 n4, char a2, char n11, __int64 a4, char n11a, char a6, char n2)
{
 char result; // al int v10; // ecx int v11; // ecx __int64 Result; // rdx result = 0; /*0x1a00*/
 if ( n4 ) /*0x1a0b*/
 {
 v10 = n4 - 1; /*0x1a0d*/
 if ( v10 ) /*0x1a10*/
 {
 v11 = v10 - 1; /*0x1a12*/
 if ( v11 ) /*0x1a15*/
 {
 if ( v11 != 1 ) /*0x1a1a*/
 return result; /*0x1a1a*/
 if ( n2 == 1 ) /*0x1a24*/
 {
 if ( !a6 ) /*0x1a2a*/
 return result; /*0x1a2a*/
 result = byte_7521; /*0x1a2c*/
 }
 else
 {
 if ( !a6 ) /*0x1a38*/
 return result; /*0x1a38*/
 result = byte_7503; /*0x1a3a*/
 }
 }
 else if ( n2 == 1 ) /*0x1a47*/
 {
 if ( !a6 ) /*0x1a4d*/
 return result; /*0x1a4d*/
 result = byte_751C; /*0x1a4f*/
 }
 else
 {
 if ( !a6 ) /*0x1a5b*/
 return result; /*0x1a5b*/
 result = byte_74FE; /*0x1a5d*/
 }
 }
 else
 {
 if ( !n11a ) /*0x1a69*/
 return result; /*0x1a69*/
 result = byte_74F9; /*0x1a6b*/
 }
 }
 else
 {
 if ( !n11a ) /*0x1a77*/
 return result; /*0x1a77*/
 result = byte_74F4; /*0x1a79*/
 }
 Result = (unsigned __int8)byte_7D91; /*0x1a7f*/
 byte_7D60[2 * (unsigned __int8)byte_7D91 + 1] = n11 + n4 - a2; /*0x1a93*/
 byte_7D60[2 *Result + 2] = result; /*0x1a98*/
 byte_7D91 = Result + 1; /*0x1a9f*/
 return result; /*0x1aa5*/
}

/*
 *ProcessSetupDefaults at 0x1aa8
 */
// Processes setup default values. Compares each setup option against its factory default and queues updates. Calls CompareSetupValues for individual comparisons.
__int64 ProcessSetupDefaults(__int64 ConfigDataSize)
{
 unsigned __int8 OptionByte; // si __int64 DataPointer; // rdx __int64 SizeValue; // rcx __int64 ReturnData_1; // r8 __int64 OffsetValue; // r9 unsigned __int8 DefaultId; // r12 unsigned __int8 n11_1; // r15 __int64 MatchFlag; // r8 char EntryIndex; // r9 bool v10; // zf __int64 v11; // r8 char ReturnData; // r9 __int64 v13; // r8 char StatusValue; // r9 __int64 v15; // r8 char UpdateFlag; // r9 unsigned __int8 TempByte; // r13 int CountValue; // r8d int n5; // r9d char p_n8_1; // di char CurrentByte_1; // bl __int64 v22; // r8 char v23; // r9 __int64 v24; // r9 char p_n8_2; // cl char v26; // cl unsigned __int8 CurrentByte; // r11 char n11_2; // r14 char v29; // si char v30; // r11 unsigned __int8 CurrentByte_2; // r11 char n11_3; // r12 char v33; // di char v34; // r11 char p_n8_3; // cl char v36; // cl char n11_4; // r14 char v38; // si char v39; // r11 __int64 result; // rax unsigned __int8 v41; // [rsp+40h] [rbp-18h]
 unsigned __int8 v42; // [rsp+41h] [rbp-17h]
 unsigned __int8 v43; // [rsp+42h] [rbp-16h]
 _BYTE p_n4[21]; // [rsp+43h] [rbp-15h] BYREF int Size; // [rsp+A0h] [rbp+48h] BYREF char v46; // [rsp+A8h] [rbp+50h] BYREF unsigned int p_n8; // [rsp+B0h] [rbp+58h] BYREF char DefaultId_1; // [rsp+B8h] [rbp+60h] BYREF OptionByte = 0; /*0x1abc*/
 DefaultId_1 = -1; /*0x1abe*/
 LOBYTE(p_n8) = 0; /*0x1ac6*/
 p_n4[0] = 0; /*0x1ace*/
 LOBYTE(Size) = -1; /*0x1adf*/
 if ( CompareSetupValues(ConfigDataSize, &p_n8, &DefaultId_1, p_n4, &Size) < 0 )
 return ConsolePrint(
 0x80000000LL,
 "[OemCollectNvmeVmdSlotInfo]: Get BP type failed!! Skip update the NVME slot info in VMD menu! \n");
 DefaultId = DefaultId_1; /*0x1af1*/
 n11_1 = Size; /*0x1af5*/
 if ( DefaultId_1 == -1 && (_BYTE)Size == 0xFF )
 return ConsolePrint(
 0x80000000LL,
 "[OemCollectNvmeVmdSlotInfo]: Get BP type failed!! Skip update the NVME slot info in VMD menu! \n");
 ValidateInputParameters(SizeValue, DataPointer, ReturnData_1, OffsetValue); /*0x1b08*/
 Size = 0; /*0x1b11*/
 GetDefaultFromTable(16973832, &Size, MatchFlag, EntryIndex); /*0x1b19*/
 v10 = Size == 0; /*0x1b1e*/
 Size = 0; /*0x1b2a*/
 v41 = v10; /*0x1b2d*/
 GetDefaultFromTable(16973833, &Size, v11, ReturnData); /*0x1b31*/
 v10 = Size == 0; /*0x1b36*/
 Size = 0; /*0x1b42*/
 v42 = v10; /*0x1b45*/
 GetDefaultFromTable(16973834, &Size, v13, StatusValue); /*0x1b49*/
 v10 = Size == 0; /*0x1b4e*/
 Size = 0; /*0x1b5a*/
 v43 = v10; /*0x1b5d*/
 GetDefaultFromTable(16973835, &Size, v15, UpdateFlag); /*0x1b61*/
 TempByte = Size == 0; /*0x1b71*/
 CheckSetupOverride(&Size, &v46, CountValue, n5); /*0x1b75*/
 p_n8_1 = p_n8; /*0x1b7a*/
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: OnBoardNvmeBaseIndexNumber = %x\n", (unsigned __int8)p_n8);
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: OnBoardNvmeBaseSlotNumber = %x\n", DefaultId);
 CurrentByte_1 = p_n4[0]; /*0x1ba9*/
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: RiserNvmeBaseIndexNumber = %x\n", p_n4[0]);
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: RiserNvmeBaseSlotNumber = %x\n", n11_1);
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: IsOnBoardNVME67Present = %x\n", TempByte);
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: IsOnBoardNVME45Present = %x\n", v43);
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: IsOnBoardNVME23Present = %x\n", v42);
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: IsOnBoardNVME01Present = %x\n", v41);
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: FirstInterPoserCardInstall = %x\n", (unsigned __int8)Size);
 ConsolePrint(0x80000000LL, "[OemCollectNvmeVmdSlotInfo]: SecondInterPoserCardInstallx = %x\n", (unsigned __int8)v46);
 ::OptionByte = 0; /*0x1c4d*/
 GetDefaultFromTable(17170432, (int *)&p_n4[1], v22, v23); /*0x1c59*/
 if ( *(_DWORD *)&p_n4[1] == 1 ) /*0x1c62*/
 {
 if ( TempByte ) /*0x1c6b*/
 {
 p_n8_2 = p_n8_1; /*0x1c6d*/
 if ( (unsigned __int8)p_n8_1 >= 8u ) /*0x1c74*/
 goto LABEL_25; /*0x1c74*/
 do /*0x1ca6*/
 {
 GetBootOptionValue(p_n8_2, p_n8_1, DefaultId, v41, v42, v43, TempByte); /*0x1c9c*/
 p_n8_2 = v26 + 1; /*0x1ca1*/
 }
 while ( (unsigned __int8)p_n8_2 < 8u ); /*0x1ca6*/
 }
 else
 {
 CurrentByte = CurrentByte_1; /*0x1cad*/
 if ( (unsigned __int8)CurrentByte_1 >= 4u ) /*0x1cb3*/
 goto LABEL_25; /*0x1cb3*/
 n11_2 = Size; /*0x1cb9*/
 v29 = v46; /*0x1cbd*/
 do /*0x1ce4*/
 {
 ProcessSetupMenuOption(CurrentByte, CurrentByte_1, n11_1, v24, n11_2, v29, 1); /*0x1cd8*/
 CurrentByte = v30 + 1; /*0x1cdd*/
 }
 while ( CurrentByte < 4u ); /*0x1ce4*/
 }
 }
 else
 {
 CurrentByte_2 = CurrentByte_1; /*0x1ceb*/
 if ( TempByte ) /*0x1cf1*/
 {
 if ( (unsigned __int8)CurrentByte_1 < 4u ) /*0x1cf6*/
 {
 n11_3 = Size; /*0x1cf8*/
 v33 = v46; /*0x1cfc*/
 do /*0x1d23*/
 {
 ProcessSetupMenuOption(CurrentByte_2, CurrentByte_1, n11_1, v24, n11_3, v33, 2); /*0x1d17*/
 CurrentByte_2 = v34 + 1; /*0x1d1c*/
 }
 while ( CurrentByte_2 < 4u ); /*0x1d23*/
 p_n8_1 = p_n8; /*0x1d25*/
 DefaultId = DefaultId_1; /*0x1d29*/
 }
 p_n8_3 = p_n8_1; /*0x1d2d*/
 if ( (unsigned __int8)p_n8_1 >= 8u ) /*0x1d34*/
 goto LABEL_25; /*0x1d34*/
 do /*0x1d62*/
 {
 GetBootOptionValue(p_n8_3, p_n8_1, DefaultId, v41, v42, v43, TempByte); /*0x1d58*/
 p_n8_3 = v36 + 1; /*0x1d5d*/
 }
 while ( (unsigned __int8)p_n8_3 < 8u ); /*0x1d62*/
 }
 else
 {
 if ( (unsigned __int8)CurrentByte_1 >= 4u ) /*0x1d69*/
 goto LABEL_25; /*0x1d69*/
 n11_4 = Size; /*0x1d6b*/
 v38 = v46; /*0x1d6f*/
 do /*0x1d96*/
 {
 ProcessSetupMenuOption(CurrentByte_2, CurrentByte_1, n11_1, v24, n11_4, v38, 2); /*0x1d8a*/
 CurrentByte_2 = v39 + 1; /*0x1d8f*/
 }
 while ( CurrentByte_2 < 4u ); /*0x1d96*/
 }
 }
 OptionByte = 0; /*0x1d9e*/
LABEL_25:
 byte_7D60[0] = ::OptionByte; /*0x1da0*/
 result = ConsolePrint(
 0x80000000LL,
 "[OemCollectNvmeVmdSlotInfo]: mVmdSetupConfiguration.DevCount = %x\n",
 (unsigned __int8)::OptionByte);
 if ( ::OptionByte )
 {
 do
 {
 ConsolePrint(
 0x80000000LL,
 "[OemCollectNvmeVmdSlotInfo]: mVmdSetupConfiguration.Dev[%x].SlotIndex = %x\n",
 OptionByte,
 (unsigned __int8)byte_7D60[2 *OptionByte + 1]);
 result = ConsolePrint(
 0x80000000LL,
 "[OemCollectNvmeVmdSlotInfo]: mVmdSetupConfiguration.Dev[%x].VmdPortIndex = %x\n",
 OptionByte,
 (unsigned __int8)byte_7D60[2 *OptionByte + 2]);
 ++OptionByte; /*0x1e07*/
 }
 while ( OptionByte < (unsigned __int8)::OptionByte );
 }
 return result; /*0x1e26*/
}

/*
 *SetupDefaultLoadMain at 0x1e38
 */
// Main entry for loading UEFI setup defaults. Iterates through setup variables, compares against factory defaults, and applies them.
EFI_STATUS SetupDefaultLoadMain(__int64 n2, EFI_SYSTEM_TABLE *SystemTable)
{
 unsigned __int8 StatusByte; // bl char ConfigFlag; // r13 EFI_BOOT_SERVICES *BootServices; // rdi __int64 ProtocolInterface; // rax __int64 FunctionResult; // rcx __int64 DataPointer; // rdx __int64 SizeValue; // rcx __int64 ReturnData; // r8 __int64 OffsetValue; // r9 unsigned __int8 ConfigByte_1; // al char n33; // r8 __int64 BufferSize; // rdx unsigned __int8 ConfigByte; // cl char OptionByte; // al int n4; // r8d __int64 DataSize; // r9 char LoopCounter; // al int v19; // ecx int v20; // ecx int v21; // ecx int v22; // ecx int v23; // ecx __int16 MaxEntries; // ax int v25; // ecx int v26; // ecx int v27; // ecx int v28; // ecx int BufferPointer; // ecx __int64 FunctionResult_1; // rax __int64 ConfigIndex;... [73709 chars total]

/*
 *CalculateCheckSum at 0x5358
 */
unsigned __int32 CalculateCheckSum(unsigned __int16 n1288)
{
 if ( (n1288 & 3) != 0 ) /*0x5364*/
 sub_5450((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c", 193, (__int64)"(Port & 3) == 0"); /*0x5379*/
 return __indword(n1288); /*0x5382*/
}

/*
 *LogDebugMessage at 0x5388
 */
__int64 LogDebugMessage()
{
 __int64 result; // rax unsigned __int64 n0x10; // rbx __int64 v2; // rax __int64 Result; // rcx result = qword_7948; /*0x5392*/
 if ( !qword_7948 ) /*0x539e*/
 {
 n0x10 = (*(__int64 ( **)(__int64))(BootServices_0 + 24))(31); /*0x53b7*/
 (*(void ( **)(unsigned __int64))(BootServices_0 + 32))(n0x10); /*0x53ba*/
 if ( n0x10 <= 0x10 ) /*0x53c1*/
 {
 v2 = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_73A0, 0, &qword_7948); /*0x53de*/
 Result = qword_7948; /*0x53e4*/
 if ( v2 < 0 ) /*0x53ee*/
 Result = 0; /*0x53ee*/
 qword_7948 = Result; /*0x53f2*/
 return Result; /*0x53f9*/
 }
 else
 {
 return 0; /*0x53c3*/
 }
 }
 return result; /*0x5401*/
}

/*
 *ConsolePrint at 0x5408
 */
__int64 ConsolePrint(__int64 a1, const char *a2, ...)
{
 __int64 result; // rax __int64 ( **v4)(__int64, const char *, __int64 *); // r10 va_list va; // [rsp+40h] [rbp+18h] BYREF va_start(va, a2);
 result = LogDebugMessage(); /*0x541f*/
 if ( result ) /*0x542a*/
 {
 result = sub_5DA0(); /*0x542c*/
 if ( ((unsigned int)result & (unsigned int)a1) != 0 ) /*0x5437*/
 return (*v4)(a1, a2, (__int64 *)va); /*0x5446*/
 }
 return result; /*0x5449*/
}

/*
 *VPrintWrapper at 0x5450
 */
__int64 VPrintWrapper(__int64 a1, __int64 a2, __int64 a3)
{
 __int64 result; // rax result = LogDebugMessage(); /*0x5468*/
 if ( result ) /*0x5470*/
 return (*(__int64 ( **)(__int64, __int64, __int64))(result + 8))(a1, a2, a3); /*0x547b*/
 return result; /*0x5488*/
}

/*
 *AllocateZeroBuffer at 0x5490
 */
void *AllocateZeroBuffer(char *p_n2, unsigned __int64 n256)
{
 if ( n256 - 1 > -1 - (__int64)p_n2 ) /*0x54ae*/
 VPrintWrapper( /*0x54c3*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\SetMemWrapper.c",
 54,
 (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)Buffer)");
 return sub_2A0(p_n2, n256, 0); /*0x54d6*/
}

/*
 *GetNvStorageData at 0x54e0
 */
unsigned __int64 GetNvStorageData(__int64 a1, _QWORD *a2)
{
 __int64 SystemTable; // rdi __int64 Index; // rbx __int64 i; // r14 if ( !a1 ) /*0x5502*/
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 97, (__int64)"TableGuid != ((void *) 0)"); /*0x5515*/
 if ( !a2 ) /*0x551d*/
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\UefiLib\\UefiLib.c", 98, (__int64)"Table != ((void *) 0)"); /*0x5530*/
 SystemTable = SystemTable_0; /*0x5535*/
 Index = 0; /*0x553c*/
 *a2 = 0; /*0x553e*/
 if ( !*(_QWORD *)(SystemTable + 104) ) /*0x5542*/
 return 0x800000000000000EuLL; /*0x556b*/
 for ( i = 0; !sub_5F54(a1, i + *(_QWORD *)(SystemTable + 112)); i += 24 ) /*0x5548*/
 {
 if ( (unsigned __int64)++Index >= *(_QWORD *)(SystemTable + 104) ) /*0x5569*/
 return 0x800000000000000EuLL; /*0x5569*/
 }
 *a2 = *(_QWORD *)(*(_QWORD *)(SystemTable + 112) + 24 *Index + 16); /*0x559f*/
 return 0; /*0x5589*/
}

/*
 *IsBufferEmpty at 0x55a4
 */
__int64 IsBufferEmpty()
{
 _DWORD Status[6]; // [rsp+20h] [rbp-18h] BYREF Status[3] = 0; /*0x55ab*/
 Status[1] = 0; /*0x55b3*/
 Status[2] = 512; /*0x55b7*/
 Status[0] = 1015808; /*0x55be*/
 return (*(__int64 ( **)(_DWORD *))(qword_7958 + 24))(Status); /*0x55cf*/
}

/*
 *LogSetupError at 0x55d4
 */
__int64 LogSetupError()
{
 __int64 result; // rax signed __int64 NvStorageData; // rax result = qword_7960; /*0x55d8*/
 if ( !qword_7960 ) /*0x55e2*/
 {
 NvStorageData = GetNvStorageData((__int64)&unk_7480, &qword_7960); /*0x55f2*/
 if ( NvStorageData < 0 ) /*0x55fa*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", NvStorageData); /*0x560b*/
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 54, (__int64)"!EFI_ERROR (Status)"); /*0x5623*/
 }
 result = qword_7960; /*0x5628*/
 if ( !qword_7960 ) /*0x5632*/
 {
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 55, (__int64)"mHobList != ((void *) 0)"); /*0x5645*/
 return qword_7960; /*0x564a*/
 }
 }
 return result; /*0x5651*/
}

/*
 *GetSetupDataSize at 0x5658
 */
__int64 GetSetupDataSize(__int64 n1024064)
{
 if ( (n1024064 & 0xFFFFFFFFF0000000uLL) != 0 ) /*0x5668*/
 VPrintWrapper( /*0x567d*/
 (__int64)"e:\\hs\\MdePkg\\Library\\SmmPciExpressLib\\PciExpressLib.c",
 118,
 (__int64)"((Address) & ~0xfffffff) == 0");
 return n1024064 + qword_7968; /*0x568c*/
}

/*
 *CompareSetupBuffers at 0x5694
 */
__int64 CompareSetupBuffers(unsigned __int64 a1)
{
 _BYTE *v1; // rdx unsigned __int64 v2; // r9 unsigned __int64 n8; // r10 unsigned __int64 v4; // r8 v1 = &unk_75F0; /*0x5697*/
 v2 = a1 + 16; /*0x569e*/
 n8 = a1 & 7; /*0x56a2*/
 if ( (a1 & 7) != 0 && n8 == ((unsigned __int64)&unk_75F0 & 7) ) /*0x56b1*/
 {
 v4 = 8 - n8; /*0x56b9*/
 if ( n8 != 8 ) /*0x56bc*/
 {
 do /*0x56ce*/
 {
 if ( *(_BYTE *)a1 != *v1 ) /*0x56c2*/
 break; /*0x56c2*/
 ++a1; /*0x56c4*/
 ++v1; /*0x56c7*/
 --v4; /*0x56ca*/
 }
 while ( v4 ); /*0x56ce*/
 }
 }
 while ( a1 <= v2 - 8 && *(_QWORD *)a1 == *(_QWORD *)v1 ) /*0x56dc*/
 {
 a1 += 8LL; /*0x56de*/
 v1 += 8; /*0x56e2*/
 }
 while ( 1 ) /*0x56f9*/
 {
 if ( a1 >= v2 ) /*0x56fc*/
 return 0; /*0x5700*/
 if ( *(_BYTE *)a1 != *v1 ) /*0x56f1*/
 break; /*0x56f1*/
 ++a1; /*0x56f3*/
 ++v1; /*0x56f6*/
 }
 return *(char *)a1 - (char)*v1; /*0x5700*/
}

/*
 *InitializeSetupContext at 0x5710
 */
__int64 InitializeSetupContext()
{
 __int64 Status; // r11 __int64 Table; // rbx unsigned __int64 Buffer; // rdi __int64 v3; // rax Status = 0; /*0x5721*/
 Table = *(_QWORD *)(SystemTable + 104); /*0x5724*/
 Buffer = *(_QWORD *)(SystemTable + 112); /*0x5728*/
 if ( Table ) /*0x572f*/
 {
 while ( CompareSetupBuffers(Buffer) ) /*0x573c*/
 {
 Buffer += 24LL; /*0x573e*/
 if ( !--Table ) /*0x5746*/
 goto LABEL_4; /*0x5746*/
 }
 v3 = *(_QWORD *)(Buffer + 16); /*0x5762*/
 }
 else
 {
LABEL_4:
 v3 = Status; /*0x5748*/
 }
 if ( v3 ) /*0x574e*/
 LODWORD(Status) = *(_DWORD *)(v3 + 12); /*0x5750*/
 return (unsigned int)Status; /*0x575c*/
}

/*
 *CheckSetupOverride at 0x5768
 */
__int64 CheckSetupOverride(_BYTE *p_n11, _BYTE *a2, __int64 n4, char n5)
{
 __int64 v6; // r8 char v7; // r9 __int64 result; // rax int Result; // [rsp+30h] [rbp+8h] BYREF

 *p_n11 = 0; /*0x5775*/
 *a2 = 0; /*0x577b*/
 Result = 1; /*0x5783*/
 GetDefaultFromTable(16842767, &Result, n4, n5); /*0x5790*/
 if ( !Result ) /*0x579a*/
 *p_n11 = 1; /*0x579c*/
 result = GetDefaultFromTable(16842768, &Result, v6, v7); /*0x57a9*/
 if ( !Result ) /*0x57b3*/
 *a2 = 1; /*0x57b5*/
 return result; /*0x57bd*/
}

/*
 *CompareSetupValues at 0x57c4
 */
// Compares a setup variable value against its default value. Returns match/mismatch status. Called from ProcessSetupDefaults.
__int64 CompareSetupValues(__int64 ConfigDataSize, _BYTE *p_n8, _BYTE *p_DefaultId, _BYTE *p_n4, _BYTE *n11)
{
 __int64 FunctionResult; // rax _BYTE *n11_1; // r15 _BYTE *p_n4_1; // rdi bool IsMatch; // r13 _BYTE *p_n8_1; // r14 char n11_2; // r12 __int64 Size; // r8 char Size; // r9 __int64 CompareStatus; // rax char DefaultPtr_1; // cl bool Size; // bl __int64 Size; // r8 char Size; // r9 bool Size; // zf __int64 v20; // [rsp+40h] [rbp-C0h] BYREF unsigned __int64 v21; // [rsp+48h] [rbp-B8h]
 _BYTE v22[298]; // [rsp+50h] [rbp-B0h] BYREF char DefaultPtr; // [rsp+17Ah] [rbp+7Ah]
 __int64 ConfigDataSize_1; // [rsp+3C0h] [rbp+2C0h] BYREF unsigned int v25; // [rsp+3C8h] [rbp+2C8h] BYREF __int64 n814; // [rsp+3D0h] [rbp+2D0h] BYREF ConfigDataSize_1 = ConfigDataSize; /*0x57c9*/
 FunctionResult = FunctionResult; /*0x57e8*/
 n11_1 = n11; /*0x57f1*/
 p_n4_1 = p_n4; /*0x57fb*/
 n814 = 814; /*0x57fe*/
 IsMatch = FunctionResult == 0; /*0x5809*/
 v20 = 0x4BB5EBA4EC87D643LL; /*0x580d*/
 v21 = 0xA90DB2363E3FE5A1uLL; /*0x5820*/
 p_n8_1 = p_n8; /*0x5828*/
 n11_2 = -1; /*0x5833*/
 *p_DefaultId = -1; /*0x5836*/
 *n11_1 = -1; /*0x583a*/
 *p_n8 = 0; /*0x583e*/
 *p_n4 = 0; /*0x5840*/
 v25 = 0; /*0x5843*/
 if ( IsMatch /*0x5887*/
 || (LOBYTE(ConfigDataSize_1) = 1,
 LOBYTE(p_n4) = 89,
 LOBYTE(p_n8) = 46,
 (*(__int64 ( **)(__int64, _BYTE *, _QWORD, _BYTE *, _QWORD, _BYTE, _BYTE **, __int64 *, __int64, unsigned __int64))(FunctionResult + 16))(
 FunctionResult,
 p_n8,
 0,
 p_n4,
 0,
 0,
 &n11,
 &ConfigDataSize_1,
 v20,
 v21) < 0) )
 {
 IsMatch = 1; /*0x5897*/
 }
 else
 {
 n11_2 = (char)n11; /*0x5889*/
 }
 if ( (*(__int64 ( **)(const __int16 *, __int64 *, unsigned int *, __int64 *, _BYTE *))(RuntimeServices_0 + 72))( /*0x58cb*/
 L"Setup",
 &v20,
 &v25,
 &n814,
 v22) < 0 )
 return 0x8000000000000003uLL; /*0x58d7*/
 DefaultPtr_1 = DefaultPtr; /*0x58dc*/
 if ( !IsMatch ) /*0x58ee*/
 DefaultPtr_1 = n11_2; /*0x58ee*/
 DefaultPtr = DefaultPtr_1; /*0x58f1*/
 GetDefaultFromTable(17170432, (int *)&ConfigDataSize_1, Size, Size); /*0x58f9*/
 Size = (_DWORD)ConfigDataSize_1 != 1; /*0x5911*/
 LODWORD(ConfigDataSize_1) = 0; /*0x5914*/
 GetDefaultFromTable(16973835, (int *)&ConfigDataSize_1, Size, Size); /*0x591d*/
 Size = (_DWORD)ConfigDataSize_1 == 0; /*0x5924*/
 *p_n4_1 = 0; /*0x592a*/
 if ( Size ) /*0x5932*/
 {
 if ( Size ) /*0x5970*/
 {
 if ( !n11_2 ) /*0x5975*/
 {
 *p_DefaultId = 4; /*0x5999*/
 *n11_1 = 0; /*0x599c*/
 goto LABEL_34; /*0x599f*/
 }
 if ( n11_2 == 9 ) /*0x597b*/
 {
 *p_n8_1 = 4; /*0x5990*/
 *p_DefaultId = 8; /*0x5994*/
 }
 else
 {
 *p_n8_1 = 0; /*0x597d*/
 if ( n11_2 == 11 ) /*0x5984*/
 {
 *p_DefaultId = 4; /*0x598b*/
 goto LABEL_15; /*0x598e*/
 }
 *p_DefaultId = -1; /*0x5986*/
 }
LABEL_29:
 *n11_1 = -1; /*0x59b8*/
 goto LABEL_35; /*0x59bc*/
 }
 if ( !n11_2 ) /*0x59a4*/
 {
 *n11_1 = 8; /*0x59c8*/
 goto LABEL_33; /*0x59c8*/
 }
 *p_DefaultId = -1; /*0x59a6*/
 if ( n11_2 == 9 ) /*0x59ad*/
 {
 *p_n8_1 = 4; /*0x59be*/
 }
 else
 {
 *p_n8_1 = 0; /*0x59af*/
 if ( n11_2 != 11 ) /*0x59b6*/
 goto LABEL_29; /*0x59b6*/
 }
 *n11_1 = 8; /*0x59c2*/
 goto LABEL_35; /*0x59c6*/
 }
 if ( n11_2 == 1 ) /*0x593b*/
 {
 *p_DefaultId = 2; /*0x5965*/
 *n11_1 = 6; /*0x5968*/
LABEL_34:
 *p_n8_1 = 0; /*0x59cf*/
 goto LABEL_35; /*0x59cf*/
 }
 if ( n11_2 == 8 ) /*0x5940*/
 {
 *p_n8_1 = 4; /*0x5958*/
 *p_DefaultId = 4; /*0x595c*/
 *n11_1 = 4; /*0x595f*/
 goto LABEL_35; /*0x5963*/
 }
 if ( n11_2 != 10 ) /*0x5945*/
 {
 *n11_1 = -1; /*0x5947*/
LABEL_33:
 *p_DefaultId = -1; /*0x59cc*/
 goto LABEL_34; /*0x59cc*/
 }
 *p_n8_1 = 4; /*0x594d*/
 *p_DefaultId = 0; /*0x5951*/
LABEL_15:
 *n11_1 = 0; /*0x5953*/
LABEL_35:
 if ( IsMatch ) /*0x59d5*/
 return 0; /*0x59d5*/
 CompareStatus = (*(__int64 ( **)(const __int16 *, __int64 *, _QWORD, __int64, _BYTE *))(RuntimeServices_0 /*0x5a02*/
 + 88))(
 L"Setup",
 &v20,
 v25,
 n814,
 v22);
 if ( CompareStatus >= 0 ) /*0x5a08*/
 return 0; /*0x5a0a*/
 return CompareStatus; /*0x5a14*/
}

/*
 *ValidateSetupOption at 0x5a28
 */
// Validates a setup option index against the option list range. Returns valid/invalid status.
unsigned __int64 ValidateSetupOption(int ValidFlag, __int64 a2, __int64 a3, char a4, int *a5)
{
 unsigned int ValidFlag_1; // ebx unsigned __int64 IndexValue; // rdi _DWORD *SetupProtocolInterface; // rsi _QWORD TempIndex[5]; // [rsp+20h] [rbp-28h] BYREF unsigned int CheckResult; // [rsp+68h] [rbp+20h] BYREF LOBYTE(CheckResult) = a4; /*0x5a32*/
 ValidFlag_1 = (unsigned __int16)ValidFlag; /*0x5a41*/
 IndexValue = BYTE2(ValidFlag); /*0x5a4a*/
 if ( !ValidateBufferIndex(ValidFlag) )
 {
 ConsolePrint(
 0x80000000LL,
 "GPIO ERROR: Incorrect GpioPad define used on this chipset (Group=%d, Pad=%d)!\n",
 (unsigned int)IndexValue,
 ValidFlag_1);
 return 0x8000000000000003uLL; /*0x5a77*/
 }
 SetupProtocolInterface = GetSetupProtocolInterface(TempIndex); /*0x5a86*/
 if ( IndexValue >= TempIndex[0] )
 {
 ConsolePrint(0x80000000LL, "GPIO ERROR: Group argument (%d) exceeds GPIO group range\n", (unsigned int)IndexValue);
 return 0x8000000000000002uLL; /*0x5ab1*/
 }
 if ( ValidFlag_1 >= SetupProtocolInterface[15 *IndexValue + 14] )
 {
 ConsolePrint(0x80000000LL, "GPIO ERROR: Pin number (%d) exceeds possible range for this group\n", ValidFlag_1);
 return 0x8000000000000002uLL; /*0x5ac7*/
 }
 ApplyVariableDefault(ValidFlag, &CheckResult); /*0x5ad1*/
 if ( CheckResult )
 {
 ConsolePrint(
 0x80000000LL,
 "GPIO ERROR: Accessing pad not owned by host (Group=%d, Pad=%d)!\n",
 (unsigned int)IndexValue,
 ValidFlag_1);
 return 0x8000000000000003uLL; /*0x5ae4*/
 }
 *a5 = *(_DWORD *)((unsigned __int16)(SetupProtocolInterface[15 *IndexValue + 13] + 8 *ValidFlag_1) /*0x5b0f*/
 | ((LOBYTE(SetupProtocolInterface[15 *IndexValue]) | 0xFD00LL) << 16))
 & 2;
 return 0; /*0x5b1d*/
}

/*
 *GetDefaultFromTable at 0x5b28
 */
__int64 GetDefaultFromTable(int a1, int *a2, __int64 a3, char a4)
{
 signed __int64 Status; // rax signed __int64 Result; // rdi Status = ValidateSetupOption(a1, (__int64)a2, a3, a4, a2); /*0x5b3a*/
 Result = Status; /*0x5b3f*/
 if ( Status < 0 ) /*0x5b45*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x5b56*/
 VPrintWrapper( /*0x5b6e*/
 (__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
 935,
 (__int64)"!EFI_ERROR (Status)");
 }
 *a2 = (unsigned int)*a2 >> 1; /*0x5b73*/
 return Result; /*0x5b7d*/
}

/*
 *ApplyVariableDefault at 0x5b84
 */
// Applies a factory default value to a specific setup variable entry.
unsigned __int64 ApplyVariableDefault(int ValidFlag, unsigned int *p_CheckResult)
{
 unsigned int ValidFlag_1; // ebx unsigned __int64 TempIndex__1; // rdi _DWORD *SetupProtocolInterface; // rax __int64 n1389; // rdx unsigned __int64 TempIndex_; // [rsp+40h] [rbp+18h] BYREF ValidFlag_1 = (unsigned __int16)ValidFlag; /*0x5b95*/
 TempIndex__1 = BYTE2(ValidFlag); /*0x5ba0*/
 SetupProtocolInterface = GetSetupProtocolInterface(&TempIndex_); /*0x5ba6*/
 if ( TempIndex__1 >= TempIndex_ )
 {
 ConsolePrint(0x80000000LL, "GPIO ERROR: Group argument (%d) exceeds GPIO group range\n", TempIndex__1);
 n1389 = 1389; /*0x5bcb*/
LABEL_3:
 VPrintWrapper( /*0x5bd0*/
 (__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
 n1389,
 (__int64)"((BOOLEAN)(0==1))");
 return 0x8000000000000002uLL; /*0x5bed*/
 }
 if ( ValidFlag_1 >= SetupProtocolInterface[15 * (unsigned int)TempIndex__1 + 14] )
 {
 ConsolePrint(0x80000000LL, "GPIO ERROR: Pin number (%d) exceeds possible range for this group\n", ValidFlag_1);
 n1389 = 1398; /*0x5c0d*/
 goto LABEL_3; /*0x5c12*/
 }
 *p_CheckResult = (*(_DWORD *)(((LOBYTE(SetupProtocolInterface[15 * (unsigned int)TempIndex__1]) | 0xFD00LL) << 16) /*0x5c4d*/
 | (unsigned __int16)(LOWORD(SetupProtocolInterface[15 * (unsigned int)TempIndex__1 + 1])
 + 4 * (ValidFlag_1 >> 3)))
 & (unsigned int)(3 << (4 * (ValidFlag_1 & 7)))) >> (4 * (ValidFlag_1 & 7));
 return 0; /*0x5c5b*/
}

/*
 *GetSetupProtocolInterface at 0x5c64
 */
void *GetSetupProtocolInterface(_QWORD *TempIndex)
{
 int n2; // ebx __int64 Buffer; // rax unsigned __int16 StringWidth; // ax n2 = n2_7; /*0x5c6e*/
 if ( n2_7 == 2 )
 {
 Buffer = IsBufferEmpty(); /*0x5c7c*/
 StringWidth = GetStringWidth((unsigned __int16 *)(Buffer + 2)); /*0x5c85*/
 if ( ((StringWidth + 24128) & 0xFF70) != 0 )
 {
 ConsolePrint(0x80000000LL, "Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", StringWidth);
 VPrintWrapper( /*0x5cc3*/
 (__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
 290,
 (__int64)"((BOOLEAN)(0==1))");
 }
 else
 {
 n2 = 1; /*0x5cca*/
 }
 n2_7 = n2; /*0x5ccf*/
 }
 if ( n2 == 1 ) /*0x5cd8*/
 {
 *TempIndex = 13; /*0x5cda*/
 return &unk_7600; /*0x5ce1*/
 }
 else
 {
 *TempIndex = 0; /*0x5cea*/
 return 0; /*0x5cee*/
 }
}

/*
 *ValidateBufferIndex at 0x5cfc
 */
bool ValidateBufferIndex(int ValidFlag)
{
 int n2; // eax n2 = InitializeSubSystem(); /*0x5d04*/
 if ( n2 == 1 ) /*0x5d0c*/
 return (ValidFlag & 0xFF000000) == 0x1000000; /*0x5d14*/
 if ( n2 != 2 ) /*0x5d23*/
 return 0; /*0x5d23*/
 return (ValidFlag & 0xFF000000) == 0x2000000; /*0x5d35*/
}

/*
 *GetStringWidth at 0x5d3c
 */
__int64 GetStringWidth(unsigned __int16 *a1)
{
 if ( ((unsigned __int8)a1 & 1) != 0 ) /*0x5d48*/
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c", 151, (__int64)"(Address & 1) == 0"); /*0x5d5d*/
 return *a1; /*0x5d65*/
}

/*
 *GetStringHeight at 0x5d6c
 */
__int64 GetStringHeight(_WORD *a1)
{
 if ( ((unsigned __int8)a1 & 1) != 0 ) /*0x5d78*/
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c", 183, (__int64)"(Address & 1) == 0"); /*0x5d8d*/
 *a1 = 1280; /*0x5d97*/
 return 1280; /*0x5d9a*/
}

/*
 *GetCurrentTsc at 0x5da0
 */
__int64 GetCurrentTsc()
{
 unsigned __int8 v0; // al char n3_1; // al char n3; // cl __int64 result; // rax v0 = __inbyte(0x70u); /*0x5da5*/
 __outbyte(0x70u, v0 & 0x80 | 0x4B); /*0x5daa*/
 n3_1 = __inbyte(0x71u); /*0x5db0*/
 n3 = n3_1; /*0x5db1*/
 if ( (unsigned __int8)n3_1 > 3u ) /*0x5db8*/
 {
 n3 = n3; /*0x5dba*/
 if ( !n3 ) /*0x5dc2*/
 n3 = MEMORY[0xFDAF0490] & 2 | 1; /*0x5dce*/
 }
 if ( (unsigned __int8)(n3 - 1) > 0xFDu ) /*0x5dd8*/
 return 0; /*0x5deb*/
 result = 2147483718LL; /*0x5ddd*/
 if ( n3 == 1 ) /*0x5de7*/
 return 2147483652LL; /*0x5de7*/
 return result; /*0x5dea*/
}

/*
 *LogStatusCode at 0x5df0
 */
__int64 LogStatusCode()
{
 __int64 result; // rax __int64 Status; // rax result = qword_79F8; /*0x5df4*/
 if ( !qword_79F8 ) /*0x5dfe*/
 {
 Status = (*(__int64 ( **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_73D0, 0, &qword_79F8); /*0x5e17*/
 if ( Status < 0 ) /*0x5e20*/
 {
 ConsolePrint(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0x5e31*/
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 78, (__int64)"!EFI_ERROR (Status)"); /*0x5e49*/
 }
 result = qword_79F8; /*0x5e4e*/
 if ( !qword_79F8 ) /*0x5e58*/
 {
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 79, (__int64)"mPcd != ((void *) 0)"); /*0x5e6b*/
 return qword_79F8; /*0x5e70*/
 }
 }
 return result; /*0x5e77*/
}

/*
 *LogStatusCodeSimple at 0x5e7c
 */
__int64 LogStatusCodeSimple(__int64 a1)
{
 if ( !a1 ) /*0x5e88*/
 VPrintWrapper((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, (__int64)"Buffer != ((void *) 0)"); /*0x5e9d*/
 return *(_QWORD *)a1; /*0x5ea5*/
}

/*
 *CopyConfiguredBuffer at 0x5eac
 */
char *CopyConfiguredBuffer(__int64 a1, char *src, unsigned __int64 count)
{
 unsigned __int64 Size; // rbp if ( !count ) /*0x5ec9*/
 return dst; /*0x5ecb*/
 Size = count - 1; /*0x5ee2*/
 if ( count - 1 > -1 - (__int64)dst ) /*0x5ee9*/
 VPrintWrapper( /*0x5efe*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
 56,
 (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)DestinationBuffer)");
 if ( Size > ~(unsigned __int64)src ) /*0x5f0c*/
 VPrintWrapper( /*0x5f21*/
 (__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
 57,
 (__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)SourceBuffer)");
 if ( dst == src ) /*0x5f29*/
 return dst; /*0x5f2b*/
 else return sub_350(dst, src, count); /*0x5f39*/
}

/*
 *ValidateMemoryBuffer at 0x5f54
 */
bool ValidateMemoryBuffer(__int64 a1, __int64 a2)
{
 __int64 Result; // rsi __int64 v5; // rbx __int64 v6; // rdi __int64 v7; // rax Result = LogStatusCodeSimple(a1); /*0x5f76*/
 v5 = LogStatusCodeSimple(a2); /*0x5f82*/
 v6 = LogStatusCodeSimple(a1 + 8); /*0x5f8e*/
 v7 = LogStatusCodeSimple(a2 + 8); /*0x5f91*/
 return Result == v5 && v6 == v7; /*0x5fb5*/
}

/*
 *InitializeSubSystem at 0x5fbc
 */
__int64 InitializeSubSystem()
{
 __int64 Result; // rax unsigned int n3_1; // ebx __int64 Buffer; // rax unsigned __int16 StringWidth; // ax int StringWidth_1; // edx int n335; // eax Result = (unsigned int)n3_0; /*0x5fc2*/
 n3_1 = 3; /*0x5fc8*/
 if ( n3_0 == 3 )
 {
 Buffer = IsBufferEmpty(); /*0x5fd1*/
 StringWidth = GetStringWidth((unsigned __int16 *)(Buffer + 2)); /*0x5fda*/
 StringWidth_1 = StringWidth; /*0x5fdf*/
 if ( ((StringWidth + 24128) & 0xFF70) != 0 )
 {
 if ( (unsigned __int16)(StringWidth + 25280) <= 8u && (n335 = 335, _bittest(&n335, StringWidth_1 + 25280)) )
 {
 n3_1 = 2; /*0x600a*/
 }
 else
 {
 ConsolePrint(0x80000000LL, "Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", (unsigned __int16)StringWidth_1);
 VPrintWrapper( /*0x6039*/
 (__int64)"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
 252,
 (__int64)"((BOOLEAN)(0==1))");
 }
 }
 else
 {
 n3_1 = 1; /*0x6040*/
 }
 n3_0 = n3_1; /*0x6045*/
 return n3_1; /*0x604b*/
 }
 return Result; /*0x604d*/
}

/*
 *ConvertHexToDecimal at 0x6060
 */
__int64 ConvertHexToDecimal(unsigned int _RAX, _DWORD *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5)
{
 __int64 result; // rax _RAX = _RAX; /*0x606f*/
 __asm { cpuid } /*0x6074*/
 if ( a2 ) /*0x6079*/
 *a2 = result; /*0x607b*/
 if ( a3 ) /*0x6081*/
 *a3 = _RBX; /*0x6083*/
 if ( a4 ) /*0x6089*/
 *a4 = _RCX; /*0x608b*/
 if ( a5 ) /*0x6091*/
 *a5 = _RDX; /*0x6093*/
 return result; /*0x6096*/
}

/*
 *FillMemoryPattern at 0x60a0
 */
int *FillMemoryPattern(int *buf, int value, unsigned __int64 n4)
{
 int *buf_1; // rdi int value_1; // eax unsigned __int64 n4_1; // rcx __int16 value_2; // bx int v7; // eax __int64 v8; // rdx char n4_2; // dl unsigned __int64 i; // rcx buf_1 = buf; /*0x60a3*/
 value_1 = value; /*0x60a6*/
 n4_1 = n4; /*0x60a9*/
 BYTE1(value_1) = value; /*0x60ba*/
 value_2 = value_1; /*0x60bc*/
 v7 = value_1 << 16; /*0x60bf*/
 LOWORD(v7) = value_2; /*0x60c3*/
 if ( n4 >= 4 ) /*0x60ca*/
 {
 v8 = (unsigned __int8)buf_1 & 3; /*0x60cf*/
 if ( ((unsigned __int8)buf_1 & 3) != 0 ) /*0x60d3*/
 {
 memset(buf_1, value_2, 4 - v8); /*0x60e2*/
 buf_1 = (int *)((char *)buf_1 + 4 - v8); /*0x60e2*/
 n4_1 = n4 - (4 - v8); /*0x60e4*/
 }
 n4_2 = n4_1; /*0x60e7*/
 for ( i = n4_1 >> 2; i; --i ) /*0x60ea*/
 *buf_1++ = v7; /*0x60ee*/
 n4_1 = n4_2 & 3; /*0x60f4*/
 }
 memset(buf_1, value_2, n4_1); /*0x60f7*/
 return buf; /*0x60fa*/
}

/*
 *CopyMemoryBlock at 0x6100
 */
char *CopyMemoryBlock(char *dst, char *src, unsigned __int64 n8)
{
 unsigned __int64 dst_1; // rdi unsigned __int64 n8_1; // rcx char v10; // dl char *n8_2; // rax unsigned __int64 count; // rax unsigned __int64 count_1; // rbx char n8_3; // al unsigned __int64 Ptr; // rcx unsigned __int64 n8_4; // rax __asm { pushf } /*0x6103*/
 dst_1 = (unsigned __int64)dst; /*0x6109*/
 n8_1 = n8; /*0x610c*/
 v10 = 0; /*0x610f*/
 n8_2 = &src[-dst_1]; /*0x6114*/
 if ( (unsigned __int64)src < dst_1 ) /*0x6117*/
 {
 n8_2 = (char *)(dst_1 - (_QWORD)src); /*0x611d*/
 if ( (unsigned __int64)&src[n8] >= dst_1 ) /*0x6123*/
 {
 src += n8; /*0x6125*/
 dst_1 += n8; /*0x6128*/
 v10 = 1; /*0x612c*/
 }
 }
 if ( n8 < 8 || (unsigned __int64)n8_2 < 8 ) /*0x6139*/
 goto LABEL_19; /*0x6139*/
 count = (unsigned __int8)src & 7; /*0x6141*/
 count_1 = dst_1 & 7; /*0x6145*/
 if ( v10 ) /*0x614b*/
 {
 --src; /*0x614d*/
 --dst_1; /*0x6150*/
 }
 if ( count == count_1 && count ) /*0x615b*/
 {
 if ( !v10 ) /*0x615f*/
 count = 8 - count; /*0x6164*/
 qmemcpy((void *)dst_1, src, count); /*0x616d*/
 src += count; /*0x616d*/
 dst_1 += count; /*0x616d*/
 n8_1 = n8 - count; /*0x616f*/
 }
 if ( v10 ) /*0x6174*/
 {
 src -= 7; /*0x6176*/
 dst_1 -= 7LL; /*0x617a*/
 }
 n8_3 = n8_1; /*0x617e*/
 Ptr = n8_1 >> 3; /*0x6181*/
 qmemcpy((void *)dst_1, src, 8 *Ptr); /*0x6185*/
 src += 8 *Ptr; /*0x6185*/
 dst_1 += 8 *Ptr; /*0x6185*/
 n8_4 = n8_3 & 7; /*0x6188*/
 if ( n8_4 ) /*0x618c*/
 {
 if ( v10 ) /*0x6190*/
 {
 src += 8; /*0x6192*/
 dst_1 += 8LL; /*0x6196*/
 }
 n8_1 = n8_4; /*0x619a*/
LABEL_19:
 if ( v10 ) /*0x619f*/
 {
 --src; /*0x61a1*/
 --dst_1; /*0x61a4*/
 }
 qmemcpy((void *)dst_1, src, n8_1); /*0x61a7*/
 }
 __asm { popf } /*0x61a9*/
 return dst; /*0x61ac*/
}