Newer
Older
AMI-Aptio-BIOS-Reversed / MdePkg / Library / PeiHobLib / CpuPei / CpuPei.c
/*
 *CpuPei - Decompiled CpuPei
 *Source: Auto-generated from IDA Pro decompilation
 *
 *Decompiled from port 13405
 */

#include "CpuPei.h"

/*
 *InternalCopyMem at 0xffc1a6d4
 */
char *InternalCopyMem(char *dst, char *src, unsigned int count)
{
 unsigned int count_1; // edx char *dst_1; // edi char *src_1; // esi count_1 = count; /*0xffc1a6de*/
 if ( src < dst && &src[count - 1] >= dst ) /*0xffc1a6ec*/
 {
 src_1 = &src[count - 1]; /*0xffc1a700*/
 dst_1 = &dst[count - 1]; /*0xffc1a702*/
 }
 else
 {
 count_1 = count & 3; /*0xffc1a6f0*/
 qmemcpy(dst, src, 4 * (count >> 2)); /*0xffc1a6f9*/
 src_1 = &src[4 * (count >> 2)]; /*0xffc1a6f9*/
 dst_1 = &dst[4 * (count >> 2)]; /*0xffc1a6f9*/
 }
 qmemcpy(dst_1, src_1, count_1); /*0xffc1a709*/
 return dst; /*0xffc1a710*/
}

/*
 *InternalZeroMem at 0xffc1a714
 */
void *InternalZeroMem(void *buf, unsigned int count)
{
 memset(buf, 0, count); /*0xffc1a72b*/
 return buf; /*0xffc1a732*/
}

/*
 *SetMem at 0xffc1a734
 */
void *SetMem(void *buf, unsigned int count, char value)
{
 memset(buf, value, count); /*0xffc1a741*/
 return buf; /*0xffc1a747*/
}

/*
 *InternalSetMem32 at 0xffc1a754
 */
int InternalSetMem32(int a1, int a2, int a3, int a4)
{
 do /*0xffc1a76d*/
 {
 *(_DWORD *)(a1 + 8 *a2 - 8) = a3; /*0xffc1a765*/
 *(_DWORD *)(a1 + 8 *a2-- - 4) = a4; /*0xffc1a769*/
 }
 while ( a2 ); /*0xffc1a76d*/
 return a1; /*0xffc1a771*/
}

/*
 *SetMem32 at 0xffc1a774
 */
void *SetMem32(void *buf, unsigned int count, int value)
{
 memset32(buf, value, count); /*0xffc1a781*/
 return buf; /*0xffc1a787*/
}

/*
 *CpuPeiModuleEntryPoint at 0xffc1a789
 */
// Main entry point for CpuPei module EFI_STATUS CpuPeiModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
 int ImageHandleBase; // edi int Cmos; // eax int DebugLib; // eax int Services; // eax int Status1; // eax int DebugLib1; // eax int Services1; // eax int Status2; // eax int CpuidInput; // ecx int DebugLib2; // eax unsigned __int32 Cr0Value; // eax unsigned __int32 Cr4Value; // eax int CpuidInput_1; // [esp-14h] [ebp-14h]
 EFI_STATUS Status2_1; // [esp-10h] [ebp-10h]
 int CpuidEax; // [esp-8h] [ebp-8h] BYREF Cmos = CpuPeiReadCmos(SystemTable); /*0xffc1a818*/
 if ( Cmos < 0 ) /*0xffc1a82e*/
 {
 DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", Cmos); /*0xffc1a837*/
 DebugLib = DebugGetDebugLib(); /*0xffc1a83f*/
 if ( DebugLib ) /*0xffc1a846*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1a84f*/
 "e:\\hs\\PurleySktPkg\\Override\\IA32FamilyCpuPkg\\CpuPei\\CpuPeim.c",
 189,
 "!EFI_ERROR (Status)");
 }
 Services = PeiGetServices(); /*0xffc1a855*/
 Status1 = (*(int (__stdcall **)(int, void *, int))(*(_DWORD *)Services + 24))( /*0xffc1a862*/
 Services,
 &unk_FFC1E258,
 ImageHandleBase);
 if ( Status1 < 0 ) /*0xffc1a869*/
 {
 DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", Status1); /*0xffc1a872*/
 DebugLib1 = DebugGetDebugLib(); /*0xffc1a87a*/
 if ( DebugLib1 ) /*0xffc1a881*/
 (*(void ( **)(const char *, int, const char *))(DebugLib1 + 4))( /*0xffc1a88a*/
 "e:\\hs\\PurleySktPkg\\Override\\IA32FamilyCpuPkg\\CpuPei\\CpuPeim.c",
 195,
 "!EFI_ERROR (Status)");
 }
 Services1 = PeiGetServices(); /*0xffc1a890*/
 Status2 = (*(int ( **)(int, void *))(*(_DWORD *)Services1 + 36))(Services1, &unk_FFC1E234); /*0xffc1a89d*/
 Status2_1 = Status2; /*0xffc1a8a0*/
 CpuidInput = CpuidInput_1; /*0xffc1a8a4*/
 if ( Status2 < 0 ) /*0xffc1a8a7*/
 {
 DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", Status2); /*0xffc1a8b0*/
 DebugLib2 = DebugGetDebugLib(); /*0xffc1a8b8*/
 if ( DebugLib2 ) /*0xffc1a8bf*/
 (*(void ( **)(const char *, int, const char *))(DebugLib2 + 4))( /*0xffc1a8c8*/
 "e:\\hs\\PurleySktPkg\\Override\\IA32FamilyCpuPkg\\CpuPei\\CpuPeim.c",
 201,
 "!EFI_ERROR (Status)");
 }
 AsmCpuid(1, 0, CpuidInput, CpuidInput, &CpuidEax); /*0xffc1a8d9*/
 if ( (CpuidEax & 0x4000000) != 0 ) /*0xffc1a8e8*/
 {
 Cr0Value = __readcr0(); /*0xffc1a8ea*/
 __writecr0(Cr0Value | 2); /*0xffc1a8f6*/
 Cr4Value = __readcr4(); /*0xffc1a8f9*/
 __writecr4(Cr4Value | 0x600); /*0xffc1a907*/
 }
 return Status2_1; /*0xffc1a913*/
}

/*
 *CpuPeiGetConfigData at 0xffc1a96f
 */
int CpuPeiGetConfigData(int a1, unsigned int *a2, char *dst)
{
 int FirstGuidHob; // eax int FirstGuidHob_1; // edx unsigned int count; // eax FirstGuidHob = GetFirstGuidHob(&unk_FFC1E224); /*0xffc1a91f*/
 FirstGuidHob_1 = FirstGuidHob; /*0xffc1a924*/
 if ( FirstGuidHob ) /*0xffc1a928*/
 {
 count = (unsigned __int16)(*(_WORD *)(FirstGuidHob + 2) - 24); /*0xffc1a93b*/
 if ( *(_QWORD *)a2 < (unsigned __int64)count ) /*0xffc1a947*/
 {
 *a2 = count; /*0xffc1a949*/
 a2[1] = 0; /*0xffc1a950*/
 return -2147483643; /*0xffc1a953*/
 }
 *a2 = count; /*0xffc1a955*/
 a2[1] = 0; /*0xffc1a957*/
 if ( count ) /*0xffc1a95c*/
 CopyMem(dst, (char *)(FirstGuidHob_1 + 24), count); /*0xffc1a964*/
 }
 else
 {
 *a2 = 0; /*0xffc1a92a*/
 a2[1] = 0; /*0xffc1a92c*/
 }
 return 0; /*0xffc1a96e*/
}

/*
 *CpuPeiGetBistData at 0xffc1a97c
 */
int CpuPeiGetBistData(int this, int a2, int a3, _DWORD *p_count, _DWORD *p_src)
{
 int Services; // eax int Status; // eax int DataSize; // esi int Services2; // eax int SectionInstance; // [esp+10h] [ebp-10h] BYREF int ( **v13)(int, int *, int); // [esp+14h] [ebp-Ch] BYREF int DataSize_1; // [esp+18h] [ebp-8h] BYREF int BufferPtr; // [esp+1Ch] [ebp-4h]

 Services = PeiGetServices(); /*0xffc1a987*/
 Status = (*(int ( **)(int, int, _DWORD, int, int ( ***)(int, int *, int)))(*(_DWORD *)Services + 32))( /*0xffc1a99c*/
 Services,
 a2,
 0,
 a3,
 &v13);
 if ( Status == -2147483634 ) /*0xffc1a9a9*/
 return -2147483634; /*0xffc1a9ab*/
 if ( Status ) /*0xffc1a9b1*/
 return -2147483641; /*0xffc1a9b1*/
 DataSize_1 = 0; /*0xffc1a9b8*/
 BufferPtr = 0; /*0xffc1a9c2*/
 SectionInstance = 0; /*0xffc1a9c6*/
 if ( (*v13)(this, &DataSize_1, 0) != -2147483643 ) /*0xffc1a9d4*/
 return -2147483641; /*0xffc1a9d4*/
 DataSize = DataSize_1; /*0xffc1a9d6*/
 Services2 = PeiGetServices(); /*0xffc1a9da*/
 if ( (*(int ( **)(int, int, int *))(*(_DWORD *)Services2 + 76))(Services2, DataSize, &SectionInstance) /*0xffc1aa00*/
 || (*v13)(this, &DataSize_1, SectionInstance) )
 {
 return -2147483641; /*0xffc1aa28*/
 }
 *p_count = DataSize_1; /*0xffc1aa11*/
 p_count[1] = BufferPtr; /*0xffc1aa17*/
 *p_src = SectionInstance; /*0xffc1aa22*/
 return 0; /*0xffc1aa2d*/
}

/*
 *CpuPeiReadCmos at 0xffc1aa35
 */
int __thiscall CpuPeiReadCmos(void *this)
{
 int result; // eax int Result; // esi int Services; // eax int v5; // esi int v6; // eax unsigned int count[2]; // [esp+10h] [ebp-10h] BYREF int Size; // [esp+18h] [ebp-8h] BYREF char *src; // [esp+1Ch] [ebp-4h] BYREF result = CpuPeiGetBistData((int)this, (int)&unk_FFC1E104, (int)&Size, count, &src); /*0xffc1aa51*/
 if ( !result ) /*0xffc1aa60*/
 {
 BuildGuidDataHob((int)byte_FFC1E224, src, count[0]); /*0xffc1aa6a*/
 Result = Size; /*0xffc1aa6f*/
 Services = PeiGetServices(); /*0xffc1aa72*/
 result = (*(int ( **)(int, int, void *))(*(_DWORD *)Services + 28))(Services, Result, &unk_FFC1E264); /*0xffc1aa82*/
 }
 if ( result == -2147483634 ) /*0xffc1aa8f*/
 {
 result = CpuPeiGetBistData((int)this, (int)&unk_FFC1E154, (int)&Size, count, &src); /*0xffc1aaa4*/
 if ( result ) /*0xffc1aaae*/
 {
 if ( result == -2147483634 ) /*0xffc1aada*/
 return 0; /*0xffc1aadc*/
 }
 else
 {
 BuildGuidDataHob((int)byte_FFC1E224, src, count[0]); /*0xffc1aab8*/
 v5 = Size; /*0xffc1aabd*/
 v6 = PeiGetServices(); /*0xffc1aac0*/
 return (*(int ( **)(int, int, void *))(*(_DWORD *)v6 + 28))(v6, v5, &unk_FFC1E278); /*0xffc1aad0*/
 }
 }
 return result; /*0xffc1aade*/
}

/*
 *CpuPeiBistEntry at 0xffc1aae5
 */
int CpuPeiBistEntry(int a1)
{
 int Services; // eax int Status; // eax int ErrorLevel; // eax int BistData; // esi _WORD *FirstGuidHob; // esi int DebugLib; // eax char *src_1; // edi unsigned int count_1; // esi int CpuidEax; // ecx char Table; // bl int HobPointer; // eax unsigned int n46_1; // [esp+Ch] [ebp-14h] BYREF int Status; // [esp+10h] [ebp-10h] BYREF char *src; // [esp+14h] [ebp-Ch] BYREF unsigned int count; // [esp+18h] [ebp-8h] BYREF Services = PeiGetServices(); /*0xffc1aaf1*/
 Status = (*(int ( **)(int, int *))(*(_DWORD *)Services + 40))(Services, &Status); /*0xffc1aafe*/
 if ( Status < 0 ) /*0xffc1ab0a*/
 {
 DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffc1ab17*/
 ErrorLevel = DebugGetDebugLib(); /*0xffc1ab1f*/
 if ( ErrorLevel ) /*0xffc1ab26*/
 (*(void ( **)(const char *, int, const char *))(ErrorLevel + 4))( /*0xffc1ab33*/
 "e:\\hs\\PurleySktPkg\\Override\\IA32FamilyCpuPkg\\CpuPei\\Bist.c",
 320,
 "!EFI_ERROR (Status)");
 }
 if ( Status != 17 ) /*0xffc1ab3e*/
 {
 BistData = CpuPeiGetBistData(a1, (int)&unk_FFC1E104, 0, &count, &src); /*0xffc1ab5e*/
 if ( !BistData ) /*0xffc1ab65*/
 BuildGuidDataHob((int)&unk_FFC1E104, src, count); /*0xffc1ab74*/
 if ( BistData == -2147483634 ) /*0xffc1ab80*/
 {
 FirstGuidHob = GetFirstGuidHob(byte_FFC1E224); /*0xffc1ab8c*/
 if ( !FirstGuidHob ) /*0xffc1ab90*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1ab92*/
 if ( DebugLib ) /*0xffc1ab99*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1aba6*/
 "e:\\hs\\PurleySktPkg\\Override\\IA32FamilyCpuPkg\\CpuPei\\Bist.c",
 340,
 "GuidHob != ((void *) 0)");
 }
 src_1 = (char *)(FirstGuidHob + 12); /*0xffc1abb0*/
 count_1 = (unsigned __int16)(FirstGuidHob[1] - 24); /*0xffc1abc0*/
 BuildGuidDataHob((int)&unk_FFC1E1B4, src_1, count_1); /*0xffc1abc5*/
 BuildGuidDataHob((int)&unk_FFC1E154, src_1, count_1); /*0xffc1abd3*/
 }
 CpuPeiBuildSecHob(); /*0xffc1abdc*/
 CpuPeiBuildCpuHob(); /*0xffc1abe1*/
 AsmCpuid(0x80000000, &n46_1, CpuidEax, CpuidEax, 0); /*0xffc1abf5*/
 if ( n46_1 < 0x80000008 ) /*0xffc1ac06*/
 {
 Table = 46; /*0xffc1ac1d*/
 }
 else
 {
 AsmCpuid(-2147483640, &n46_1, -2147483640, -2147483640, 0); /*0xffc1ac0f*/
 Table = n46_1; /*0xffc1ac14*/
 }
 HobPointer = HobConstructor(6, 16); /*0xffc1ac25*/
 if ( HobPointer ) /*0xffc1ac2c*/
 {
 *(_BYTE *)(HobPointer + 8) = Table; /*0xffc1ac33*/
 *(_BYTE *)(HobPointer + 9) = 16; /*0xffc1ac37*/
 ZeroMem(HobPointer + 10, 6u); /*0xffc1ac3b*/
 }
 }
 return 0; /*0xffc1ac40*/
}

/*
 *MtrrSetMemoryAttribute at 0xffc1ac49
 */
int MtrrSetMemoryAttribute(int a1, int a2, unsigned __int64 n0x100000, unsigned __int64 a4, int a5)
{
 double ErrorLevel; // [esp-14h] [ebp-1Ch]

 HIDWORD(ErrorLevel) = n0x100000; /*0xffc1ac5d*/
 LODWORD(ErrorLevel) = off_FFC1DAC4[a5]; // "UC" /*0xffc1ac60*/
 DebugPrint(0x200000, "MtrrSetMemoryAttribute() %a:%016lx-%016lx\n", ErrorLevel, HIDWORD(n0x100000), (_DWORD)a4); /*0xffc1ac71*/
 return MtrrSetMemoryAttributeWorker(a5, n0x100000, a4); /*0xffc1ac8f*/
}

/*
 *CpuPeiS3Restore at 0xffc1ac94
 */
int CpuPeiS3Restore()
{
 void *v0; // ecx unsigned __int64 v2; // [esp+0h] [ebp-270h]
 _BYTE v3[8]; // [esp+8h] [ebp-268h] BYREF unsigned __int64 v4[11]; // [esp+10h] [ebp-260h] BYREF unsigned __int64 v5[64]; // [esp+68h] [ebp-208h] BYREF unsigned __int64 v6; // [esp+268h] [ebp-8h]

 ZeroMem((int)v4, 0x260u); /*0xffc1aca9*/
 if ( MtrrIsMtrrSupported(v0) ) /*0xffc1acae*/
 {
 MtrrDisableCache(v3); /*0xffc1acbb*/
 MtrrS3RestoreMsrs(v4); /*0xffc1acc4*/
 MtrrS3RestoreVariables(v5); /*0xffc1accd*/
 v2 = v6; /*0xffc1acd9*/
 __writemsr(0x2FFu, v6); /*0xffc1acf3*/
 MtrrEnableCache((int)v3); /*0xffc1acf9*/
 MtrrWriteDefaultMemoryTypeMsr(v2, HIDWORD(v2)); /*0xffc1acfe*/
 }
 return 0; /*0xffc1ad05*/
}

/*
 *MtrrWriteDefaultMemoryTypeMsr at 0xffc1acfe
 */
void MtrrWriteDefaultMemoryTypeMsr(unsigned int MsrValueLow, unsigned int MsrValueHigh)
{
 __writemsr(0x2FFu, ((unsigned __int64)MsrValueHigh << 32) | MsrValueLow); /*0xffc1acfe*/
}

/*
 *DebugGetDebugLib at 0xffc1ad09
 */
int DebugGetDebugLib()
{
 int Services; // eax int v2; // [esp+0h] [ebp-8h] BYREF int Result; // [esp+4h] [ebp-4h] BYREF Services = PeiGetServices(); /*0xffc1ad0e*/
 if ( (*(int ( **)(int, void *, _DWORD, int *, int *))(*(_DWORD *)Services + 32))( /*0xffc1ad2d*/
 Services,
 &unk_FFC1E124,
 0,
 &v2,
 &Result) >= 0 )
 return Result; /*0xffc1ad33*/
 else return 0; /*0xffc1ad2f*/
}

/*
 *DebugPrint at 0xffc1ad3a
 */
int DebugPrint(int a1, const char *a2, ...)
{
 int result; // eax int ( **v3)(int, const char *, char *); // esi va_list va; // [esp+10h] [ebp+Ch] BYREF va_start(va, a2);
 result = DebugGetDebugLib(); /*0xffc1ad3b*/
 v3 = (int ( **)(int, const char *, char *))result; /*0xffc1ad40*/
 if ( result ) /*0xffc1ad44*/
 {
 result = CmosDebugPortCheck(); /*0xffc1ad46*/
 if ( (result & a1) != 0 ) /*0xffc1ad51*/
 return (*v3)(a1, a2, (char *)va); /*0xffc1ad5d*/
 }
 return result; /*0xffc1ad62*/
}

/*
 *DebugAssert at 0xffc1ad64
 */
int DebugAssert(int a1, int n48, const char *Idtr____((void__)_0))
{
 int result; // eax result = DebugGetDebugLib(); /*0xffc1ad6a*/
 if ( result ) /*0xffc1ad71*/
 return (*(int ( **)(int, int, const char *))(result + 4))(a1, n48, Idtr____((void__)_0)); /*0xffc1ad79*/
 return result; /*0xffc1ad7f*/
}

/*
 *AsmCpuid at 0xffc1ad82
 */
int AsmCpuid(int _EAX, _DWORD *a2, int a3, int a4, _DWORD *a5)
{
 _EAX = _EAX; /*0xffc1ad97*/
 __asm { cpuid } /*0xffc1ad9a*/
 if ( a2 ) /*0xffc1ada0*/
 *a2 = _EAX; /*0xffc1ada2*/
 if ( a5 ) /*0xffc1adb6*/
 *a5 = _EDX; /*0xffc1adb8*/
 return _EAX; /*0xffc1adbd*/
}

/*
 *CopyMem at 0xffc1adc2
 */
char *CopyMem(char *dst, char *src, unsigned int count)
{
 int DebugLib; // eax int ErrorLevel; // eax if ( count - 1 > -1 - (int)dst ) /*0xffc1add8*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1adda*/
 if ( DebugLib ) /*0xffc1ade1*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1adef*/
 "e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
 56,
 "(Length - 1) <= (0xFFFFFFFF - (UINTN)DestinationBuffer)");
 }
 if ( count - 1 > -1 - (int)src ) /*0xffc1adf9*/
 {
 ErrorLevel = DebugGetDebugLib(); /*0xffc1adfb*/
 if ( ErrorLevel ) /*0xffc1ae02*/
 (*(void ( **)(const char *, int, const char *))(ErrorLevel + 4))( /*0xffc1ae10*/
 "e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
 57,
 "(Length - 1) <= (0xFFFFFFFF - (UINTN)SourceBuffer)");
 }
 if ( dst == src ) /*0xffc1ae18*/
 return dst; /*0xffc1ae1a*/
 else return InternalCopyMem(dst, src, count); /*0xffc1ae24*/
}

/*
 *ZeroMem at 0xffc1ae31
 */
void *ZeroMem(int buf, unsigned int count)
{
 int DebugLib; // eax int ErrorLevel; // eax if ( !buf ) /*0xffc1ae3f*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1ae41*/
 if ( DebugLib ) /*0xffc1ae48*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1ae52*/
 "e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
 53,
 "Buffer != ((void *) 0)");
 }
 if ( count > -buf ) /*0xffc1ae5e*/
 {
 ErrorLevel = DebugGetDebugLib(); /*0xffc1ae60*/
 if ( ErrorLevel ) /*0xffc1ae67*/
 (*(void ( **)(const char *, int, const char *))(ErrorLevel + 4))( /*0xffc1ae71*/
 "e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\ZeroMemWrapper.c",
 54,
 "Length <= (0xFFFFFFFF - (UINTN)Buffer + 1)");
 }
 return InternalZeroMem((void *)buf, count); /*0xffc1ae80*/
}

/*
 *CopyGuid at 0xffc1ae84
 */
int CopyGuid(int a1, int a2)
{
 __int64 Unaligned64; // rax __int64 Unaligned64_1; // rax Unaligned64 = ReadUnaligned64((void *)a2); /*0xffc1ae8c*/
 WriteUnaligned64(Unaligned64, SHIDWORD(Unaligned64)); /*0xffc1ae95*/
 Unaligned64_1 = ReadUnaligned64((void *)(a2 + 8)); /*0xffc1ae9d*/
 WriteUnaligned64(Unaligned64_1, SHIDWORD(Unaligned64_1)); /*0xffc1aea7*/
 return a1; /*0xffc1aeb1*/
}

/*
 *CompareGuid at 0xffc1aeb4
 */
bool CompareGuid(char *this, int a2)
{
 __int64 Unaligned64; // rax int Unaligned64_1; // ebp __int64 Unaligned64_3; // rax int Unaligned64_2; // edi __int64 v8; // kr00_8 __int64 v9; // rax int v11; // [esp+10h] [ebp-Ch]
 int v12; // [esp+14h] [ebp-8h]

 Unaligned64 = ReadUnaligned64(this); /*0xffc1aebf*/
 v12 = HIDWORD(Unaligned64); /*0xffc1aec6*/
 Unaligned64_1 = Unaligned64; /*0xffc1aeca*/
 Unaligned64_3 = ReadUnaligned64((void *)a2); /*0xffc1aecc*/
 v11 = HIDWORD(Unaligned64_3); /*0xffc1aed4*/
 Unaligned64_2 = Unaligned64_3; /*0xffc1aed8*/
 v8 = ReadUnaligned64(this + 8); /*0xffc1aee6*/
 v9 = ReadUnaligned64((void *)(a2 + 8)); /*0xffc1aee8*/
 return Unaligned64_1 == Unaligned64_2 && v12 == v11 && v8 == v9; /*0xffc1af0b*/
}

/*
 *GetHobList at 0xffc1af13
 */
int GetHobList()
{
 int Services; // eax int Status; // eax int DebugLib; // eax int ErrorLevel; // eax int Result; // [esp+4h] [ebp-4h] BYREF Services = PeiGetServices(); /*0xffc1af18*/
 Status = (*(int ( **)(int, int *))(*(_DWORD *)Services + 48))(Services, &Result); /*0xffc1af24*/
 if ( Status < 0 ) /*0xffc1af30*/
 {
 DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffc1af3d*/
 DebugLib = DebugGetDebugLib(); /*0xffc1af45*/
 if ( DebugLib ) /*0xffc1af4c*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1af56*/
 "e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
 50,
 "!EFI_ERROR (Status)");
 }
 if ( !Result ) /*0xffc1af60*/
 {
 ErrorLevel = DebugGetDebugLib(); /*0xffc1af62*/
 if ( ErrorLevel ) /*0xffc1af69*/
 (*(void ( **)(const char *, int, const char *))(ErrorLevel + 4))( /*0xffc1af73*/
 "e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
 51,
 "HobList != ((void *) 0)");
 }
 return Result; /*0xffc1af7c*/
}

/*
 *GetNextHob at 0xffc1af81
 */
_WORD *GetNextHob(int a1, _WORD *i)
{
 _WORD *i_1; // esi int DebugLib; // eax i_1 = i; /*0xffc1af82*/
 if ( !i ) /*0xffc1af86*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1af88*/
 if ( DebugLib ) /*0xffc1af8f*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1af9d*/
 "e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
 82,
 "HobStart != ((void *) 0)");
 }
 while ( 1 ) /*0xffc1afb6*/
 {
 if ( *i_1 == 0xFFFF ) /*0xffc1afbc*/
 return 0; /*0xffc1afc1*/
 if ( *i_1 == 4 ) /*0xffc1afae*/
 break; /*0xffc1afae*/
 i_1 = (_WORD *)((char *)i_1 + (unsigned __int16)i_1[1]); /*0xffc1afb4*/
 }
 return i_1; /*0xffc1afc0*/
}

/*
 *GetFirstGuidHob at 0xffc1afc6
 */
_WORD *__thiscall GetFirstGuidHob(char *this)
{
 _WORD *i; // edx int v3; // ecx _WORD *NextHob; // eax _WORD *NextHob_1; // esi for ( i = (_WORD *)GetHobList(); ; i = (_WORD *)((char *)NextHob_1 + (unsigned __int16)NextHob_1[1]) ) /*0xffc1afd5*/
 {
 NextHob = GetNextHob(v3, i); /*0xffc1afed*/
 NextHob_1 = NextHob; /*0xffc1aff2*/
 if ( !NextHob || CompareGuid(this, (int)(NextHob + 4)) ) /*0xffc1afde*/
 break; /*0xffc1afde*/
 }
 return NextHob_1; /*0xffc1aff8*/
}

/*
 *HobConstructor at 0xffc1b000
 */
int HobConstructor(int n6, int n16)
{
 int Services; // eax int DebugLib; // eax int Result; // [esp+Ch] [ebp-4h] BYREF Services = PeiGetServices(); /*0xffc1b00b*/
 if ( (*(int ( **)(int, int, int, int *))(*(_DWORD *)Services + 52))(Services, n6, n16, &Result) < 0 ) /*0xffc1b024*/
 Result = 0; /*0xffc1b026*/
 if ( !Result ) /*0xffc1b02e*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1b030*/
 if ( DebugLib ) /*0xffc1b037*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1b048*/
 "e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
 250,
 "Hob != ((void *) 0)");
 }
 return Result; /*0xffc1b01f*/
}

/*
 *CpuPeiBuildSecHob at 0xffc1b055
 */
_DWORD *CpuPeiBuildSecHob()
{
 _DWORD *result; // eax result = (_DWORD *)HobConstructor(3, 48); /*0xffc1b05b*/
 if ( result ) /*0xffc1b062*/
 {
 result[9] = 0; /*0xffc1b064*/
 result[11] = 0; /*0xffc1b06b*/
 result[6] = 1; /*0xffc1b071*/
 result[7] = 1027; /*0xffc1b078*/
 result[8] = -20447232; /*0xffc1b07f*/
 result[10] = 0x80000; /*0xffc1b086*/
 return ZeroMem((int)(result + 2), 0x10u); /*0xffc1b08e*/
 }
 return result; /*0xffc1b093*/
}

/*
 *BuildGuidHob at 0xffc1b094
 */
int BuildGuidHob(int a1, unsigned int count)
{
 int DebugLib; // eax int ErrorLevel; // eax int result; // eax int Result; // esi if ( !a1 ) /*0xffc1b0a2*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1b0a4*/
 if ( DebugLib ) /*0xffc1b0ab*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1b0b8*/
 "e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
 416,
 "Guid != ((void *) 0)");
 }
 if ( count > 0xFFE0 ) /*0xffc1b0c4*/
 {
 ErrorLevel = DebugGetDebugLib(); /*0xffc1b0c6*/
 if ( ErrorLevel ) /*0xffc1b0cd*/
 (*(void ( **)(const char *, int, const char *))(ErrorLevel + 4))( /*0xffc1b0da*/
 "e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
 421,
 "DataLength <= (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE))");
 }
 result = HobConstructor(4, count + 24); /*0xffc1b0e6*/
 Result = result; /*0xffc1b0eb*/
 if ( result ) /*0xffc1b0ef*/
 {
 CopyGuid(result + 8, a1); /*0xffc1b0f6*/
 return Result + 24; /*0xffc1b0fb*/
 }
 return result; /*0xffc1b0fe*/
}

/*
 *BuildGuidDataHob at 0xffc1b102
 */
char *BuildGuidDataHob(int a1, char *src, unsigned int count)
{
 int DebugLib; // eax char *dst; // eax if ( !src ) /*0xffc1b10f*/
 {
 if ( count ) /*0xffc1b113*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1b115*/
 if ( DebugLib ) /*0xffc1b11c*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1b12d*/
 "e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
 466,
 "Data != ((void *) 0) || DataLength == 0");
 }
 }
 dst = (char *)BuildGuidHob(a1, count); /*0xffc1b137*/
 if ( dst ) /*0xffc1b13e*/
 {
 if ( count ) /*0xffc1b142*/
 return CopyMem(dst, src, count); /*0xffc1b149*/
 }
 return dst; /*0xffc1b14f*/
}

/*
 *CpuPeiBuildCpuHob at 0xffc1b153
 */
_DWORD *CpuPeiBuildCpuHob()
{
 _DWORD *result; // eax _DWORD *v1; // esi result = (_DWORD *)HobConstructor(2, 48); /*0xffc1b15a*/
 v1 = result; /*0xffc1b15f*/
 if ( result ) /*0xffc1b163*/
 {
 ZeroMem((int)(result + 2), 0x10u); /*0xffc1b16b*/
 v1[7] = 0; /*0xffc1b170*/
 v1[9] = 0; /*0xffc1b177*/
 v1[6] = -20447232; /*0xffc1b17e*/
 v1[8] = 0x80000; /*0xffc1b185*/
 v1[10] = 11; /*0xffc1b18c*/
 return ZeroMem((int)(v1 + 11), 4u); /*0xffc1b194*/
 }
 return result; /*0xffc1b193*/
}

/*
 *MtrrGetVariableCount at 0xffc1b19b
 */
int MtrrGetVariableCount()
{
 unsigned __int64 n0x20; // rax int n0x20_1; // esi int DebugLib; // eax n0x20 = __readmsr(0xFEu); /*0xffc1b1a3*/
 n0x20_1 = (unsigned __int8)n0x20; /*0xffc1b1a5*/
 if ( (unsigned __int8)n0x20 > 0x20u ) /*0xffc1b1ab*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1b1ad*/
 if ( DebugLib ) /*0xffc1b1b4*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1b1c2*/
 "e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MtrrLib\\MtrrLib.c",
 126,
 "VariableMtrrCount <= 32");
 }
 return n0x20_1; /*0xffc1b1ca*/
}

/*
 *MtrrGetAvailableCount at 0xffc1b1ce
 */
unsigned int MtrrGetAvailableCount()
{
 unsigned int Result; // eax Result = MtrrGetVariableCount(); /*0xffc1b1ce*/
 if ( Result >= dword_FFC1E318 ) /*0xffc1b1db*/
 return Result - dword_FFC1E318; /*0xffc1b1e0*/
 else return 0; /*0xffc1b1dd*/
}

/*
 *MtrrDisableCache at 0xffc1b1e3
 */
unsigned __int64 __thiscall MtrrDisableCache(_BYTE *this)
{
 __int16 v1; // kr00_2 unsigned __int32 v2; // eax unsigned __int32 v3; // eax _BYTE *this_1; // ecx unsigned __int32 v5; // eax v1 = __readeflags(); /*0xffc1b1ed*/
 _disable(); /*0xffc1b1ef*/
 *(this + 4) = (v1 & 0x200) != 0; /*0xffc1b1f5*/
 v2 = __readcr0(); /*0xffc1b1f8*/
 __writecr0(v2 & 0x9FFFFFFF | 0x40000000); /*0xffc1b203*/
 __wbinvd(); /*0xffc1b206*/
 v3 = __readcr4(); /*0xffc1b208*/
 this_1 = this; /*0xffc1b20b*/
 *(_DWORD *)this = v3; /*0xffc1b20e*/
 __writecr4(v3 & 0xFFFFFF7F); /*0xffc1b21b*/
 v5 = __readcr3(); /*0xffc1b21e*/
 __writecr3(v5); /*0xffc1b221*/
 return MtrrWriteMsrWithFilter(this_1, 0, 0); /*0xffc1b231*/
}

/*
 *MtrrEnableCache at 0xffc1b238
 */
int __thiscall MtrrEnableCache(int this)
{
 unsigned __int32 v1; // eax unsigned __int32 v2; // eax int this_1; // eax v1 = __readcr3(); /*0xffc1b243*/
 __writecr3(v1); /*0xffc1b246*/
 __wbinvd(); /*0xffc1b249*/
 v2 = __readcr0(); /*0xffc1b24b*/
 __writecr0(v2 & 0x9FFFFFFF); /*0xffc1b256*/
 __writecr4(*(_DWORD *)this); /*0xffc1b261*/
 this_1 = this; /*0xffc1b264*/
 if ( *(_BYTE *)(this + 4) ) /*0xffc1b267*/
 _enable(); /*0xffc1b26d*/
 else _disable(); /*0xffc1b270*/
 return this_1; /*0xffc1b271*/
}

/*
 *MtrrReadFixedMsrs at 0xffc1b278
 */
_QWORD *__thiscall MtrrReadFixedMsrs(_QWORD *this)
{
 unsigned int Index; // ebx _QWORD *this_1; // edi unsigned __int64 v3; // rax Index = 0; /*0xffc1b27d*/
 this_1 = this; /*0xffc1b280*/
 do /*0xffc1b2a3*/
 {
 v3 = __readmsr(dword_FFC1DA34[Index]); /*0xffc1b290*/
 Index += 3; /*0xffc1b292*/
 *this_1++ = v3; /*0xffc1b295*/
 }
 while ( Index < 33 ); /*0xffc1b2a3*/
 return this; /*0xffc1b2a5*/
}

/*
 *MtrrReadAllMsrs at 0xffc1b2ac
 */
_DWORD *MtrrReadAllMsrs(int this, unsigned int n0x20, _DWORD *src)
{
 unsigned int n0x20_1; // ebx int this_1; // eax int DebugLib; // eax _DWORD *src_1; // esi unsigned int n513; // ebp _DWORD *v8; // edi n0x20_1 = n0x20; /*0xffc1b2af*/
 this_1 = this; /*0xffc1b2b1*/
 if ( n0x20 > 0x20 ) /*0xffc1b2ba*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1b2bc*/
 if ( DebugLib ) /*0xffc1b2c3*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1b2d4*/
 "e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MtrrLib\\MtrrLib.c",
 399,
 "VariableMtrrCount <= 32");
 this_1 = this; /*0xffc1b2da*/
 }
 if ( n0x20_1 ) /*0xffc1b2e0*/
 {
 src_1 = src; /*0xffc1b2e4*/
 n513 = 513; /*0xffc1b2e8*/
 v8 = (_DWORD *)(this_1 + 96); /*0xffc1b2ee*/
 do /*0xffc1b33f*/
 {
 if ( this_1 ) /*0xffc1b2f3*/
 {
 *src_1 = *(v8 - 2); /*0xffc1b31c*/
 src_1[1] = *(v8 - 1); /*0xffc1b321*/
 src_1[2] = *v8; /*0xffc1b326*/
 src_1[3] = v8[1]; /*0xffc1b32c*/
 }
 else
 {
 *(_QWORD *)src_1 = __readmsr(n513 - 1); /*0xffc1b302*/
 *((_QWORD *)src_1 + 1) = __readmsr(n513); /*0xffc1b311*/
 }
 this_1 = this; /*0xffc1b32f*/
 n513 += 2; /*0xffc1b333*/
 v8 += 4; /*0xffc1b336*/
 src_1 += 4; /*0xffc1b339*/
 --n0x20_1; /*0xffc1b33c*/
 }
 while ( n0x20_1 ); /*0xffc1b33f*/
 }
 return src; /*0xffc1b348*/
}

/*
 *MtrrLibProgramOneEntry at 0xffc1b34c
 */
int MtrrLibProgramOneEntry(
 unsigned int *p_n0x100000,
 int p_p_n0x100000,
 __int64 a3,
 _DWORD *a4,
 _QWORD *a5,
 _QWORD *a6)
{
 int n11; // ebx unsigned int n33; // ecx unsigned int MtrrBaseLow; // ebp unsigned int MtrrTableValue; // edx unsigned int SubIndex; // esi int TableOffset; // ebp int RangeBase; // eax unsigned int BitOffset; // ebx unsigned int ChunkSize; // eax bool CarryFlag; // cf __int64 MaskValue; // [esp+10h] [ebp-18h]
 __int64 AttrValue; // [esp+18h] [ebp-10h]
 int n11_1; // [esp+24h] [ebp-4h]

 AttrValue = 0; /*0xffc1b34f*/
 MaskValue = 0; /*0xffc1b359*/
 n11 = 0; /*0xffc1b367*/
 n33 = 0; /*0xffc1b370*/
 MtrrBaseLow = p_n0x100000[1]; /*0xffc1b372*/
 do /*0xffc1b3a2*/
 {
 MtrrTableValue = dword_FFC1DA38[n33]; /*0xffc1b375*/
 if ( (MtrrBaseLow || *p_n0x100000 >= MtrrTableValue) /*0xffc1b396*/
 && !MtrrBaseLow
 && *p_n0x100000 < MtrrTableValue + 8 *dword_FFC1DA3C[n33] )
 {
 break; /*0xffc1b396*/
 }
 n33 += 3; /*0xffc1b398*/
 ++n11; /*0xffc1b39b*/
 }
 while ( n33 < 33 ); /*0xffc1b3a2*/
 n11_1 = n11; /*0xffc1b3a4*/
 if ( n11 == 11 ) /*0xffc1b3ab*/
 return -2147483645; /*0xffc1b3ab*/
 SubIndex = 0; /*0xffc1b3bb*/
 TableOffset = 3 *n11; /*0xffc1b3bd*/
 RangeBase = dword_FFC1DA38[3 *n11]; /*0xffc1b3c0*/
 do /*0xffc1b3da*/
 {
 if ( *p_n0x100000 == RangeBase && !p_n0x100000[1] ) /*0xffc1b3ca*/
 break; /*0xffc1b3ce*/
 RangeBase += dword_FFC1DA3C[3 *n11]; /*0xffc1b3d0*/
 ++SubIndex; /*0xffc1b3d6*/
 }
 while ( SubIndex < 8 ); /*0xffc1b3da*/
 if ( SubIndex == 8 ) /*0xffc1b3df*/
 return -2147483645; /*0xffc1b3df*/
 if ( SubIndex < 8 ) /*0xffc1b3e1*/
 {
 BitOffset = 8 *SubIndex; /*0xffc1b3e9*/
 do /*0xffc1b451*/
 {
 if ( *(_QWORD *)p_p_n0x100000 < (unsigned __int64)(unsigned int)dword_FFC1DA3C[TableOffset] ) /*0xffc1b3fc*/
 break; /*0xffc1b3fc*/
 AttrValue |= LShiftU64(a3); /*0xffc1b40d*/
 MaskValue |= LShiftU64(255); /*0xffc1b423*/
 ChunkSize = dword_FFC1DA3C[TableOffset]; /*0xffc1b42a*/
 CarryFlag = *(_DWORD *)p_p_n0x100000 < ChunkSize; /*0xffc1b434*/
 *(_DWORD *)p_p_n0x100000 -= ChunkSize; /*0xffc1b434*/
 *(_DWORD *)(p_p_n0x100000 + 4) -= CarryFlag; /*0xffc1b43a*/
 *(_QWORD *)p_n0x100000 += (unsigned int)dword_FFC1DA3C[TableOffset]; /*0xffc1b444*/
 BitOffset += 8; /*0xffc1b44a*/
 ++SubIndex; /*0xffc1b44d*/
 }
 while ( BitOffset < 0x40 ); /*0xffc1b451*/
 n11 = n11_1; /*0xffc1b453*/
 if ( SubIndex < 8 ) /*0xffc1b45a*/
 {
 if ( *(_QWORD *)p_p_n0x100000 ) /*0xffc1b45c*/
 return -2147483645; /*0xffc1b3ad*/
 }
 }
 *a4 = n11; /*0xffc1b46f*/
 *a5 = MaskValue; /*0xffc1b475*/
 *a6 = AttrValue; /*0xffc1b486*/
 return 0; /*0xffc1b491*/
}

/*
 *MtrrLibFillMtrrEntry at 0xffc1b499
 */
int MtrrLibFillMtrrEntry(unsigned __int8 *this, unsigned int a2, __int64 Arg1, __int64 Arg3, int EntryPtr)
{
 int Index; // ebx unsigned int Index; // edi int v8; // edx int v9; // eax int v10; // eax ZeroMem(EntryPtr, 0x400u); /*0xffc1b4af*/
 Index = 0; /*0xffc1b4b4*/
 Index = 0; /*0xffc1b4b6*/
 if ( a2 ) /*0xffc1b4bc*/
 {
 v8 = EntryPtr + 8; /*0xffc1b4be*/
 do /*0xffc1b525*/
 {
 if ( (*((_DWORD *)this + 2) & 0x800) != 0 ) /*0xffc1b4cc*/
 {
 *(_DWORD *)(v8 + 16) = Index; /*0xffc1b4ce*/
 v9 = HIDWORD(Arg3) & *((_DWORD *)this + 1); /*0xffc1b4d6*/
 *(_DWORD *)(v8 - 8) = Arg3 & *(_DWORD *)this; /*0xffc1b4de*/
 *(_DWORD *)(v8 - 4) = v9; /*0xffc1b4e1*/
 *(_QWORD *)v8 = (Arg1 & ~(Arg3 & *((_QWORD *)this + 1))) + 1; /*0xffc1b501*/
 v10 = *this; /*0xffc1b509*/
 *(_DWORD *)(v8 + 12) = 0; /*0xffc1b50c*/
 ++Index; /*0xffc1b510*/
 *(_DWORD *)(v8 + 8) = v10; /*0xffc1b511*/
 *(_WORD *)(v8 + 20) = 257; /*0xffc1b514*/
 }
 ++Index; /*0xffc1b51a*/
 this += 16; /*0xffc1b51b*/
 v8 += 32; /*0xffc1b51e*/
 }
 while ( Index < a2 ); /*0xffc1b525*/
 }
 return Index; /*0xffc1b527*/
}

/*
 *MtrrCheckMemoryAttributeMapped at 0xffc1b52f
 */
// positive sp value has been detected, the output may be wrong!
BOOL MtrrCheckMemoryAttributeMapped(
 unsigned int EntryIndex,
 int a2,
 unsigned __int64 n0x100000,
 unsigned __int64 MtrrAttr64)
{
 unsigned int AddressLow; // eax unsigned int EntryIndex_1; // ecx int BaseAddress; // edi unsigned int *MtrrAttr64_1; // esi unsigned __int64 EntryEndAddr; // kr08_8 char *AddressLow_3; // eax unsigned int EntryBaseLow; // edx unsigned __int64 n0x100000_1; // kr10_8 bool ResultFlag; // al double DebugArg1; // [esp-40h] [ebp-64h]
 unsigned __int64 MtrrAttr64_2; // [esp-18h] [ebp-3Ch]
 unsigned int EntryIndex_2; // [esp+Ch] [ebp-18h]
 void *AddressLow_2; // [esp+10h] [ebp-14h]
 unsigned int BaseAddress_1; // [esp+20h] [ebp-4h]
 void *AddressLow_1; // [esp+24h] [ebp+0h]

 AddressLow = (unsigned int)AddressLow_1; /*0xffc1b532*/
 EntryIndex_1 = 0; /*0xffc1b53e*/
 AddressLow_2 = AddressLow_1; /*0xffc1b544*/
 EntryIndex_2 = 0; /*0xffc1b548*/
 if ( AddressLow_1 ) /*0xffc1b550*/
 {
 BaseAddress = BaseAddress_1; /*0xffc1b56b*/
 }
 else
 {
 BaseAddress = BaseAddress_1; /*0xffc1b559*/
 if ( BaseAddress_1 < 0x100000 ) /*0xffc1b55f*/
 {
 AddressLow = 0; /*0xffc1b561*/
 BaseAddress = 0x100000; /*0xffc1b563*/
 AddressLow_2 = 0; /*0xffc1b565*/
 }
 }
 if ( !EntryIndex ) /*0xffc1b571*/
 {
LABEL_20:
 ResultFlag = AddressLow_2 != (void *)MtrrLibCalculateAddressMask( /*0xffc1b6c3*/
 (_DWORD *)HIDWORD(MtrrAttr64),
 __PAIR64__((unsigned int)AddressLow_2, BaseAddress));
 return !ResultFlag; /*0xffc1b6d7*/
 }
 MtrrAttr64_1 = (unsigned int *)MtrrAttr64; /*0xffc1b577*/
 while ( 1 ) /*0xffc1b583*/
 {
 if ( *((_BYTE *)MtrrAttr64_1 + 28) ) /*0xffc1b583*/
 {
 EntryEndAddr = *((_QWORD *)MtrrAttr64_1 + 1) + *(_QWORD *)MtrrAttr64_1 - 1LL; /*0xffc1b59b*/
 EntryIndex_1 = EntryIndex_2; /*0xffc1b5a8*/
 if ( __PAIR64__(AddressLow, BaseAddress) <= EntryEndAddr && n0x100000 >= *(_QWORD *)MtrrAttr64_1 ) /*0xffc1b5d5*/
 break; /*0xffc1b5d5*/
 }
LABEL_17:
 ++EntryIndex_1; /*0xffc1b6a8*/
 MtrrAttr64_1 += 8; /*0xffc1b6a9*/
 EntryIndex_2 = EntryIndex_1; /*0xffc1b6ac*/
 if ( EntryIndex_1 >= EntryIndex ) /*0xffc1b6b4*/
 goto LABEL_20; /*0xffc1b6b4*/
 AddressLow = (unsigned int)AddressLow_2; /*0xffc1b6b6*/
 }
 HIDWORD(DebugArg1) = 668; /*0xffc1b5f4*/
 LODWORD(DebugArg1) = "CheckMemoryAttributeMapped"; /*0xffc1b5f9*/
 DebugPrint( /*0xffc1b608*/
 0x200000,
 "%a():%d MTRR[%d] %lx..%lx %x ?= %x %lx..%lx\n",
 DebugArg1,
 EntryIndex_2,
 *MtrrAttr64_1,
 MtrrAttr64_1[1],
 (_DWORD)EntryEndAddr,
 (_DWORD)((unsigned __int64)(*((_QWORD *)MtrrAttr64_1 + 1) + *(_QWORD *)MtrrAttr64_1 - 1LL) >> 32),
 MtrrAttr64_1[4],
 MtrrAttr64_1[5],
 a2);
 AddressLow_3 = (char *)MtrrAttr64_1[1]; /*0xffc1b60d*/
 EntryBaseLow = *MtrrAttr64_1; /*0xffc1b617*/
 if ( __PAIR64__((unsigned int)AddressLow_2, BaseAddress) < *(_QWORD *)MtrrAttr64_1 ) /*0xffc1b621*/
 {
 HIDWORD(MtrrAttr64_2) = &AddressLow_3[(EntryBaseLow != 0) - 1]; /*0xffc1b631*/
 LODWORD(MtrrAttr64_2) = EntryBaseLow - 1; /*0xffc1b632*/
 if ( !MtrrCheckMemoryAttributeMapped( /*0xffc1b647*/
 EntryIndex,
 a2,
 __PAIR64__((unsigned int)AddressLow_2, BaseAddress),
 MtrrAttr64_2) )
 goto LABEL_19; /*0xffc1b647*/
 EntryBaseLow = *MtrrAttr64_1; /*0xffc1b649*/
 BaseAddress = *MtrrAttr64_1; /*0xffc1b64b*/
 AddressLow_3 = (char *)MtrrAttr64_1[1]; /*0xffc1b64d*/
 AddressLow_2 = AddressLow_3; /*0xffc1b650*/
 }
 n0x100000_1 = *((_QWORD *)MtrrAttr64_1 + 1) + __PAIR64__((unsigned int)AddressLow_3, EntryBaseLow); /*0xffc1b659*/
 if ( n0x100000 <= __PAIR64__( /*0xffc1b66e*/
 (unsigned int)((_DWORD)n0x100000_1 != 0) + HIDWORD(n0x100000_1) - 1,
 (int)n0x100000_1 - 1) )
 {
LABEL_16:
 EntryIndex_1 = EntryIndex_2; /*0xffc1b6a4*/
 goto LABEL_17; /*0xffc1b6a4*/
 }
 if ( MtrrCheckMemoryAttributeMapped(EntryIndex, a2, n0x100000_1, n0x100000) ) /*0xffc1b687*/
 {
 n0x100000 = *(_QWORD *)MtrrAttr64_1 + *((_QWORD *)MtrrAttr64_1 + 1) - 1LL; /*0xffc1b6a1*/
 goto LABEL_16; /*0xffc1b6a1*/
 }
LABEL_19:
 ResultFlag = 1; /*0xffc1b6bf*/
 return !ResultFlag; /*0xffc1b6da*/
}

/*
 *MtrrIsAddrInRange at 0xffc1b6e8
 */
char MtrrIsAddrInRange(unsigned int a1, int a2, unsigned __int64 n0x100000, unsigned __int64 a4)
{
 unsigned int Index; // esi Index = 0; /*0xffc1b6eb*/
 if ( !a1 ) /*0xffc1b6f0*/
 return 0; /*0xffc1b732*/
 while ( !*(_BYTE *)(a2 + 28) || n0x100000 > *(_QWORD *)a2 + *(_QWORD *)(a2 + 8) - 1LL || a4 < *(_QWORD *)a2 ) /*0xffc1b728*/
 {
 ++Index; /*0xffc1b72a*/
 a2 += 32; /*0xffc1b72b*/
 if ( Index >= a1 ) /*0xffc1b730*/
 return 0; /*0xffc1b730*/
 }
 return 1; /*0xffc1b734*/
}

/*
 *MtrrProgramVariableMtrr at 0xffc1b73d
 */
int MtrrProgramVariableMtrr(
 unsigned int MtrrCount2,
 unsigned int *p_n0x100000,
 __int64 n4,
 _QWORD *p_n0x100000a,
 int a5,
 _DWORD *a6,
 _BYTE *p_CacheEnabled)
{
 unsigned int n0x100000; // esi _DWORD *p_n0x100000a_1; // edi unsigned __int64 RangeEnd; // kr00_8 int *EntryPtr; // ecx unsigned int RangeLow1_1; // ebp unsigned __int64 RangeEnd_1; // kr10_8 unsigned int RangeHigh; // edi bool IsBelow; // cf bool IsBelowOrEq; // cc int n6; // ecx int EntryType; // edi unsigned int RangeLow2; // edi char Modified; // bl unsigned __int64 NewRangeEnd; // kr18_8 char Modified_1; // [esp+13h] [ebp-19h]
 int *EntryPtr_1; // [esp+14h] [ebp-18h]
 unsigned int RangeLow1; // [esp+18h] [ebp-14h]
 unsigned int RangeHigh_1; // [esp+20h] [ebp-Ch]
 unsigned int MtrrCount2_1; // [esp+24h] [ebp-8h]

 n0x100000 = *p_n0x100000; /*0xffc1b74f*/
 p_n0x100000a_1 = p_n0x100000a; /*0xffc1b752*/
 *p_CacheEnabled = 0; /*0xffc1b756*/
 Modified_1 = 0; /*0xffc1b761*/
 MtrrCount2_1 = 0; /*0xffc1b76b*/
 RangeEnd = *p_n0x100000a + __PAIR64__(p_n0x100000[1], n0x100000) - 1; /*0xffc1b768*/
 if ( !MtrrCount2 ) /*0xffc1b774*/
 return 0; /*0xffc1b774*/
 EntryPtr = (int *)(a5 + 16); /*0xffc1b77e*/
 EntryPtr_1 = (int *)(a5 + 16); /*0xffc1b781*/
 do /*0xffc1b90b*/
 {
 RangeLow1_1 = *(EntryPtr - 4); /*0xffc1b788*/
 RangeEnd_1 = *((_QWORD *)EntryPtr - 2) + *((_QWORD *)EntryPtr - 1) - 1LL; /*0xffc1b796*/
 if ( *((_BYTE *)EntryPtr + 12) ) /*0xffc1b799*/
 {
 RangeHigh = p_n0x100000[1]; /*0xffc1b7a9*/
 IsBelow = RangeHigh < HIDWORD(RangeEnd_1); /*0xffc1b7ac*/
 IsBelowOrEq = RangeHigh <= HIDWORD(RangeEnd_1); /*0xffc1b7ac*/
 RangeHigh_1 = RangeHigh; /*0xffc1b7ae*/
 p_n0x100000a_1 = p_n0x100000a; /*0xffc1b7b2*/
 RangeLow1 = *p_n0x100000; /*0xffc1b7b6*/
 if ( !IsBelowOrEq || !IsBelow && *p_n0x100000 > (unsigned int)RangeEnd_1 ) /*0xffc1b7c4*/
 goto LABEL_36; /*0xffc1b7c4*/
 EntryPtr = EntryPtr_1; /*0xffc1b7ca*/
 if ( RangeEnd >= __PAIR64__(*(EntryPtr_1 - 3), RangeLow1_1) ) /*0xffc1b7db*/
 {
 n6 = *EntryPtr_1; /*0xffc1b7e5*/
 EntryType = EntryPtr_1[1]; /*0xffc1b7e7*/
 if ( n4 == *(_QWORD *)EntryPtr_1 ) /*0xffc1b7ee*/
 {
 EntryPtr = EntryPtr_1; /*0xffc1b7fa*/
 RangeLow2 = p_n0x100000[1]; /*0xffc1b7fe*/
 if ( *(EntryPtr_1 - 3) <= RangeHigh_1 /*0xffc1b817*/
 && (*(EntryPtr_1 - 3) < RangeHigh_1 || RangeLow1_1 <= RangeLow1)
 && RangeEnd_1 >= RangeEnd )
 {
 p_n0x100000a_1 = p_n0x100000a; /*0xffc1b819*/
 Modified = 1; /*0xffc1b81d*/
 Modified_1 = 1; /*0xffc1b81f*/
 goto LABEL_38; /*0xffc1b823*/
 }
 if ( RangeHigh_1 > *(EntryPtr_1 - 3) || RangeHigh_1 >= *(EntryPtr_1 - 3) && RangeLow1 >= RangeLow1_1 ) /*0xffc1b833*/
 RangeLow2 = *(EntryPtr_1 - 3); /*0xffc1b83b*/
 else RangeLow1_1 = *p_n0x100000; /*0xffc1b835*/
 if ( RangeEnd <= RangeEnd_1 ) /*0xffc1b846*/
 RangeEnd = RangeEnd_1; /*0xffc1b84a*/
 *((_BYTE *)EntryPtr_1 + 12) = 0; /*0xffc1b850*/
 --*a6; /*0xffc1b856*/
 p_n0x100000[1] = RangeLow2; /*0xffc1b85e*/
 *p_n0x100000 = RangeLow1_1; /*0xffc1b861*/
 NewRangeEnd = RangeEnd - __PAIR64__(RangeLow2, RangeLow1_1); /*0xffc1b858*/
 p_n0x100000a_1 = p_n0x100000a; /*0xffc1b867*/
 *p_n0x100000a = NewRangeEnd + 1; /*0xffc1b871*/
 goto LABEL_35; /*0xffc1b876*/
 }
 if ( RangeLow1_1 != RangeLow1 /*0xffc1b890*/
 || (EntryType = EntryPtr_1[1], *(EntryPtr_1 - 3) != RangeHigh_1)
 || RangeEnd_1 != RangeEnd )
 {
 if ( (n4 != 4 || n6 != 6 || EntryType) && (n4 != 6 || n6 != 4 || EntryType) && n4 && EntryType | n6 ) /*0xffc1b8e0*/
 return -2147483633; /*0xffc1b926*/
 p_n0x100000a_1 = p_n0x100000a; /*0xffc1b8e4*/
LABEL_35:
 *p_CacheEnabled = 1; /*0xffc1b8e8*/
LABEL_36:
 EntryPtr = EntryPtr_1; /*0xffc1b8ef*/
 goto LABEL_37; /*0xffc1b8ef*/
 }
 EntryPtr = EntryPtr_1; /*0xffc1b89a*/
 p_n0x100000a_1 = p_n0x100000a; /*0xffc1b89c*/
 --*a6; /*0xffc1b8a0*/
 *((_BYTE *)EntryPtr_1 + 12) = 0; /*0xffc1b8a2*/
 }
 }
LABEL_37:
 Modified = Modified_1; /*0xffc1b8f3*/
LABEL_38:
 EntryPtr += 8; /*0xffc1b8f7*/
 EntryPtr_1 = EntryPtr; /*0xffc1b8ff*/
 ++MtrrCount2_1; /*0xffc1b903*/
 }
 while ( MtrrCount2_1 < MtrrCount2 ); /*0xffc1b90b*/
 if ( Modified ) /*0xffc1b913*/
 {
 *p_n0x100000a_1 = 0; /*0xffc1b915*/
 p_n0x100000a_1[1] = 0; /*0xffc1b918*/
 }
 return 0; /*0xffc1b91e*/
}

/*
 *MtrrLibCalculateHighAddress at 0xffc1b92d
 */
int MtrrLibCalculateHighAddress(int n0x100000, int n0x100000_4a)
{
 if ( !n0x100000_4a ) /*0xffc1b94a*/
 return GetPowerOfTwo64(n0x100000); /*0xffc1b98e*/
 GetPowerOfTwo64(n0x100000_4a); /*0xffc1b967*/
 return 0; /*0xffc1b995*/
}

/*
 *MtrrSetVariableMtrr at 0xffc1b999
 */
char MtrrSetVariableMtrr(unsigned __int64 n0x100000, unsigned __int64 ShiftedOne_2)
{
 _DWORD *CountPtr; // ecx _DWORD *CountPtr_1; // edi unsigned int EntryCount; // ebx __int64 ShiftedOne; // rax unsigned int RemainHi; // ecx unsigned int ShiftedOne_1; // esi unsigned int DiffHi; // ecx unsigned __int64 ShiftedOne_3; // kr00_8 int n0x100000_1; // edx int n0x100000_4a; // ecx __int64 Size1; // rax __int64 Size2; // rax __int64 n0x100000_2; // kr20_8 unsigned int EntryCount_1; // esi __int64 Size3; // rax _DWORD *CountPtr_2; // [esp+10h] [ebp-10h]
 unsigned int SavedArg2; // [esp+14h] [ebp-Ch]
 __int64 CountPtrSave; // [esp+18h] [ebp-8h]
 unsigned int RemainLoCopy; // [esp+2Ch] [ebp+Ch]
 int n0x100000_4; // [esp+2Ch] [ebp+Ch]

 CountPtr_1 = CountPtr; /*0xffc1b9a5*/
 SavedArg2 = HIDWORD(n0x100000); /*0xffc1b9a7*/
 EntryCount = 0; /*0xffc1b9ad*/
 CountPtr_2 = CountPtr; /*0xffc1b9b1*/
 LODWORD(CountPtrSave) = n0x100000; /*0xffc1b9b6*/
 *CountPtr = 0; /*0xffc1b9b9*/
 if ( n0x100000 ) /*0xffc1b9bb*/
 {
 MtrrBitScanForward(n0x100000); /*0xffc1b9bf*/
 ShiftedOne = LShiftU64(1); /*0xffc1b9c9*/
 RemainHi = HIDWORD(ShiftedOne_2); /*0xffc1b9ce*/
 ShiftedOne_1 = ShiftedOne_2; /*0xffc1b9d4*/
 HIDWORD(CountPtrSave) = HIDWORD(ShiftedOne); /*0xffc1b9da*/
 RemainLoCopy = ShiftedOne; /*0xffc1b9da*/
 if ( HIDWORD(ShiftedOne) <= HIDWORD(ShiftedOne_2) ) /*0xffc1b9df*/
 {
 if ( HIDWORD(ShiftedOne) >= HIDWORD(ShiftedOne_2) ) /*0xffc1b9e1*/
 goto LABEL_6; /*0xffc1b9e1*/
 do /*0xffc1ba22*/
 {
 do /*0xffc1ba22*/
 {
 ++*CountPtr_1; /*0xffc1b9e3*/
 ShiftedOne_3 = __PAIR64__(RemainHi, ShiftedOne_1) - __PAIR64__(HIDWORD(CountPtrSave), RemainLoCopy); /*0xffc1b9f1*/
 DiffHi = (__PAIR64__(RemainHi, ShiftedOne_1) - __PAIR64__(HIDWORD(CountPtrSave), RemainLoCopy)) >> 32; /*0xffc1b9f1*/
 ShiftedOne_1 = ShiftedOne_3; /*0xffc1b9f1*/
 SavedArg2 = (__PAIR64__(SavedArg2, RemainLoCopy) + CountPtrSave) >> 32; /*0xffc1b9fc*/
 LODWORD(CountPtrSave) = RemainLoCopy + CountPtrSave; /*0xffc1b9fc*/
 ShiftedOne_2 = __PAIR64__(DiffHi, ShiftedOne_3); /*0xffc1b9ff*/
 MtrrBitScanForward(__PAIR64__(SavedArg2, CountPtrSave)); /*0xffc1ba05*/
 ShiftedOne = LShiftU64(1); /*0xffc1ba0f*/
 RemainHi = HIDWORD(ShiftedOne_2); /*0xffc1ba14*/
 HIDWORD(CountPtrSave) = HIDWORD(ShiftedOne); /*0xffc1ba1d*/
 RemainLoCopy = ShiftedOne; /*0xffc1ba1d*/
 }
 while ( HIDWORD(ShiftedOne) < HIDWORD(ShiftedOne_2) ); /*0xffc1ba22*/
 if ( HIDWORD(ShiftedOne) > HIDWORD(ShiftedOne_2) ) /*0xffc1ba24*/
 break; /*0xffc1ba24*/
LABEL_6:
 ; /*0xffc1ba28*/
 }
 while ( (unsigned int)ShiftedOne <= ShiftedOne_1 ); /*0xffc1ba22*/
 }
 n0x100000_1 = HIDWORD(ShiftedOne_2); /*0xffc1ba2a*/
 if ( !(HIDWORD(ShiftedOne_2) | ShiftedOne_1) ) /*0xffc1ba2f*/
 return 1; /*0xffc1ba31*/
 }
 else
 {
 n0x100000_1 = HIDWORD(ShiftedOne_2); /*0xffc1ba3a*/
 ShiftedOne_1 = ShiftedOne_2; /*0xffc1ba3a*/
 }
 n0x100000_4a = n0x100000_1; /*0xffc1ba3d*/
 n0x100000_4 = n0x100000_1; /*0xffc1ba42*/
 do /*0xffc1ba5d*/
 {
 LODWORD(Size1) = MtrrLibCalculateHighAddress(ShiftedOne_1, n0x100000_4a); /*0xffc1ba47*/
 n0x100000_4a = (__PAIR64__(n0x100000_4, ShiftedOne_1) - Size1) >> 32; /*0xffc1ba4d*/
 ShiftedOne_1 -= Size1; /*0xffc1ba4d*/
 ++EntryCount; /*0xffc1ba57*/
 n0x100000_4 = n0x100000_4a; /*0xffc1ba5a*/
 }
 while ( __PAIR64__(n0x100000_4a, ShiftedOne_1) ); /*0xffc1ba5d*/
 LODWORD(Size2) = MtrrLibCalculateHighAddress(2 *ShiftedOne_2, ShiftedOne_2 >> 31); /*0xffc1ba7a*/
 n0x100000_2 = Size2 - ShiftedOne_2; /*0xffc1ba83*/
 EntryCount_1 = 1; /*0xffc1ba8d*/
 do /*0xffc1baa0*/
 {
 LODWORD(Size3) = MtrrLibCalculateHighAddress(n0x100000_2, SHIDWORD(n0x100000_2)); /*0xffc1ba90*/
 ++EntryCount_1; /*0xffc1ba9b*/
 n0x100000_2 -= Size3; /*0xffc1baa0*/
 }
 while ( n0x100000_2 ); /*0xffc1baa0*/
 if ( EntryCount <= EntryCount_1 ) /*0xffc1baaa*/
 {
 *CountPtr_2 += EntryCount; /*0xffc1baac*/
 return 1; /*0xffc1ba35*/
 }
 *CountPtr_2 += EntryCount_1; /*0xffc1bab0*/
 return 0; /*0xffc1bab4*/
}

/*
 *MtrrGetMsr at 0xffc1babb
 */
void MtrrGetMsr(_DWORD *dst, int n0x20, int a3)
{
 _BYTE *v3; // eax if ( n0x20 ) /*0xffc1babd*/
 {
 v3 = (_BYTE *)(a3 + 29); /*0xffc1bac4*/
 do /*0xffc1bae8*/
 {
 if ( !*(v3 - 1) ) /*0xffc1bac9*/
 {
 if ( *v3 ) /*0xffc1bace*/
 {
 *dst = 0; /*0xffc1bad2*/
 dst[1] = 0; /*0xffc1bad4*/
 dst[2] = 0; /*0xffc1bad7*/
 dst[3] = 0; /*0xffc1bada*/
 *v3 = 0; /*0xffc1badd*/
 }
 }
 dst += 4; /*0xffc1badf*/
 v3 += 32; /*0xffc1bae2*/
 --n0x20; /*0xffc1bae5*/
 }
 while ( n0x20 ); /*0xffc1bae8*/
 }
}

/*
 *MtrrGetPhysicalAddress at 0xffc1baec
 */
int MtrrGetPhysicalAddress(
 int dst,
 int n0x20,
 int n0x100000,
 int n0x20a,
 __int64 a5,
 int a6,
 int a7,
 int a8,
 int a9)
{
 int v9; // edx int result; // eax v9 = 2 *n0x20; /*0xffc1baf2*/
 *(_DWORD *)(dst + 8 *v9 + 4) = a7 | a9 & n0x20a; /*0xffc1bb0f*/
 *(_DWORD *)(dst + 8 *v9) = a6 | a8 & n0x100000; /*0xffc1bb19*/
 result = a9 & ~(((_DWORD)a5 != 0) + HIDWORD(a5) - 1); /*0xffc1bb21*/
 *(_DWORD *)(dst + 8 *v9 + 8) = a8 & ~(a5 - 1) | 0x800; /*0xffc1bb2a*/
 *(_DWORD *)(dst + 8 *v9 + 12) = result; /*0xffc1bb2e*/
 return result; /*0xffc1bb32*/
}

/*
 *MtrrResolveMemoryTypeFromCap at 0xffc1bb36
 */
unsigned int MtrrResolveMemoryTypeFromCap(int mtrrContext, unsigned int candidateType, int rawType)
{
 int v3; // ecx int result; // eax unsigned __int64 Result; // rax int v6; // [esp+0h] [ebp+0h]
 int wcType; // [esp+0h] [ebp+0h]
 int wpType; // [esp+0h] [ebp+0h]
 unsigned int memoryTypeLimit; // [esp+4h] [ebp+4h]

 v3 = mtrrContext; /*0xffc1bb33*/
 if ( !rawType ) /*0xffc1bb3d*/
 {
 v6 = 6; /*0xffc1bb42*/
 result = memoryTypeLimit; /*0xffc1bb44*/
 if ( candidateType <= memoryTypeLimit ) /*0xffc1bb49*/
 {
 switch ( candidateType ) /*0xffc1bb4e*/
  {
  case 0u: /*0xffc1bb4e*/
 return 0; /*0xffc1bb82*/
  case 1u: /*0xffc1bb4e*/
 return 1; /*0xffc1bb7e*/
  case 4u: /*0xffc1bb4e*/
 wpType = 4; /*0xffc1bb75*/
 break;
  case 5u: /*0xffc1bb4e*/
 wcType = 5; /*0xffc1bb71*/
 break;
  case 6u: /*0xffc1bb4e*/
 return result; /*0xffc1bb62*/
  default:
  goto LABEL_8; /*0xffc1bb62*/
 }
 return memoryTypeLimit; /*0xffc1bb79*/
 }
}
LABEL_8:
 if ( v3 ) /*0xffc1bb66*/
 Result = *(_DWORD *)(v3 + 600); /*0xffc1bb83*/
 else Result = __readmsr(0x2FFu); /*0xffc1bb6d*/
 return Result & 7; /*0xffc1bb78*/
}

/*
 *MtrrGetMtrrInfo at 0xffc1bb8e
 */
int MtrrGetMtrrInfo(_DWORD *p_Arg1, _DWORD *a2)
{
 __int64 v4; // rax int v5; // ecx int Result; // eax unsigned int v7; // [esp+Ch] [ebp-4h] BYREF AsmCpuid(0x80000000, &v7, (int)p_Arg1, (int)p_Arg1, 0); /*0xffc1bba5*/
 if ( v7 < 0x80000008 ) /*0xffc1bbb5*/
 {
 *p_Arg1 = -1; /*0xffc1bbee*/
 Result = 15; /*0xffc1bbf3*/
 p_Arg1[1] = 15; /*0xffc1bbf4*/
 *a2 = -4096; /*0xffc1bbf7*/
 }
 else
 {
 AsmCpuid(-2147483640, &v7, -2147483640, -2147483640, 0); /*0xffc1bbbe*/
 v4 = LShiftU64(1) - 1; /*0xffc1bbd3*/
 *(_QWORD *)p_Arg1 = v4; /*0xffc1bbdb*/
 v5 = v4 & 0xFFFFF000; /*0xffc1bbe2*/
 Result = HIDWORD(v4); /*0xffc1bbe8*/
 *a2 = v5; /*0xffc1bbea*/
 }
 a2[1] = Result; /*0xffc1bbfd*/
 return Result; /*0xffc1bc00*/
}

/*
 *MtrrMergeVariableMtrrType at 0xffc1bc06
 */
unsigned int MtrrMergeVariableMtrrType(__int64 currentTypePacked, unsigned int currentAttributeMask, __int64 entryAttributePacked)
{
 unsigned int mergedType; // esi bool isCacheTypeMatch; // zf bool isTypeAllowed; // zf int mergedTypeHint; // [esp+8h] [ebp+0h]
 int requestedType; // [esp+8h] [ebp+0h]
 unsigned int n6_2; // [esp+Ch] [ebp+4h]

 requestedType = 7; /*0xffc1bc13*/
 mergedType = n6_2; /*0xffc1bc15*/
 if ( __PAIR64__(currentAttributeMask, HIDWORD(currentTypePacked)) <= n6_2 ) /*0xffc1bc24*/
 {
 if ( HIDWORD(currentTypePacked) ) /*0xffc1bc2c*/
 {
 if ( HIDWORD(currentTypePacked) == 1 ) /*0xffc1bc31*/
 {
 isTypeAllowed = (_DWORD)entryAttributePacked == 1; /*0xffc1bc87*/
 goto LABEL_19; /*0xffc1bc87*/
 }
 if ( HIDWORD(currentTypePacked) != 4 ) /*0xffc1bc36*/
 {
 if ( HIDWORD(currentTypePacked) != 5 ) /*0xffc1bc3b*/
 {
 if ( HIDWORD(currentTypePacked) != 6 ) /*0xffc1bc40*/
 {
 isCacheTypeMatch = HIDWORD(currentTypePacked) == 7; /*0xffc1bc42*/
 goto LABEL_22; /*0xffc1bc45*/
 }
 if ( entryAttributePacked && entryAttributePacked != 4 ) /*0xffc1bc50*/
 {
 if ( (_DWORD)entryAttributePacked != 6 ) /*0xffc1bc59*/
 goto LABEL_25; /*0xffc1bc59*/
 isCacheTypeMatch = HIDWORD(entryAttributePacked) == 0; /*0xffc1bc5b*/
LABEL_22:
 if ( !isCacheTypeMatch ) /*0xffc1bc94*/
 goto LABEL_25; /*0xffc1bc94*/
 goto LABEL_23; /*0xffc1bc94*/
 }
 goto LABEL_23; /*0xffc1bc50*/
 }
 isTypeAllowed = (_DWORD)entryAttributePacked == 5; /*0xffc1bc5f*/
LABEL_19:
 if ( !isTypeAllowed || HIDWORD(entryAttributePacked) ) /*0xffc1bc8e*/
 {
 isCacheTypeMatch = entryAttributePacked == 0; /*0xffc1bc92*/
 goto LABEL_22; /*0xffc1bc92*/
 }
LABEL_23:
 mergedType = entryAttributePacked; /*0xffc1bc96*/
 goto LABEL_25; /*0xffc1bc9a*/
 }
 if ( entryAttributePacked == 4 || entryAttributePacked == 6 ) /*0xffc1bc70*/
 {
 requestedType = 4; /*0xffc1bc76*/
 mergedType = n6_2; /*0xffc1bc78*/
 }
 else if ( !entryAttributePacked ) /*0xffc1bc7f*/
 {
 return 0; /*0xffc1bc85*/
 }
 }
 else
 {
 mergedType = 0; /*0xffc1bc9c*/
 }
}
LABEL_25:
 if ( entryAttributePacked == 7 ) /*0xffc1bca3*/
 return HIDWORD(currentTypePacked); /*0xffc1bca9*/
 return mergedType; /*0xffc1bcb3*/
}

/*
 *MtrrLibCalculateAddressMask at 0xffc1bcb7
 */
int __thiscall MtrrLibCalculateAddressMask(_DWORD *this, unsigned __int64 n0x100000)
{
 unsigned __int64 MsrValue; // rax __int64 Result; // rdi int MtrrIndex; // ecx unsigned int TableIndex; // edx unsigned int RangeBase; // ebx unsigned int VariableCount; // eax unsigned int n0x20; // ebx int DebugLib; // eax int EntryCount; // eax _BYTE *EntryPtr; // ebx unsigned __int64 MsrData; // rax unsigned __int8 MtrrType; // al int Arg1; // [esp-14h] [ebp-648h]
 int Arg2; // [esp-10h] [ebp-644h]
 int Arg3; // [esp-Ch] [ebp-640h]
 unsigned int Arg4; // [esp-8h] [ebp-63Ch]
 __int64 Result1; // [esp+0h] [ebp-634h]
 int Result2; // [esp+0h] [ebp-634h]
 __int64 MtrrInfo; // [esp+8h] [ebp-62Ch]
 _DWORD v23[3]; // [esp+10h] [ebp-624h] BYREF int MtrrTypeResult; // [esp+1Ch] [ebp-618h]
 int Arg1_1; // [esp+20h] [ebp-614h] BYREF int Arg2_1; // [esp+24h] [ebp-610h]
 _DWORD *MtrrContext; // [esp+2Ch] [ebp-608h]
 unsigned __int8 MtrrBuffer[512]; // [esp+30h] [ebp-604h] BYREF _BYTE EntryPtr_1[1028]; // [esp+230h] [ebp-404h] BYREF MtrrContext = this; /*0xffc1bcc3*/
 if ( this ) /*0xffc1bcc9*/
 {
 HIDWORD(MsrValue) = *(this + 150); /*0xffc1bce0*/
 Arg2_1 = *(this + 151); /*0xffc1bce6*/
 }
 else
 {
 MsrValue = __readmsr(0x2FFu); /*0xffc1bcd0*/
 Arg2_1 = HIDWORD(MsrValue); /*0xffc1bcd2*/
 WORD2(MsrValue) = MsrValue; /*0xffc1bcd6*/
 }
 MtrrTypeResult = 7; /*0xffc1bcec*/
 HIDWORD(Result) = 0; /*0xffc1bcf4*/
 LODWORD(MsrValue) = WORD2(MsrValue) & 0x800; /*0xffc1bcfb*/
 if ( (MsrValue & 0x80000000000LL) != 0 ) /*0xffc1bcfd*/
 {
 if ( n0x100000 < 0x100000 && (MsrValue & 0x40000000000LL) != 0 ) /*0xffc1bd25*/
 {
 MtrrIndex = 0; /*0xffc1bd27*/
 TableIndex = 0; /*0xffc1bd29*/
 while ( 1 ) /*0xffc1bd2b*/
 {
 RangeBase = dword_FFC1DA38[TableIndex]; /*0xffc1bd2b*/
 if ( (unsigned int)n0x100000 >= RangeBase /*0xffc1bd5a*/
 && (unsigned int)n0x100000 < RangeBase + 8 *dword_FFC1DA3C[TableIndex] )
 {
 break; /*0xffc1bd5a*/
 }
 TableIndex += 3; /*0xffc1bd60*/
 ++MtrrIndex; /*0xffc1bd63*/
 if ( TableIndex >= 33 ) /*0xffc1bd6a*/
 goto LABEL_11; /*0xffc1bd6a*/
 }
 if ( this ) /*0xffc1be83*/
 MsrData = *((_QWORD *)this + MtrrIndex); /*0xffc1be97*/
 else MsrData = __readmsr(dword_FFC1DA34[3 *MtrrIndex]); /*0xffc1be93*/
 MtrrType = RShiftU64(MsrData); /*0xffc1bea5*/
 LODWORD(MsrValue) = MtrrResolveMemoryTypeFromCap(MtrrType, 0, 0); /*0xffc1beb3*/
 }
 else
 {
LABEL_11:
 MtrrGetMtrrInfo(&Arg1_1, v23); /*0xffc1bd6c*/
 VariableCount = MtrrGetVariableCount(); /*0xffc1bd7e*/
 MtrrReadAllMsrs((int)this, VariableCount, MtrrBuffer); /*0xffc1bd87*/
 Arg4 = v23[1]; /*0xffc1bd95*/
 Arg3 = v23[0]; /*0xffc1bd99*/
 Arg2 = Arg2_1; /*0xffc1bd9d*/
 Arg1 = Arg1_1; /*0xffc1bda1*/
 MtrrGetAvailableCount(); /*0xffc1bda5*/
 MtrrLibFillMtrrEntry(MtrrBuffer, Arg1, Arg2, Arg3, Arg4, (int)EntryPtr_1, Result1, MtrrInfo); /*0xffc1bdb0*/
 n0x20 = MtrrGetVariableCount(); /*0xffc1bdbd*/
 v23[0] = n0x20; /*0xffc1bdbf*/
 if ( n0x20 > 0x20 ) /*0xffc1bdc6*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1bdc8*/
 if ( DebugLib ) /*0xffc1bdcf*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1bde0*/
 "e:\\hs\\PurleySktPkg\\Override\\UefiCpuPkg\\Library\\MtrrLib\\MtrrLib.c",
 1317,
 "VariableMtrrCount <= 32");
 }
 if ( n0x20 ) /*0xffc1bde8*/
 {
 EntryCount = v23[0]; /*0xffc1bdea*/
 EntryPtr = EntryPtr_1; /*0xffc1bdee*/
 LODWORD(Result) = 7; /*0xffc1bdf7*/
 do /*0xffc1be49*/
 {
 if ( EntryPtr[28] ) /*0xffc1bdf8*/
 {
 if ( n0x100000 >= *(_QWORD *)EntryPtr && n0x100000 < *((_QWORD *)EntryPtr + 1) + *(_QWORD *)EntryPtr ) /*0xffc1be25*/
 Result = MtrrMergeVariableMtrrType(Result, *((_DWORD *)EntryPtr + 4), *((_DWORD *)EntryPtr + 5)); /*0xffc1be37*/
 EntryCount = v23[0]; /*0xffc1be3b*/
 }
 EntryPtr += 32; /*0xffc1be3f*/
 v23[0] = --EntryCount; /*0xffc1be45*/
 }
 while ( EntryCount ); /*0xffc1be49*/
 MtrrTypeResult = Result; /*0xffc1be4b*/
 }
 LODWORD(MsrValue) = MtrrResolveMemoryTypeFromCap(MtrrTypeResult, HIDWORD(Result), 0); /*0xffc1be5a*/
 }
 }
 return MsrValue; /*0xffc1be61*/
}

/*
 *MtrrProgramFixedMtrr at 0xffc1bebd
 */
// positive sp value has been detected, the output may be wrong!
char __thiscall MtrrProgramFixedMtrr(void *this)
{
 char result; // al void *v2; // ecx unsigned int VariableCount; // eax unsigned __int64 MsrValueA; // rax unsigned int n0xB; // esi void *v6; // ecx unsigned int MtrrCountA; // ebx unsigned int MtrrCountA_1; // edi _DWORD *src_1; // esi unsigned int *v10; // eax int *v11; // ebp unsigned int StatusA; // ecx unsigned int StatusB; // edi unsigned int MsrIndex; // edx unsigned int MtrrData; // esi unsigned int n7_1; // ebx unsigned int MtrrData_1; // kr00_4 bool CacheType; // zf void *v19; // ecx int MtrrBase; // ecx int MsrContents; // ebp unsigned __int64 n0x100000; // kr28_8 unsigned int n7_2; // ebx int MsrLow; // ebx unsigned int MsrLow_2; // edx unsigned int MsrContents_1; // ecx _DWORD *v27; // eax int MsrIndex_2; // ebx __int64 RegisterB; // rcx __int64 MsrContents_3; // rax unsigned __int64 AddressMask; /... [10908 chars total]

/*
 *MtrrSetMemoryAttributeWorker at 0xffc1c3a6
 */
int __usercall MtrrSetMemoryAttributeWorker@<eax>(
 int a1@<edx>,
 unsigned __int64 n0x100000,
 unsigned __int64 p_n0x100000)
{
 __int64 MtrrCount; // rcx unsigned int p_n0x100000_1; // edi int RegisterValue1; // eax int RegisterValue2; // edx unsigned int MtrrAttr; // esi int Status1; // eax bool IsValid; // zf int MtrrValue1; // esi unsigned __int64 MsrValue; // rax int MtrrRegIndex; // ecx int ReturnStatus; // eax unsigned int MtrrAttr_1; // kr00_4 unsigned int n0x100000_2; // esi unsigned __int64 MtrrAttr64; // kr28_8 unsigned int MtrrCount2; // ecx unsigned int n0x20_1; // edi unsigned int n0x20a_3; // eax unsigned __int64 MsrValue2; // rax char CacheEnabled; // al int RegisterValue3; // edx unsigned int MtrrCount3; // edx int *MtrrEntryPtr; // esi __int64 p_n0x100000_2; // rax int *MtrrEntryPtr2; // esi unsigned int n0x20a_1; // eax int v28; // eax int RegisterValue4; // edx unsigned int n0x20_2; // edx
 ... [21104 chars total]

/*
 *MtrrS3RestoreVariables at 0xffc1cb31
 */
int __thiscall MtrrS3RestoreVariables(unsigned __int64 *this)
{
 unsigned __int64 n0x20; // rax int n0x20_1; // esi unsigned int n513; // ebx LODWORD(n0x20) = MtrrGetVariableCount(); /*0xffc1cb3c*/
 n0x20_1 = n0x20; /*0xffc1cb41*/
 if ( (unsigned int)n0x20 > 0x20 ) /*0xffc1cb46*/
 {
 LODWORD(n0x20) = DebugGetDebugLib(); /*0xffc1cb48*/
 if ( (_DWORD)n0x20 ) /*0xffc1cb4f*/
 LODWORD(n0x20) = (*(int ( **)(char *, int, char *))(n0x20 + 4))((char *)-4073508, 2042, (char *)-4073532); /*0xffc1cb60*/
 }
 if ( n0x20_1 ) /*0xffc1cb68*/
 {
 n513 = 513; /*0xffc1cb6a*/
 do /*0xffc1cbae*/
 {
 __writemsr(n513 - 1, *this); /*0xffc1cb89*/
 n0x20 = *(this + 1); /*0xffc1cb9d*/
 __writemsr(n513, n0x20); /*0xffc1cba3*/
 n513 += 2; /*0xffc1cba5*/
 this += 2; /*0xffc1cba8*/
 --n0x20_1; /*0xffc1cbab*/
 }
 while ( n0x20_1 ); /*0xffc1cbae*/
 }
 return n0x20; /*0xffc1cbb0*/
}

/*
 *MtrrS3RestoreMsrs at 0xffc1cbb7
 */
unsigned __int64 __thiscall MtrrS3RestoreMsrs(unsigned __int64 *this)
{
 unsigned int i; // edi unsigned __int64 result; // rax for ( i = 0; i < 0x84; i += 12 ) /*0xffc1cbc1*/
 {
 result = *this; /*0xffc1cbda*/
 __writemsr(*(_DWORD *)(i - 4072908), *this++); /*0xffc1cbe0*/
 }
 return result; /*0xffc1cbf0*/
}

/*
 *MtrrIsMtrrSupported at 0xffc1cbf6
 */
// positive sp value has been detected, the output may be wrong!
bool __thiscall MtrrIsMtrrSupported(void *this)
{
 unsigned __int64 v1; // rax int v2; // edi int v3; // esi bool result; // al int v5; // [esp+Ch] [ebp-4h] BYREF AsmCpuid(1, 0, (int)this, (int)this, &v5); /*0xffc1cc08*/
 result = 0; /*0xffc1cc48*/
 if ( (v5 & 0x1000) != 0 ) /*0xffc1cc17*/
 {
 v1 = __readmsr(0xFEu); /*0xffc1cc1e*/
 v2 = HIDWORD(v1); /*0xffc1cc20*/
 v3 = v1; /*0xffc1cc24*/
 if ( BitFieldRead64(0, 7u, v1, SHIDWORD(v1)) ) /*0xffc1cc2b*/
 {
 if ( BitFieldRead64(8u, 8u, v3, v2) ) /*0xffc1cc3d*/
 return 1; /*0xffc1cc17*/
 }
 }
 return result; /*0xffc1cc4e*/
}

/*
 *CmosDebugPortCheck at 0xffc1cf63
 */
int CmosDebugPortCheck()
{
 unsigned __int8 v0; // al char Result; // al char n3_1; // cl v0 = __inbyte(0x70u); /*0xffc1cf69*/
 __outbyte(0x70u, v0 & 0x80 | 0x4A); /*0xffc1cf6e*/
 Result = __inbyte(0x71u); /*0xffc1cf75*/
 n3_1 = Result; /*0xffc1cf76*/
 if ( (unsigned __int8)Result <= 3u ) /*0xffc1cf7b*/
 {
LABEL_4:
 if ( !n3_1 ) /*0xffc1cf96*/
 return 0; /*0xffc1cf96*/
 goto LABEL_5; /*0xffc1cf96*/
 }
 n3_1 = Result; /*0xffc1cf7d*/
 if ( !Result ) /*0xffc1cf85*/
 {
 n3_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffc1cf91*/
 goto LABEL_4; /*0xffc1cf91*/
 }
LABEL_5:
 if ( n3_1 != -1 )
 return n3_1 != 1 ? -2147483578 : -2147483644;
 return 0; /*0xffc1cfae*/
}

/*
 *PeiGetServices at 0xffc1cfb2
 */
int PeiGetServices()
{
 int Result; // esi _BYTE v2[8]; // [esp+4h] [ebp-8h] BYREF CpuReadIdtr(v2); /*0xffc1cfbb*/
 Result = *(_DWORD *)(*(_DWORD *)&v2[2] - 4); /*0xffc1cfc3*/
 if ( !Result ) /*0xffc1cfc8*/
 DebugAssert(-4072524, 48, "PeiServices != ((void *) 0)"); /*0xffc1cfd7*/
 return Result; /*0xffc1cfdf*/
}

/*
 *ReadUnaligned64 at 0xffc1d02a
 */
__int64 __thiscall ReadUnaligned64(void *this)
{
 int DebugLib; // eax if ( !this ) /*0xffc1d02f*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1d031*/
 if ( DebugLib ) /*0xffc1d038*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1d049*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
 192,
 "Buffer != ((void *) 0)");
 }
 return *(_QWORD *)this; /*0xffc1d054*/
}

/*
 *WriteUnaligned64 at 0xffc1d056
 */
int WriteUnaligned64(int Unaligned64, int a2)
{
 _DWORD *v2; // ecx _DWORD *v3; // esi int DebugLib; // eax v3 = v2; /*0xffc1d057*/
 if ( !v2 ) /*0xffc1d05b*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1d05d*/
 if ( DebugLib ) /*0xffc1d064*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1d075*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
 219,
 "Buffer != ((void *) 0)");
 }
 *v3 = Unaligned64; /*0xffc1d083*/
 v3[1] = a2; /*0xffc1d085*/
 return Unaligned64; /*0xffc1d088*/
}

/*
 *MtrrWriteMsrWithFilter at 0xffc1d08a
 */
int MtrrWriteMsrWithFilter(_BYTE *this, unsigned __int64 n3)
{
 unsigned __int64 Result; // rax unsigned __int64 v4; // [esp-18h] [ebp-2Ch]

 v4 = __readmsr(0x2FFu); /*0xffc1d0a5*/
 LODWORD(Result) = BitFieldOr64(v4, SHIDWORD(v4), 767, 767, n3); /*0xffc1d0a6*/
 __writemsr(0x2FFu, Result); /*0xffc1d0bd*/
 return Result; /*0xffc1d0bf*/
}

/*
 *BitFieldRead64 at 0xffc1d0c3
 */
unsigned __int64 BitFieldRead64(unsigned int n8, unsigned int n8_1, __int64 a3)
{
 int DebugLib; // eax __int64 v4; // rax if ( n8 > n8_1 ) /*0xffc1d0cc*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1d0ce*/
 if ( DebugLib ) /*0xffc1d0d5*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1d0e6*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\BitField.c",
 732,
 "StartBit <= EndBit");
 }
 v4 = LShiftU64(-2); /*0xffc1d0f2*/
 return RShiftU64(a3 & ~v4); /*0xffc1d10f*/
}

/*
 *BitFieldWrite64 at 0xffc1d113
 */
unsigned int BitFieldWrite64(int a1, int a2, unsigned __int64 a3)
{
 int v3; // esi int DebugLib; // eax int v5; // esi v3 = RShiftU64(a3) & 1; /*0xffc1d131*/
 if ( RShiftU64(a3) != v3 ) /*0xffc1d140*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1d146*/
 if ( DebugLib ) /*0xffc1d14d*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1d15e*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\BitField.c",
 817,
 "RShiftU64 (OrData, EndBit - StartBit) == (RShiftU64 (OrData, EndBit - StartBit) & 1)");
 }
 v5 = LShiftU64(a3); /*0xffc1d17b*/
 return a1 | v5 & ~(unsigned int)LShiftU64(-2); /*0xffc1d193*/
}

/*
 *BitFieldAnd64 at 0xffc1d197
 */
unsigned int BitFieldAnd64(int a1)
{
 __int64 v1; // rdi unsigned __int64 v2; // rax int DebugLib; // eax int v4; // esi HIDWORD(v1) = RShiftU64(0) & 1; /*0xffc1d1af*/
 LODWORD(v1) = 0; /*0xffc1d1b2*/
 v2 = RShiftU64(0); /*0xffc1d1b4*/
 if ( __PAIR64__(v2, HIDWORD(v2)) != v1 ) /*0xffc1d1be*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1d1c4*/
 if ( DebugLib ) /*0xffc1d1cb*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1d1dc*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\BitField.c",
 869,
 "RShiftU64 (AndData, EndBit - StartBit) == (RShiftU64 (AndData, EndBit - StartBit) & 1)");
 }
 v4 = LShiftU64(-1); /*0xffc1d1f7*/
 return a1 & ~(v4 & ~(unsigned int)LShiftU64(-2)); /*0xffc1d215*/
}

/*
 *BitFieldOr64 at 0xffc1d219
 */
unsigned int BitFieldOr64(int a1, int a2, int n767, int a4, unsigned __int64 n3)
{
 unsigned int v5; // eax int v6; // edx v5 = BitFieldAnd64(a1); /*0xffc1d22c*/
 return BitFieldWrite64(v5, v6, n3); /*0xffc1d23f*/
}

/*
 *MtrrBitScanForward at 0xffc1d240
 */
int MtrrBitScanForward(unsigned __int64 n0x100000)
{
 int i; // esi if ( !n0x100000 ) /*0xffc1d24c*/
 return -1; /*0xffc1d24e*/
 for ( i = 0; (n0x100000 & 1) == 0; n0x100000 >>= 1 ) /*0xffc1d25a*/
 ++i; /*0xffc1d25c*/
 return i; /*0xffc1d283*/
}

/*
 *LShiftU64 at 0xffc1d286
 */
__int64 LShiftU64(__int64 a1)
{
 unsigned int n0x40; // ecx int DebugLib; // eax __int64 Result; // rax char n0x40_1; // [esp+0h] [ebp-4h]

 n0x40_1 = n0x40; /*0xffc1d28a*/
 if ( n0x40 >= 0x40 ) /*0xffc1d290*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1d292*/
 if ( DebugLib ) /*0xffc1d299*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1d2a7*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\LShiftU64.c",
 39,
 "Count < 64");
 }
 LODWORD(Result) = 0; /*0xffc1d2b0*/
 HIDWORD(Result) = a1; /*0xffc1d2b2*/
 if ( (n0x40_1 & 0x20) == 0 ) /*0xffc1d2b8*/
 Result = a1; /*0xffc1d2ba*/
 return Result << (n0x40_1 & 0x1F); /*0xffc1d2c4*/
}

/*
 *GetPowerOfTwo64 at 0xffc1d2c8
 */
int GetPowerOfTwo64(int n0x100000)
{
 char n31; // dl if ( !n0x100000 ) /*0xffc1d2ca*/
 return 0; /*0xffc1d2cc*/
 n31 = 31; /*0xffc1d2d1*/
 while ( n0x100000 > 0 ) /*0xffc1d2d9*/
 {
 --n31; /*0xffc1d2d4*/
 n0x100000 *= 2; /*0xffc1d2d5*/
 }
 return 1 << n31; /*0xffc1d2ce*/
}

/*
 *RShiftU64 at 0xffc1d2e3
 */
unsigned __int64 RShiftU64(unsigned __int64 a1)
{
 unsigned int n0x40; // ecx int DebugLib; // eax unsigned __int64 Result; // rax char n0x40_1; // [esp+0h] [ebp-4h]

 n0x40_1 = n0x40; /*0xffc1d2e7*/
 if ( n0x40 >= 0x40 ) /*0xffc1d2ed*/
 {
 DebugLib = DebugGetDebugLib(); /*0xffc1d2ef*/
 if ( DebugLib ) /*0xffc1d2f6*/
 (*(void ( **)(const char *, int, const char *))(DebugLib + 4))( /*0xffc1d304*/
 "e:\\hs\\MdePkg\\Library\\BaseLib\\RShiftU64.c",
 39,
 "Count < 64");
 }
 Result = HIDWORD(a1); /*0xffc1d30f*/
 if ( (n0x40_1 & 0x20) == 0 ) /*0xffc1d315*/
 Result = a1; /*0xffc1d319*/
 return Result >> (n0x40_1 & 0x1F); /*0xffc1d321*/
}

/*
 *CpuReadIdtr at 0xffc1d325
 */
void *__thiscall CpuReadIdtr(void *this)
{
 void *this_1; // eax if ( !this ) /*0xffc1d32b*/
 DebugAssert((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, "Idtr != ((void *) 0)"); /*0xffc1d33a*/
 this_1 = this; /*0xffc1d340*/
 __sidt(this); /*0xffc1d343*/
 return this_1; /*0xffc1d347*/
}