Newer
Older
AMI-Aptio-BIOS-Reversed / Build / GuidArtifacts / 117828F1-DA7D-4BC1-8B58-9A954FED5121 / RsteDevice.c
@Ajax Dong Ajax Dong 2 days ago 72 KB Full restructure
#include "117828F1-DA7D-4BC1-8B58-9A954FED5121.h"

// RsteDevice.c - Device initialization
// Extracted from 117828F1-DA7D-4BC1-8B58-9A954FED5121.c

// Function: RstUefiDriverEntryPoint @ 0x4058 (0x7d bytes)
// Index: 74/906

EFI_STATUS __fastcall RstUefiDriverEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  __int64 v3; // rax
  __int64 v4; // rbx

  EfiDriverInit(ImageHandle, SystemTable); /*0x4065*/
  GetSystemMemoryMap(0); /*0x406c*/
  v3 = MemAlloc(744); /*0x407d*/
  v4 = v3; /*0x4082*/
  if ( v3 ) /*0x4088*/
  {
    RstPrivateDataInit(v3, ImageHandle); /*0x4090*/
    *(_QWORD *)(v4 + 720) = 0; /*0x4095*/
    *(_QWORD *)(v4 + 728) = 0; /*0x409d*/
    *(_BYTE *)(v4 + 736) = 0; /*0x40ac*/
    *(_QWORD *)v4 = &off_23120; /*0x40b3*/
  }
  else
  {
    v4 = 0; /*0x40b8*/
  }
  qword_35410 = v4; /*0x40ba*/
  return (*(EFI_STATUS (__fastcall **)(__int64))(*(_QWORD *)v4 + 16LL))(v4);
}

// Function: RstAllocContext728 @ 0x4730 (0xb1 bytes)
// Index: 97/906

RST_DEVICE *__fastcall RstAllocContext728(RST_PRIVATE_DATA *Private)
{
  __int64 v1; // rdx
  __int64 v2; // rbx
  _QWORD *v4; // rax
  _QWORD *NewContext; // rbx
  RST_DEVICE *result; // rax
  bool v7; // di
  bool v8; // cl

  v2 = v1; /*0x4744*/
  v4 = (_QWORD *)MemAlloc(632); /*0x4756*/
  if ( v4 ) /*0x4760*/
    NewContext = RstCreateNewContext(v4, v2, (__int64)Private); /*0x4770*/
  else
    NewContext = 0; /*0x4775*/
  result = (RST_DEVICE *)RstReturnSuccess(NewContext); /*0x477b*/
  v7 = (_DWORD)result != -1; /*0x4783*/
  if ( (_DWORD)result == -1 ) /*0x478a*/
    goto LABEL_9; /*0x478a*/
  result = (RST_DEVICE *)(*(__int64 (__fastcall **)(_QWORD *))(*NewContext + 8LL))(NewContext); /*0x4792*/
  v8 = v7; /*0x4795*/
  if ( (__int64)result < 0 ) /*0x479c*/
    v8 = 0; /*0x479c*/
  if ( !v8 ) /*0x47a2*/
  {
LABEL_9:
    if ( NewContext ) /*0x47bd*/
      return (RST_DEVICE *)(*(__int64 (__fastcall **)(_QWORD *, __int64))*NewContext)(NewContext, 1); /*0x47ca*/
  }
  else
  {
    RstInstallClass((RST_PRIVATE_DATA *)&Private->HiiLibFunctions[1], NewContext); /*0x47ab*/
    return (RST_DEVICE *)sub_5404(NewContext); /*0x47b3*/
  }
  return result; /*0x47db*/
}

// Function: RstAllocContext440 @ 0x47e4 (0x63 bytes)
// Index: 98/906

void *__fastcall RstAllocContext440(RST_PRIVATE_DATA *Private)
{
  __int64 v1; // rdx
  __int64 v2; // rsi
  __int64 v4; // rax
  void *Context; // rbx

  v2 = v1; /*0x47f3*/
  v4 = MemAlloc(440); /*0x4805*/
  Context = 0; /*0x480a*/
  if ( v4 ) /*0x480f*/
    Context = (void *)RstFormCallbackHandler(v4, (__int64)Private, v2); /*0x481f*/
  RstInstallClass((RST_PRIVATE_DATA *)&Private->HiiLibFunctions[1], Context); /*0x4829*/
  return (*(void *(__fastcall **)(void *))(*(_QWORD *)Context + 8LL))(Context);
}

// Function: RstFreeContext @ 0x4848 (0x58 bytes)
// Index: 99/906

void __fastcall RstFreeContext(void *Context)
{
  unsigned int v1; // edx
  unsigned int v2; // edi
  _DWORD *Context_1; // r11
  unsigned int v4; // ebx
  unsigned int v5; // esi

  v2 = v1; /*0x4857*/
  Context_1 = Context; /*0x4859*/
  if ( v1 ) /*0x485e*/
  {
    v4 = 0; /*0x4860*/
    v5 = v1 - 1; /*0x4862*/
    while ( !HiiLibGetDefaultStringId((__int64)Context_1, v4, v2) ) /*0x4874*/
    {
      if ( ++v4 > v5 ) /*0x487a*/
        goto LABEL_5; /*0x487a*/
    }
  }
  else
  {
LABEL_5:
    ++Context_1[27]; /*0x487c*/
  }
}

// Function: RstHelper_48a0 @ 0x48a0 (0x36 bytes)
// Index: 100/906

void __fastcall RstHelper_48a0(RST_PRIVATE_DATA *Private)
{
  _QWORD *i; // rbx
  RST_DEVICE *Device; // rcx

  for ( i = Private->HiiLibFunctions[1]; i; i = (_QWORD *)*i ) /*0x48a6*/
  {
    if ( !(*(unsigned __int8 (__fastcall **)(_QWORD))(*(_QWORD *)i[2] + 104LL))(i[2]) ) /*0x48b3*/
    {
      Device = (RST_DEVICE *)i[2]; /*0x48ba*/
      if ( Device ) /*0x48c1*/
        RstFormEntry(Device); /*0x48c3*/
    }
  }
}

// Function: RstCreateNewContext @ 0x4c3c (0x69 bytes)
// Index: 106/906

_QWORD *__fastcall RstCreateNewContext(_QWORD *a1, __int64 a2, RST_PRIVATE_DATA *Private)
{
  CfgArrayAllocBlock(a1, (__int64)Private); /*0x4c4f*/
  *a1 = off_231B0; /*0x4c6c*/
  a1[23] = a2; /*0x4c6f*/
  a1[24] = 0; /*0x4c76*/
  a1[25] = 0; /*0x4c7d*/
  a1[78] = 0; /*0x4c84*/
  a1[45] = 0; /*0x4c8b*/
  MemZero((_BYTE *)a1 + 368, 0, 256); /*0x4c92*/
  return a1; /*0x4c9f*/
}

// Function: RstNullSub2 @ 0x4ca8 (0x3 bytes)
// Index: 107/906

char RstNullSub2()
{
  return 0; /*0x4caa*/
}

// Function: RstNullSub @ 0x4cac (0xb bytes)
// Index: 108/906

bool __fastcall RstNullSub(__int64 a1, __int64 a2)
{
  return a2 == *(_QWORD *)(a1 + 184); /*0x4cb6*/
}

// Function: RstFormEntry @ 0x4cb8 (0x3e2 bytes)
// Index: 109/906

RST_FORM_ENTRY *__fastcall RstFormEntry(RST_DEVICE *Device)
{
  _BYTE *FormEntry_1; // rax
  uint8_t *v4; // r8
  __int64 n3; // r9
  __int64 v6; // rdx
  __int64 v7; // rdx
  uint8_t *v8; // r8
  __int64 n8; // r9
  UINTN v10; // rax
  char *FormEntry; // rcx
  UINTN v12; // rax
  char *FormEntry_2; // rcx
  UINTN v14; // rax
  unsigned __int8 Length; // al
  RST_FORM_ENTRY *v16; // rdi
  UINTN v17; // rax
  UINTN v18; // rax
  CHAR16 i_1[12]; // [rsp+20h] [rbp-58h] BYREF
  CHAR16 i[28]; // [rsp+38h] [rbp-40h] BYREF

  if ( Device->FormEntry ) /*0x4cc7*/
    return 0; /*0x4cd6*/
  FormEntry_1 = (_BYTE *)MemAllocPages(116); /*0x4ce3*/
  Device->FormEntry = FormEntry_1; /*0x4ce8*/
  if ( !FormEntry_1 ) /*0x4cf2*/
    return (RST_FORM_ENTRY *)0x8000000000000009LL; /*0x4cf2*/
  MemZero(FormEntry_1, 0, 116); /*0x4d0b*/
  *(_QWORD *)((char *)Device->FormEntry + 28) = Device->reserved_090[152]; /*0x4d1f*/
  *(_QWORD *)((char *)Device->FormEntry + 36) = Device->reserved_090[153]; /*0x4d31*/
  *(_QWORD *)((char *)Device->FormEntry + 44) = Device->reserved_090[159]; /*0x4d43*/
  *((_QWORD *)Device->FormEntry + 2) = Device->reserved_090[158]; /*0x4d55*/
  *((_DWORD *)Device->FormEntry + 6) = *(_DWORD *)&Device->reserved_090[154]; /*0x4d66*/
  v4 = &Device->reserved_090[193]; /*0x4d80*/
  n3 = 3; /*0x4d8a*/
  *(_QWORD *)Device->FormEntry = ((unsigned __int64)*(unsigned __int16 *)&Device->reserved_090[161] >> 4) & 0xF; /*0x4d8e*/
  *((_WORD *)Device->FormEntry + 26) = *(_WORD *)&Device->reserved_090[213]; /*0x4d9f*/
  *((_QWORD *)Device->FormEntry + 1) = ((unsigned __int64)*(unsigned __int16 *)&Device->reserved_090[161] >> 8) & 3; /*0x4db8*/
  *(_QWORD *)((char *)Device->FormEntry + 70) = *(unsigned int *)&Device->reserved_090[82] /*0x4dd7*/
                                              | ((unsigned __int64)*(unsigned __int16 *)&Device->reserved_090[80] << 32);
  v6 = 0; /*0x4df0*/
  *(_WORD *)((char *)Device->FormEntry + 83) = (*(_WORD *)&Device->reserved_090[161] >> 10) & 0xF; /*0x4df2*/
  *(_QWORD *)((char *)Device->FormEntry + 85) = *(_QWORD *)&Device->reserved_090[48]; /*0x4e04*/
  *(_DWORD *)((char *)Device->FormEntry + 78) = *(_DWORD *)&Device->reserved_090[72]; /*0x4e15*/
  *(_WORD *)((char *)Device->FormEntry + 93) = *(_WORD *)&Device->reserved_090[187]; /*0x4e26*/
  *(_WORD *)((char *)Device->FormEntry + 95) = *(_WORD *)&Device->reserved_090[189]; /*0x4e38*/
  *(_WORD *)((char *)Device->FormEntry + 97) = *(_WORD *)&Device->reserved_090[191]; /*0x4e4a*/
  do /*0x4e66*/
  {
    *((_BYTE *)Device->FormEntry + ++v6 + 98) = *v4++; /*0x4e5b*/
    --n3; /*0x4e62*/
  }
  while ( n3 ); /*0x4e66*/
  v7 = 0; /*0x4e75*/
  v8 = &Device->reserved_090[197]; /*0x4e77*/
  n8 = 8; /*0x4e7e*/
  *((_BYTE *)Device->FormEntry + 102) = Device->reserved_090[196]; /*0x4e82*/
  do /*0x4e9d*/
  {
    *((_BYTE *)Device->FormEntry + ++v7 + 102) = *v8++; /*0x4e92*/
    --n8; /*0x4e99*/
  }
  while ( n8 ); /*0x4e9d*/
  *((_BYTE *)Device->FormEntry + 111) = Device->reserved_090[205]; /*0x4eb0*/
  RstStringTrimCopy(i_1, 21, (const CHAR16 *)&Device->reserved_090[92], 0x14u); /*0x4ec5*/
  RstStringTrimCopy(i, 41, (const CHAR16 *)&Device->reserved_090[112], 0x28u); /*0x4edd*/
  v10 = AsciiStrLen((const CHAR8 *)i_1); /*0x4ee7*/
  *(_QWORD *)((char *)Device->FormEntry + 54) = MemAllocPages(2 * v10 + 2); /*0x4efd*/
  FormEntry = (char *)Device->FormEntry; /*0x4f01*/
  if ( !*(_QWORD *)(FormEntry + 54) ) /*0x4f08*/
  {
LABEL_10:
    MemZeroThenFree(FormEntry, 116); /*0x4f0f*/
    return (RST_FORM_ENTRY *)0x8000000000000009LL; /*0x4cfe*/
  }
  v12 = AsciiStrLen((const CHAR8 *)i); /*0x4f21*/
  *(_QWORD *)((char *)Device->FormEntry + 62) = MemAllocPages(2 * v12 + 2); /*0x4f37*/
  FormEntry_2 = (char *)Device->FormEntry; /*0x4f3b*/
  if ( !*(_QWORD *)(FormEntry_2 + 62) ) /*0x4f42*/
  {
    v14 = StrLen(*(const CHAR16 **)(FormEntry_2 + 54)); /*0x4f4d*/
    MemZeroThenFree(*(_BYTE **)((char *)Device->FormEntry + 54), v14); /*0x4f60*/
    FormEntry = (char *)Device->FormEntry; /*0x4f65*/
    goto LABEL_10; /*0x4f6c*/
  }
  FormEntry_2[112] = Device->reserved_090[206]; /*0x4f77*/
  *((_BYTE *)Device->FormEntry + 113) = Device->reserved_090[207]; /*0x4f87*/
  *((_BYTE *)Device->FormEntry + 114) = Device->reserved_090[208]; /*0x4f97*/
  *((_BYTE *)Device->FormEntry + 115) = Device->reserved_090[209]; /*0x4fa7*/
  Assert_9(i_1, *(_QWORD *)((char *)Device->FormEntry + 54), 0x14u); /*0x4fba*/
  Assert_9(i, *(_QWORD *)((char *)Device->FormEntry + 62), 0x28u); /*0x4fd5*/
  Length = StrLenA(i_1); /*0x4fdf*/
  *((_BYTE *)Device->FormEntry + 82) = sub_A3B4(i_1, Length); /*0x4fff*/
  v16 = (RST_FORM_ENTRY *)(*(__int64 (__fastcall **)(uint8_t *, void *, _QWORD, void *))(qword_58070 + 128))( /*0x5020*/
                            &Device->reserved_090[40],
                            &unk_278D0,
                            0,
                            Device->FormEntry);
  if ( (__int64)v16 < 0 ) /*0x5026*/
  {
    v17 = StrLen(*(const CHAR16 **)((char *)Device->FormEntry + 62)); /*0x5033*/
    MemZeroThenFree(*(_BYTE **)((char *)Device->FormEntry + 62), v17); /*0x5046*/
    v18 = StrLen(*(const CHAR16 **)((char *)Device->FormEntry + 54)); /*0x5056*/
    MemZeroThenFree(*(_BYTE **)((char *)Device->FormEntry + 54), v18); /*0x5069*/
    MemZeroThenFree((_BYTE *)Device->FormEntry, 116); /*0x5078*/
    Device->FormEntry = 0; /*0x507d*/
  }
  return v16; /*0x5095*/
}

// Function: RstReturnFail @ 0x5164 (0x8 bytes)
// Index: 111/906

__int64 __fastcall RstReturnFail(__int64 a1)
{
  return *(_QWORD *)(a1 + 360); /*0x516b*/
}

// Function: RstReturnInvalid @ 0x516c (0x8 bytes)
// Index: 112/906

void __fastcall RstReturnInvalid(__int64 a1, __int64 a2)
{
  *(_QWORD *)(a1 + 192) = a2; /*0x516c*/
}

// Function: RstCheckCondition @ 0x5174 (0x38 bytes)
// Index: 113/906

__int64 __fastcall RstCheckCondition(__int64 *a1)
{
  __int64 result; // rax

  if ( a1[78] ) /*0x517a*/
  {
    result = HiiLibFindString(a1[2], a1[23], (__int64)&unk_278F0); /*0x5199*/
    a1[78] = 0; /*0x519e*/
  }
  return result; /*0x51a6*/
}

// Function: RstReadWriteConfig @ 0x528c (0xd3 bytes)
// Index: 117/906

__int64 __fastcall RstReadWriteConfig(__int64 a1, int a2, __int64 a3, unsigned __int64 a4, __int64 a5)
{
  __int64 v5; // rsi
  __int64 v6; // r12
  __int64 v8; // rbx

  v5 = *(_QWORD *)(a1 + 200); /*0x52a5*/
  v6 = *(_QWORD *)(v5 + 8); /*0x52b4*/
  v8 = 0x8000000000000003uLL; /*0x52bd*/
  if ( !a5 || a4 / *(unsigned int *)(v6 + 12) + a3 - 1 > *(_QWORD *)(v6 + 24) ) /*0x52e3*/
    return 0x8000000000000002uLL; /*0x533a*/
  if ( !a4 ) /*0x52e8*/
    return 0; /*0x52ea*/
  if ( a4 % *(unsigned int *)(v6 + 12) ) /*0x52d6*/
    return 0x8000000000000004uLL; /*0x52f3*/
  if ( v5 ) /*0x5302*/
  {
    if ( a2 ) /*0x5313*/
    {
      v8 = (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, unsigned __int64, __int64))(v5 + 32))(v5, 0, a3, a4, a5); /*0x5320*/
      if ( v8 >= 0 ) /*0x5326*/
        (*(void (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 200) + 40LL))(*(_QWORD *)(a1 + 200)); /*0x5332*/
    }
    else
    {
      return (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, unsigned __int64, __int64))(v5 + 24))( /*0x5318*/
               v5,
               0,
               a3,
               a4,
               a5);
    }
  }
  return v8; /*0x5358*/
}

// Function: RstConfigRead @ 0x5360 (0x2a bytes)
// Index: 118/906

__int64 __fastcall RstConfigRead(__int64 a1)
{
  __int64 result; // rax

  result = 0x8000000000000003uLL; /*0x536c*/
  if ( *(_QWORD *)(a1 + 200) ) /*0x5364*/
    return (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 200) + 16LL))(*(_QWORD *)(a1 + 200)); /*0x5382*/
  return result; /*0x5385*/
}

// Function: RstConfigWrite @ 0x538c (0x1e bytes)
// Index: 119/906

__int64 __fastcall RstConfigWrite(__int64 a1, __int64 a2, unsigned __int64 a3, __int64 a4)
{
  return RstReadWriteConfig(a1, 1, a2, a3, a4); /*0x53a5*/
}

// Function: RstConfigReadVar @ 0x53ac (0x1b bytes)
// Index: 120/906

__int64 __fastcall RstConfigReadVar(__int64 a1, __int64 a2, unsigned __int64 a3, __int64 a4)
{
  return RstReadWriteConfig(a1, 0, a2, a3, a4); /*0x53c2*/
}

// Function: RstValidate @ 0x5504 (0x4a bytes)
// Index: 126/906

unsigned __int64 __fastcall RstValidate(__int64 a1, __int64 a2, CHAR16 *i, unsigned __int64 n0x14)
{
  if ( !a2 || !i || n0x14 <= 0x14 ) /*0x551b*/
    return 0x8000000000000002uLL; /*0x553f*/
  RstStringTrimCopy(i, n0x14, (const CHAR16 *)(a1 + 236), 0x14u); /*0x5536*/
  return 0; /*0x5549*/
}

// Function: RstCheckSecureBoot @ 0x5550 (0x86 bytes)
// Index: 127/906

char __fastcall RstCheckSecureBoot(__int64 a1, int n5)
{
  __int64 v4; // rax
  char v5; // bl
  int n5_1; // eax
  __int64 v8; // [rsp+30h] [rbp+8h] BYREF
  __int64 v9; // [rsp+40h] [rbp+18h] BYREF

  v4 = sub_2DB8(*(_QWORD *)(a1 + 184)); /*0x556b*/
  v5 = 0; /*0x5570*/
  if ( !v4 ) /*0x5575*/
    return 0; /*0x5575*/
  v8 = v4; /*0x5577*/
  if ( (*(__int64 (__fastcall **)(void *, __int64 *, __int64 *))(qword_58070 + 184))(&unk_27890, &v8, &v9) < 0 || !v9 ) /*0x55a7*/
    return 0; /*0x55c4*/
  n5_1 = HiiLibFreeStringArray(*(_QWORD *)(a1 + 16), v9); /*0x55ad*/
  if ( !n5_1 || !n5 || n5_1 == n5 ) /*0x55bc*/
    return 1; /*0x55be*/
  return v5; /*0x55d0*/
}

// Function: RstReturnSuccess @ 0x55d8 (0x10 bytes)
// Index: 128/906

__int64 __fastcall RstReturnSuccess(_QWORD *NewContext)
{
  return HiiLibGetAllStrings(NewContext[2], NewContext[23]);
}

// Function: RstStringAllocCopy @ 0x55e8 (0x2f bytes)
// Index: 129/906

_QWORD *__fastcall RstStringAllocCopy(_QWORD *a1, char a2)
{
  CfgArrayGetBlock(a1); /*0x55f7*/
  if ( (a2 & 1) != 0 ) /*0x55ff*/
    MemFree(); /*0x5604*/
  return a1; /*0x5611*/
}

// Function: RsteDeviceAlloc @ 0x5618 (0x1fd bytes)
// Index: 130/906

void *__fastcall RsteDeviceAlloc(RST_DEVICE *Device)
{
  __int64 v1; // rdx
  void *v3; // rbx
  __int64 (__fastcall **NameString_1)(_QWORD, uint8_t *, int *); // rcx
  __int64 v5; // rbx
  int n512; // eax
  uint32_t BlockSize; // r8d
  char v8; // al
  unsigned __int64 v9; // rcx
  __int64 v10; // rax
  uint64_t LastBlock; // rcx
  uint64_t PhysicalSectorSize; // rax
  int n151; // [rsp+30h] [rbp+8h] BYREF
  __int64 (__fastcall **NameString)(_QWORD, uint8_t *, int *); // [rsp+38h] [rbp+10h] BYREF

  v1 = *(_QWORD *)&Device->reserved_090[40]; /*0x5622*/
  v3 = (void *)0x8000000000000006LL; /*0x562c*/
  if ( v1 ) /*0x5639*/
  {
    if ( HiiLibGetStringId((RST_PRIVATE_DATA *)Device->StringTable, v1, (__int64)&unk_278B0, (__int64)&NameString) ) /*0x564f*/
      return (void *)0x800000000000000ELL; /*0x564f*/
    if ( !NameString ) /*0x5662*/
      return (void *)0x800000000000000ELL; /*0x5662*/
    n151 = 151; /*0x5677*/
    MemZero(&Device->reserved_090[64], 0, 151); /*0x567c*/
    NameString_1 = NameString; /*0x5692*/
    *(_DWORD *)&Device->reserved_090[64] = 1381192805; /*0x5695*/
    *(_DWORD *)&Device->reserved_090[68] = 2; /*0x569f*/
    v5 = (*NameString_1)(NameString_1, &Device->reserved_090[64], &n151); /*0x56bd*/
    HiiLibFindString((RST_PRIVATE_DATA *)Device->StringTable, *(_QWORD *)&Device->reserved_090[40], (__int64)&unk_278B0); /*0x56c0*/
    if ( v5 < 0 ) /*0x56c8*/
      return (void *)0x800000000000000ELL; /*0x56c8*/
    n512 = *(_DWORD *)&Device->reserved_090[72]; /*0x56ce*/
    if ( n512 != 512 && n512 != 4096 ) /*0x56e0*/
      return (void *)0x800000000000000ELL; /*0x56e0*/
    if ( !HiiLibGetStringId( /*0x570d*/
            (RST_PRIVATE_DATA *)Device->StringTable,
            *(_QWORD *)&Device->reserved_090[40],
            (__int64)&unk_278A0,
            (__int64)&Device->reserved_090[56])
      && *(_QWORD *)&Device->reserved_090[56] )
    {
      BlockSize = *(_DWORD *)&Device->reserved_090[72]; /*0x5720*/
      v8 = Device->reserved_090[211] >> 2; /*0x572e*/
      v3 = 0; /*0x5731*/
      v9 = (unsigned __int64)*(unsigned __int16 *)&Device->reserved_090[80] << 32; /*0x5733*/
      Device->Flags = 0; /*0x5737*/
      Device->BitfieldBytes[0] = v8 & 1; /*0x573e*/
      v10 = *(unsigned int *)&Device->reserved_090[82]; /*0x5741*/
      Device->BitfieldBytes[1] = 1; /*0x5747*/
      LastBlock = v9 + v10 - 1; /*0x574b*/
      PhysicalSectorSize = *(unsigned int *)&Device->reserved_090[86]; /*0x5750*/
      Device->BitfieldBytes[2] = 0; /*0x5756*/
      Device->PhysicalSectorSize = PhysicalSectorSize; /*0x5759*/
      LODWORD(PhysicalSectorSize) = *(_DWORD *)&Device->reserved_090[76]; /*0x575d*/
      Device->BitfieldBytes[3] = 0; /*0x5763*/
      Device->BitfieldBytes[4] = 0; /*0x5769*/
      Device->BlockSize = BlockSize; /*0x576c*/
      Device->MediaId = 4; /*0x5770*/
      Device->LastBlock = LastBlock; /*0x5777*/
      Device->LogicalBlocksPerPhysical = (unsigned int)PhysicalSectorSize / BlockSize; /*0x577b*/
      if ( RstDebugEnabled() && *(_DWORD *)&Device->reserved_090[76] % *(_DWORD *)&Device->reserved_090[72] ) /*0x5792*/
        DebugAssert("RsteDevice.cpp", 0xE6u, "( m_idd.PhysicalSectorSize % m_idd.LogicalSectorSize ) == 0"); /*0x57af*/
      if ( RstDebugEnabled() && !Device->LogicalBlocksPerPhysical ) /*0x57bd*/
        DebugAssert("RsteDevice.cpp", 0xE7u, "mBlkMedia.LogicalBlocksPerPhysicalBlock != ( 0 )"); /*0x57d8*/
      HiiLibGetStringId( /*0x57f6*/
        (RST_PRIVATE_DATA *)Device->StringTable,
        *(_QWORD *)&Device->reserved_090[40],
        (__int64)&unk_278F0,
        (__int64)&Device->NameString);
    }
    else
    {
      return (void *)0x800000000000000ELL; /*0x57fd*/
    }
  }
  return v3; /*0x580f*/
}

// Function: RstInstallMultipleProtocols @ 0x5818 (0x5 bytes)
// Index: 131/906

// attributes: thunk
__int64 __fastcall RstInstallMultipleProtocols(__int64 a1)
{
  return RstInstallProtocols(a1);
}

// Function: RstDevicePathGet @ 0x5820 (0xc bytes)
// Index: 132/906

EFI_STATUS __fastcall RstDevicePathGet()
{
  return RstHelper_1114((__int64)&unk_27120);
}

// Function: RstDevicePathUpdate @ 0x582c (0xc bytes)
// Index: 133/906

EFI_STATUS __fastcall RstDevicePathUpdate()
{
  return RstHelper_1308((__int64)&unk_27120);
}

// Function: RstInstallClass @ 0x5838 (0x64 bytes)
// Index: 134/906

RST_LIST_ENTRY *__fastcall RstInstallClass(RST_PRIVATE_DATA *Private, void *Context)
{
  _QWORD *Vtable_1; // rax
  void *Vtable; // r11
  _QWORD *v7; // rax

  Vtable_1 = (_QWORD *)MemAlloc(24); /*0x5854*/
  Vtable = Vtable_1; /*0x5859*/
  if ( !Vtable_1 ) /*0x585f*/
    return (RST_LIST_ENTRY *)0xFFFFFFFFLL; /*0x5861*/
  *Vtable_1 = 0; /*0x5866*/
  Vtable_1[2] = Context; /*0x586a*/
  Vtable_1[1] = *(_QWORD *)&Private->Version; /*0x5872*/
  v7 = *(_QWORD **)&Private->Version; /*0x5876*/
  if ( v7 ) /*0x587d*/
    *v7 = Vtable; /*0x587f*/
  if ( !Private->Vtable ) /*0x5882*/
    Private->Vtable = Vtable; /*0x5888*/
  *(_QWORD *)&Private->Version = Vtable; /*0x588b*/
  return 0; /*0x5896*/
}

// Function: RstReturnOne @ 0x589c (0xb bytes)
// Index: 135/906

unsigned __int64 RstReturnOne()
{
  return 0x8000000000000003uLL; /*0x58a6*/
}

// Function: RstReturnThree @ 0x58a8 (0x7 bytes)
// Index: 136/906

__int64 __fastcall RstReturnThree(__int64 a1)
{
  return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 40LL))(a1);
}

// Function: RstCreateClass @ 0x58b0 (0x77 bytes)
// Index: 137/906

__int64 __fastcall RstCreateClass(__int64 a1, __int64 a2, RST_PRIVATE_DATA *Private)
{
  *(_QWORD *)(a1 + 8) = a2; /*0x58b6*/
  *(_BYTE *)(a1 + 16) = 0; /*0x58ba*/
  *(_QWORD *)a1 = off_232D0; /*0x58c5*/
  *(_QWORD *)(a1 + 24) = 0; /*0x58c8*/
  *(_QWORD *)(a1 + 32) = 0; /*0x58cd*/
  *(_QWORD *)(a1 + 40) = 0; /*0x58d2*/
  *(_QWORD *)(a1 + 48) = Private; /*0x58df*/
  *(_WORD *)(a1 + 56) = 256; /*0x58e3*/
  sub_7D30((_QWORD *)(a1 + 72), a1); /*0x58ee*/
  *(_DWORD *)(a1 + 104) = 0; /*0x58f3*/
  *(_DWORD *)(a1 + 108) = 0; /*0x58f7*/
  *(_QWORD *)(a1 + 112) = 0; /*0x58fb*/
  *(_QWORD *)(a1 + 120) = 0; /*0x5900*/
  *(_QWORD *)(a1 + 128) = 0; /*0x5905*/
  *(_BYTE *)(a1 + 136) = 0; /*0x5914*/
  *(_QWORD *)a1 = off_23320; /*0x591e*/
  return a1; /*0x5921*/
}

// Function: RstUefiProtocolInstall @ 0x5928 (0x73 bytes)
// Index: 138/906

EFI_STATUS __fastcall RstUefiProtocolInstall(RST_PRIVATE_DATA *Private)
{
  void (__fastcall ***Class)(void *, _QWORD); // rbx
  __int64 v3; // rax

  Class = 0; /*0x593f*/
  if ( !RstCheckAlreadyStarted((__int64)Private, 0, 0) ) /*0x593a*/
  {
    v3 = MemAlloc(144); /*0x5952*/
    if ( v3 ) /*0x595a*/
      Class = (void (__fastcall ***)(void *, _QWORD))RstCreateClass(v3, 0, (__int64)Private); /*0x5969*/
    RstInstallClass((RST_PRIVATE_DATA *)&Private->Private_, Class); /*0x5976*/
    (**Class)(Class, 0); /*0x5983*/
  }
  return 0x8000000000000003uLL; /*0x5995*/
}

// Function: RstHelper_599c @ 0x599c (0xf bytes)
// Index: 139/906

char __fastcall RstHelper_599c(__int64 a1, _QWORD *a2)
{
  if ( !a2 ) /*0x599f*/
  {
    while ( 1 ) /*0x59a1*/
      ; /*0x59a1*/
  }
  return RstUefiProtocolGuid(a2);
}

// Function: RstUefiProtocolEntry @ 0x59ac (0x4f bytes)
// Index: 140/906

__int64 __fastcall RstUefiProtocolEntry(__int64 a1)
{
  __int64 v2; // rbx

  v2 = RstHiiPackageInstall(a1); /*0x59be*/
  if ( v2 >= 0 ) /*0x59c4*/
    HiiCreateEventEx((__int64)&dword_278C0, 8, (__int64)RstHelper_599c, a1, a1 + 728); /*0x59e8*/
  return v2; /*0x59f5*/
}

// Function: RstHelper_59fc @ 0x59fc (0x22 bytes)
// Index: 141/906

__int64 __fastcall sub_59FC(__int64 a1)
{
  __int64 v1; // rcx

  v1 = *(_QWORD *)(a1 + 704); /*0x5a00*/
  if ( v1 ) /*0x5a0a*/
    return HiiLibReturnZero(*(_QWORD *)(v1 + 16)); /*0x5a10*/
  else
    return 0; /*0x5a17*/
}

// Function: RstHelper_5a44 @ 0x5a44 (0x22 bytes)
// Index: 143/906

__int64 __fastcall sub_5A44(__int64 a1, unsigned int a2)
{
  __int64 v2; // rcx

  v2 = *(_QWORD *)(a1 + 704); /*0x5a48*/
  if ( v2 ) /*0x5a52*/
    return HiiLibReturnOne(*(_QWORD *)(v2 + 16), a2); /*0x5a58*/
  else
    return 0; /*0x5a5f*/
}

// Function: RstHelper_5a68 @ 0x5a68 (0x22 bytes)
// Index: 144/906

__int64 __fastcall sub_5A68(__int64 a1, unsigned int a2)
{
  __int64 v2; // rcx

  v2 = *(_QWORD *)(a1 + 704); /*0x5a6c*/
  if ( v2 ) /*0x5a76*/
    return HiiLibReturnFalse(*(_QWORD *)(v2 + 16), a2); /*0x5a7c*/
  else
    return 0; /*0x5a83*/
}

// Function: RstHelper_5a8c @ 0x5a8c (0x22 bytes)
// Index: 145/906

__int64 __fastcall RstHelper_5a8c(__int64 a1, unsigned int a2, const char *en)
{
  __int64 v3; // rcx

  v3 = *(_QWORD *)(a1 + 704); /*0x5a90*/
  if ( v3 ) /*0x5a9a*/
    return HiiLibGetStringFromPackage(*(_QWORD *)(v3 + 16), a2, (__int64)en); /*0x5aa0*/
  else
    return 0; /*0x5aa7*/
}

// Function: RstProtocolEfiCall @ 0x5ab0 (0xd bytes)
// Index: 146/906

__int64 __fastcall RstProtocolEfiCall(__int64 a1)
{
  return (**(__int64 (__fastcall ***)(__int64))(a1 - 520))(a1 - 520);
}

// Function: RstProtocolEfiCall2 @ 0x5ac0 (0x31 bytes)
// Index: 147/906

__int64 __fastcall RstProtocolEfiCall2(__int64 a1, __int64 a2, __int64 a3)
{
  if ( a1 && a2 && a3 ) /*0x5ad1*/
    return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(a1 - 568) + 8LL))(a1 - 568); /*0x5add*/
  else
    return 0x8000000000000002uLL; /*0x5ae2*/
}

// Function: RstProtocolEfiCall3 @ 0x5af4 (0x31 bytes)
// Index: 148/906

__int64 __fastcall RstProtocolEfiCall3(__int64 a1, __int64 a2, __int64 a3)
{
  if ( a1 && a2 && a3 ) /*0x5b05*/
    return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(a1 - 592) + 8LL))(a1 - 592); /*0x5b11*/
  else
    return 0x8000000000000002uLL; /*0x5b16*/
}

// Function: RstInstallProtocols @ 0x5b28 (0x84 bytes)
// Index: 149/906

__int64 __fastcall RstInstallProtocols(__int64 a1)
{
  return (*(__int64 (__fastcall **)(_QWORD, void *, __int64, void *, __int64, void *, __int64, void *, __int64, void *, __int64, _QWORD))(qword_58070 + 336))( /*0x5ba7*/
           *(_QWORD *)(a1 + 624),
           &unk_27740,
           a1 + 520,
           &unk_27770,
           a1 + 568,
           &unk_27760,
           a1 + 592,
           &unk_27820,
           a1 + 616,
           &unk_27900,
           a1 + 8,
           0);
}

// Function: RstHiiPackageInstall @ 0x5bac (0x84 bytes)
// Index: 150/906

__int64 __fastcall RstHiiPackageInstall(__int64 a1)
{
  __int64 result; // rax

  result = (*(__int64 (__fastcall **)(__int64, void *, __int64, void *, __int64, void *, __int64, void *, __int64, _QWORD))(qword_58070 + 328))( /*0x5c16*/
             a1 + 624,
             &unk_27740,
             a1 + 520,
             &unk_27770,
             a1 + 568,
             &unk_27760,
             a1 + 592,
             &unk_27820,
             a1 + 616,
             0);
  if ( result >= 0 ) /*0x5c1f*/
    return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 56LL))(a1); /*0x5c27*/
  return result; /*0x5c2a*/
}

// Function: RstGetVariableUefi @ 0x5c30 (0x37 bytes)
// Index: 151/906

__int64 __fastcall RstGetVariableUefi(RST_PRIVATE_DATA *Private, __int16 *RstUefiV)
{
  sub_9368(); /*0x5c39*/
  return (*(__int64 (__fastcall **)(__int16 *, void *, __int64))(RuntimeServices + 88))(RstUefiV, &unk_27178, 6); /*0x5c61*/
}

// Function: RstGetRaidVariable @ 0x5c68 (0xab bytes)
// Index: 152/906

__int64 __fastcall RstGetRaidVariable(RST_PRIVATE_DATA *Private, __int16 *VrocHwKeyId)
{
  __int64 v2; // rbx
  _BYTE *v5; // rdi

  v2 = 0; /*0x5c7c*/
  if ( !VrocHwKeyId ) /*0x5c84*/
    return 0x8000000000000002uLL; /*0x5c86*/
  v5 = (_BYTE *)MemAllocPages(7); /*0x5c9f*/
  if ( v5 ) /*0x5ca5*/
  {
    if ( !sub_96B8() ) /*0x5cc0*/
      v2 = (*(__int64 (__fastcall **)(__int16 *, void *, __int64, __int64, _BYTE *))(RuntimeServices + 88))( /*0x5ced*/
             VrocHwKeyId,
             &unk_27178,
             6,
             6,
             v5);
    MemZeroThenFree(v5, 7); /*0x5cf6*/
    return v2; /*0x5cfb*/
  }
  else
  {
    MemZeroThenFree(0, 7); /*0x5cac*/
    return 0x8000000000000009uLL; /*0x5cb1*/
  }
}

// Function: RstParseRaidVariable @ 0x5d14 (0x1fc bytes)
// Index: 153/906

EFI_STATUS __fastcall RstParseRaidVariable(RST_PRIVATE_DATA *Private)
{
  const __m128i *v1; // rdx
  CHAR16 *Source_2; // r8
  CHAR16 *Source; // r13
  const __m128i *v5; // r14
  signed __int64 RaidVariable; // rbx
  __int64 i; // rdi
  unsigned __int16 Length; // ax
  __m128i v9; // xmm5
  const CHAR16 *Source_1; // rax
  __int64 v11; // r8
  __int64 (__fastcall **v12)(void *, __int64, _QWORD, __int64, void **); // r11
  void (__fastcall **DeviceListHead)(void *); // rax
  __int64 (__fastcall **v14)(void *, __int64); // rax

  Private->field_2A8 = 0; /*0x5d31*/
  Private->DeviceListHead = 0; /*0x5d39*/
  Source = Source_2; /*0x5d48*/
  v5 = v1; /*0x5d55*/
  if ( (*(__int64 (__fastcall **)(void *, _QWORD, void **))(qword_58070 + 320))(&unk_27880, 0, &Private->field_2A8) >= 0 /*0x5d9f*/
    && Private->field_2A8
    || (RaidVariable = (*(__int64 (__fastcall **)(void *, _QWORD, void **))(qword_58070 + 320))(
                         &unk_277E0,
                         0,
                         &Private->DeviceListHead),
        RaidVariable >= 0)
    && Private->DeviceListHead )
  {
    i = MemAllocPages(92); /*0x5dc2*/
    MemZero((_BYTE *)i, 0, 92); /*0x5dc5*/
    *(_DWORD *)i = 1229342037; /*0x5dd9*/
    *(_DWORD *)(i + 4) = 92; /*0x5ddf*/
    *(_BYTE *)(i + 8) = 1; /*0x5de2*/
    StrnCpy((CHAR16 *)(i + 10), "INTEL", 5u); /*0x5de6*/
    Length = StrLenA(Source); /*0x5dee*/
    StrnCpy((CHAR16 *)(i + 16), Source, Length); /*0x5dfe*/
    v9 = _mm_loadu_si128(v5); /*0x5e06*/
    *(_WORD *)(i + 52) = 54; /*0x5e0b*/
    *(__m128i *)(i + 36) = v9; /*0x5e0f*/
    Source_1 = (const CHAR16 *)sub_9368(); /*0x5e14*/
    StrnCpy((CHAR16 *)(i + 54), Source_1, 0x26u); /*0x5e24*/
    v12 = (__int64 (__fastcall **)(void *, __int64, _QWORD, __int64, void **))Private->field_2A8; /*0x5e29*/
    if ( v12 ) /*0x5e37*/
    {
      LOBYTE(v11) = 1; /*0x5e43*/
      RaidVariable = v12[1](Private->field_2A8, i, v11, 14, &Private->DeviceListTail); /*0x5e55*/
    }
    else
    {
      DeviceListHead = (void (__fastcall **)(void *))Private->DeviceListHead; /*0x5e5a*/
      if ( DeviceListHead ) /*0x5e64*/
      {
        if ( Private->DeviceListTail ) /*0x5e66*/
          DeviceListHead[1](Private->DeviceListHead); /*0x5e75*/
        (*(void (__fastcall **)(void *, __int64, __int64, void **))Private->DeviceListHead)( /*0x5e92*/
          Private->DeviceListHead,
          i,
          92,
          &Private->DeviceListTail);
        RstGetVariableUefi((__int64)Private, L"RstUefiV"); /*0x5e9e*/
        RaidVariable = RstGetRaidVariable((__int64)Private, L"VrocHwKeyId"); /*0x5eb2*/
      }
      else
      {
        RaidVariable = 0x800000000000000EuLL; /*0x5eb7*/
      }
    }
    if ( RaidVariable >= 0 ) /*0x5ec9*/
    {
      v14 = (__int64 (__fastcall **)(void *, __int64))Private->field_2A8; /*0x5ecb*/
      if ( v14 ) /*0x5ed5*/
        RaidVariable = v14[2](Private->field_2A8, 14); /*0x5ee0*/
    }
    MemZeroThenFree((_BYTE *)i, 92); /*0x5ee9*/
  }
  return RaidVariable; /*0x5f05*/
}

// Function: RstInstallHiiConfigAccess @ 0x5f10 (0x35 bytes)
// Index: 154/906

__int64 __fastcall RstInstallHiiConfigAccess(RST_PRIVATE_DATA *Private, char *VROC)
{
  Private->HiiLibFunctions[0] = VROC; /*0x5f1a*/
  return (*(__int64 (__fastcall **)(void **, void *, uint32_t *, _QWORD, _QWORD))(qword_58070 + 328))( /*0x5f40*/
           &Private->ImageHandle,
           &unk_27900,
           &Private->Version,
           0,
           0);
}

// Function: RstSetVariableUefi @ 0x5f48 (0x41 bytes)
// Index: 155/906

__int64 __fastcall RstSetVariableUefi(RST_PRIVATE_DATA *Private, wchar_t *RstUefiF)
{
  return (*(__int64 (__fastcall **)(wchar_t *, void *, __int64))(RuntimeServices + 88))(RstUefiF, &unk_27178, 2); /*0x5f84*/
}

// Function: RstDriverBindingStart @ 0x5fe0 (0xf bytes)
// Index: 157/906

EFI_STATUS __fastcall RstDriverBindingStart(RST_PRIVATE_DATA *Private)
{
  _BYTE *v1; // rdx
  _QWORD *v2; // r8

  return RstParseUnicodeString(v1, &i_, v2);
}
/* Orphan comments:
"en-US"
*/

// Function: RstMainDispatch @ 0x5ff0 (0x41 bytes)
// Index: 158/906

__int64 __fastcall RstMainDispatch(_QWORD *a1)
{
  __int64 **i; // rbx
  __int64 result; // rax

  for ( i = (__int64 **)a1[88]; i; i = (__int64 **)*i ) /*0x5ffa*/
  {
    result = (*(__int64 (__fastcall **)(__int64 *))(*i[2] + 40))(i[2]); /*0x600d*/
    if ( result < 0 ) /*0x6013*/
      return result; /*0x6013*/
  }
  return (*(__int64 (__fastcall **)(_QWORD *))(*a1 + 24LL))(a1); /*0x602b*/
}

// Function: RstCheckAlreadyStarted @ 0x6034 (0x55 bytes)
// Index: 159/906

__int64 __fastcall RstCheckAlreadyStarted(RST_PRIVATE_DATA *Private, __int64 a2, char a3)
{
  _QWORD *Private_; // rax
  __int64 v5; // rbx
  _QWORD *p_i; // [rsp+30h] [rbp+8h] BYREF

  Private_ = Private->Private_; /*0x6041*/
  if ( !Private_ ) /*0x6047*/
    return 0; /*0x6049*/
  p_i = Private->Private_; /*0x604d*/
  while ( *(_QWORD *)(Private_[2] + 8LL) != a2 ) /*0x605a*/
  {
    Private_ = (_QWORD *)*Private_; /*0x605c*/
    p_i = Private_; /*0x605f*/
    if ( !Private_ ) /*0x6067*/
      return 0; /*0x6067*/
  }
  v5 = Private_[2]; /*0x606b*/
  if ( a3 ) /*0x6071*/
    RstInstallConfigAccess(&Private->Private_, &p_i); /*0x607b*/
  return v5; /*0x6083*/
}

// Function: RstFindDriverByHandle @ 0x608c (0x3c bytes)
// Index: 160/906

_QWORD *__fastcall RstFindDriverByHandle(__int64 a1, __int64 a2)
{
  _QWORD *i; // rbx
  _QWORD *result; // rax

  for ( i = *(_QWORD **)(a1 + 704); i; i = (_QWORD *)*i ) /*0x6096*/
  {
    result = RstConfigAccessCallback(i[2], a2); /*0x60a9*/
    if ( result ) /*0x60b1*/
      return result; /*0x60b1*/
  }
  return 0; /*0x60c2*/
}

// Function: RstUefiProtocolGuid @ 0x60c8 (0xbd bytes)
// Index: 161/906

EFI_STATUS __fastcall RstUefiProtocolGuid(RST_PRIVATE_DATA *Private)
{
  __int64 **i; // rbx
  char v3; // di
  __int64 **v4; // rbx
  char v5; // al
  EFI_STATUS result; // rax
  __int64 **j; // rbx

  MemZero(Private->GuidProtocolArea, 0, 48); /*0x60e2*/
  for ( i = (__int64 **)qword_35418[88]; i; i = (__int64 **)*i ) /*0x60ee*/
    (*(void (__fastcall **)(__int64 *))(*i[2] + 48))(i[2]); /*0x60fe*/
  sub_A750(); /*0x6109*/
  RstParseRaidVariable(Private); /*0x611f*/
  v3 = 1; /*0x612b*/
  v4 = (__int64 **)qword_35418[88]; /*0x612e*/
  while ( v4 )
  {
    v5 = (*(__int64 (__fastcall **)(__int64 *))(*v4[2] + 56))(v4[2]); /*0x613e*/
    v4 = (__int64 **)*v4; /*0x6141*/
    v3 = v5 != 0 ? v3 : 0;
  }
  sub_A278(); /*0x6150*/
  for ( j = (__int64 **)qword_35418[88]; j; j = (__int64 **)*j ) /*0x615c*/
    result = (*(__int64 (__fastcall **)(__int64 *))(*j[2] + 64))(j[2]); /*0x616c*/
  LOBYTE(result) = v3; /*0x6177*/
  return result; /*0x617f*/
}

// Function: RstComponentNameGetDriverName @ 0x6188 (0x6e bytes)
// Index: 162/906

__int64 __fastcall RstComponentNameGetDriverName(__int64 a1, __int64 a2, __int64 a3)
{
  __int64 v3; // rdi
  __int64 (__fastcall ***v6)(_QWORD, __int64); // rax
  _QWORD *DriverByHandle; // rax

  v3 = a1 - 520; /*0x6197*/
  v6 = (__int64 (__fastcall ***)(_QWORD, __int64))RstCheckAlreadyStarted(a1 - 520, a2, 0); /*0x61aa*/
  if ( v6 ) /*0x61b5*/
    return (**v6)(v6, a3); /*0x61e4*/
  DriverByHandle = RstFindDriverByHandle(v3, a2); /*0x61bd*/
  if ( DriverByHandle ) /*0x61c8*/
    return (*(__int64 (__fastcall **)(_QWORD *))(*DriverByHandle + 8LL))(DriverByHandle); /*0x61d9*/
  else
    return 0x8000000000000003uLL; /*0x61ca*/
}

// Function: RstComponentNameGetControllerName @ 0x61f8 (0x8b bytes)
// Index: 163/906

__int64 __fastcall RstComponentNameGetControllerName(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
  __int64 v4; // rsi
  __int64 v7; // rbx
  __int64 Context_1; // rax
  void *Context; // rdi

  v4 = a1 - 520; /*0x6211*/
  v7 = 0x8000000000000002uLL; /*0x6228*/
  Context_1 = RstCheckAlreadyStarted((RST_PRIVATE_DATA *)(a1 - 520), a2, a3 == 0); /*0x6232*/
  Context = (void *)Context_1; /*0x6237*/
  if ( Context_1 ) /*0x623d*/
  {
    v7 = (*(__int64 (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)Context_1 + 8LL))(Context_1, a3, a4); /*0x624e*/
    if ( v7 < 0 ) /*0x6254*/
      RstInstallClass((RST_PRIVATE_DATA *)(v4 + 704), Context); /*0x6260*/
  }
  return v7; /*0x627c*/
}

// Function: RstComponentName2GetController @ 0x6284 (0x8b bytes)
// Index: 164/906

__int64 __fastcall RstComponentName2GetController(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
  __int64 result; // rax
  __int64 v8; // rax
  _QWORD *v9; // rax

  result = 0x8000000000000002uLL; /*0x6294*/
  if ( a1 && a4 && a5 && a2 ) /*0x62b3*/
  {
    v8 = RstCheckAlreadyStarted(a1, a2, 0); /*0x62b8*/
    if ( v8 ) /*0x62c3*/
    {
      if ( !a3 ) /*0x62c8*/
        return (*(__int64 (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v8 + 24LL))(v8, a4, a5); /*0x62f8*/
      v9 = RstConfigAccessCallback(v8, a3); /*0x62cd*/
      if ( v9 ) /*0x62d8*/
        return (*(__int64 (__fastcall **)(_QWORD *, __int64, __int64))(*v9 + 64LL))(v9, a4, a5); /*0x62e8*/
    }
    return 0x8000000000000003uLL; /*0x62fa*/
  }
  return result; /*0x6309*/
}

// Function: RstGetLanguage @ 0x6310 (0x3f bytes)
// Index: 165/906

__int64 __fastcall RstGetLanguage(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
  if ( a1 && a4 && a5 && a2 ) /*0x632b*/
    return RstComponentName2GetController(a1 - 568, a2, a3, a4, a5); /*0x6339*/
  else
    return 0x8000000000000002uLL; /*0x6340*/
}

// Function: RstSetLanguage @ 0x6350 (0x3f bytes)
// Index: 166/906

__int64 __fastcall RstSetLanguage(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
  if ( a1 && a4 && a5 && a2 ) /*0x636b*/
    return RstComponentName2GetController(a1 - 592, a2, a3, a4, a5); /*0x6379*/
  else
    return 0x8000000000000002uLL; /*0x6380*/
}

// Function: RstHelper_6390 @ 0x6390 (0xc bytes)
// Index: 167/906

char RstHelper_6390()
{
  return RstUefiProtocolGuid(qword_35418);
}

// Function: RstPrivateDataInit @ 0x639c (0x368 bytes)
// Index: 168/906

__int64 __fastcall RstPrivateDataInit(__int64 a1, EFI_HANDLE ImageHandle)
{
  __int64 v4; // rax
  char *_en_US_; // rax

  *(_QWORD *)a1 = &off_23400; /*0x63b2*/
  *(_QWORD *)(a1 + 704) = 0; /*0x63b5*/
  *(_QWORD *)(a1 + 712) = 0; /*0x63bd*/
  MemZero((_BYTE *)(a1 + 632), 0, 48); /*0x63d3*/
  *(_QWORD *)(a1 + 624) = ImageHandle; /*0x63d8*/
  qword_35418 = (_QWORD *)a1; /*0x63df*/
  *(_QWORD *)(a1 + 696) = 0; /*0x63e6*/
  *(_QWORD *)(a1 + 520) = RstProtocolEfiCall; /*0x63f9*/
  *(_QWORD *)(a1 + 528) = RstComponentNameGetDriverName; /*0x6409*/
  *(_QWORD *)(a1 + 536) = RstComponentNameGetControllerName; /*0x641d*/
  v4 = *(_QWORD *)(a1 + 624); /*0x6424*/
  *(_DWORD *)(a1 + 544) = 11; /*0x642b*/
  *(_QWORD *)(a1 + 552) = v4; /*0x6435*/
  *(_QWORD *)(a1 + 560) = v4; /*0x643c*/
  *(_QWORD *)(a1 + 568) = RstProtocolEfiCall2; /*0x644a*/
  *(_DWORD *)(a1 + 616) = 8; /*0x6458*/
  *(_QWORD *)(a1 + 576) = RstGetLanguage; /*0x6462*/
  _en_US_ = off_27138[0]; // "en-US" /*0x6469*/
  *(_DWORD *)(a1 + 620) = (_DWORD)&loc_20009 + 1; /*0x6470*/
  *(_QWORD *)(a1 + 584) = _en_US_; /*0x647a*/
  *(_QWORD *)(a1 + 592) = RstProtocolEfiCall3; /*0x6488*/
  *(_QWORD *)(a1 + 600) = RstSetLanguage; /*0x6496*/
  *(char **)(a1 + 608) = off_27140[0]; // "eng" /*0x64a4*/
  MemZero((_BYTE *)(a1 + 8), 0, 512); /*0x64ab*/
  *(_QWORD *)(a1 + 24) = sub_A8AC; /*0x64b7*/
  *(_DWORD *)(a1 + 8) = 16; /*0x64c2*/
  *(_QWORD *)(a1 + 32) = Assert_121; /*0x64c9*/
  *(_DWORD *)(a1 + 12) = 512; /*0x64d4*/
  *(_QWORD *)(a1 + 40) = RstHelper_ce6c; /*0x64db*/
  *(_QWORD *)(a1 + 48) = Assert_116; /*0x64e6*/
  *(_QWORD *)(a1 + 56) = sub_B0D8; /*0x64f1*/
  *(_QWORD *)(a1 + 64) = sub_AC48; /*0x64fc*/
  *(_QWORD *)(a1 + 72) = RstHelper_c8a8; /*0x6507*/
  *(_QWORD *)(a1 + 80) = sub_AA5C; /*0x6512*/
  *(_QWORD *)(a1 + 88) = Assert_129; /*0x651d*/
  *(_QWORD *)(a1 + 96) = sub_AF6C; /*0x6528*/
  *(_QWORD *)(a1 + 104) = sub_AF44; /*0x6533*/
  *(_QWORD *)(a1 + 112) = sub_AEC0; /*0x653e*/
  *(_QWORD *)(a1 + 120) = sub_AC84; /*0x6549*/
  *(_QWORD *)(a1 + 128) = Assert_24; /*0x6554*/
  *(_QWORD *)(a1 + 136) = sub_D600; /*0x6562*/
  *(_QWORD *)(a1 + 144) = sub_D6CC; /*0x6570*/
  *(_QWORD *)(a1 + 152) = sub_D764; /*0x657e*/
  *(_QWORD *)(a1 + 168) = RstHelper_be04; /*0x658c*/
  *(_QWORD *)(a1 + 176) = sub_DAAC; /*0x659a*/
  *(_QWORD *)(a1 + 184) = sub_DB88; /*0x65a8*/
  *(_QWORD *)(a1 + 192) = sub_A898; /*0x65b6*/
  *(_QWORD *)(a1 + 200) = sub_B0C4; /*0x65c4*/
  *(_QWORD *)(a1 + 208) = sub_AAB8; /*0x65d2*/
  *(_QWORD *)(a1 + 216) = sub_AE2C; /*0x65e0*/
  *(_QWORD *)(a1 + 160) = DxeInstall_3; /*0x65ee*/
  *(_QWORD *)(a1 + 224) = sub_B014; /*0x65fc*/
  *(_QWORD *)(a1 + 232) = sub_B4E4; /*0x660a*/
  *(_QWORD *)(a1 + 240) = sub_B5D8; /*0x6618*/
  *(_QWORD *)(a1 + 248) = sub_B5E0; /*0x6626*/
  *(_QWORD *)(a1 + 256) = sub_BBD4; /*0x6634*/
  *(_QWORD *)(a1 + 488) = Assert_19; /*0x6642*/
  *(_QWORD *)(a1 + 472) = Assert_107; /*0x6650*/
  *(_QWORD *)(a1 + 480) = Assert_29; /*0x665e*/
  *(_QWORD *)(a1 + 496) = sub_BC94; /*0x666c*/
  *(_QWORD *)(a1 + 504) = sub_CAAC; /*0x667a*/
  *(_QWORD *)(a1 + 336) = RstHelper_6390; /*0x6688*/
  *(_QWORD *)(a1 + 424) = j_j_HiiLibGuidIsZero; /*0x6696*/
  *(_QWORD *)(a1 + 432) = j_j_HiiBlockCompare; /*0x66a4*/
  *(_QWORD *)(a1 + 440) = sub_BD68; /*0x66b2*/
  *(_QWORD *)(a1 + 448) = sub_B93C; /*0x66c0*/
  *(_QWORD *)(a1 + 456) = j_j_HiiLibGuidToStr; /*0x66ce*/
  *(_QWORD *)(a1 + 464) = j_j_HiiBlockCompareConst; /*0x66dc*/
  *(_QWORD *)(a1 + 512) = sub_BDB0; /*0x66ea*/
  sub_9370(); /*0x66f1*/
  return a1; /*0x66fe*/
}

// Function: RstHelper_67ec @ 0x67ec (0xf bytes)
// Index: 170/906

unsigned __int64 __fastcall RstHelper_67ec(__int64 a1, _BYTE *a2, _QWORD *a3)
{
  return RstParseUnicodeString(a2, &i__6, a3);
}
/* Orphan comments:
"en-US"
*/

// Function: RstInstallConfigAccess @ 0x67fc (0x34 bytes)
// Index: 171/906

__int64 __fastcall RstInstallConfigAccess(_QWORD *Private, _QWORD **p_i)
{
  _QWORD *i; // r8
  _QWORD *Private_1; // r9
  __int64 v4; // rax

  i = *p_i; /*0x67fc*/
  Private_1 = Private; /*0x67ff*/
  if ( (_QWORD *)*Private != *p_i ) /*0x6808*/
    Private = (_QWORD *)i[1]; /*0x680a*/
  *Private = **p_i; /*0x680e*/
  v4 = i[1]; /*0x6811*/
  if ( (_QWORD *)Private_1[1] == i ) /*0x6819*/
    Private_1[1] = v4; /*0x681b*/
  else
    *(_QWORD *)(*i + 8LL) = v4; /*0x6824*/
  return MemFree();
}

// Function: RstConfigAccessExtract @ 0x6830 (0x13c bytes)
// Index: 172/906

EFI_STATUS __fastcall RstConfigAccessExtract(RST_PRIVATE_DATA *Private)
{
  unsigned __int64 v1; // rdx
  __int64 v2; // r8
  signed __int64 v3; // rdi
  __int64 v4; // r12
  unsigned __int64 v5; // rbp
  void **Private_1; // rsi
  _QWORD *i; // rbx
  __int64 v8; // rax
  _QWORD *v9; // rcx
  void (__fastcall ***v10)(_QWORD, __int64); // rcx
  _QWORD *j; // rbx
  __int64 v12; // rax
  _QWORD *v13; // rcx
  void (__fastcall ***v14)(_QWORD, __int64); // rcx
  _QWORD *p_i; // [rsp+48h] [rbp+10h] BYREF

  v3 = 0; /*0x6842*/
  v4 = v2; /*0x6844*/
  v5 = v1; /*0x6847*/
  if ( v1 ) /*0x684d*/
  {
    if ( v2 ) /*0x6856*/
    {
      Private_1 = &Private->HiiLibFunctions[1]; /*0x6867*/
      for ( i = Private->HiiLibFunctions[1]; ; i = (_QWORD *)*i ) /*0x686b*/
      {
        p_i = i; /*0x68d7*/
        if ( !i ) /*0x68df*/
          break; /*0x68df*/
        if ( (*(unsigned __int8 (__fastcall **)(_QWORD))(*(_QWORD *)i[2] + 104LL))(i[2]) ) /*0x6877*/
        {
          v8 = 0; /*0x687e*/
          if ( v5 ) /*0x6883*/
          {
            v9 = (_QWORD *)i[2]; /*0x6885*/
            while ( *(_QWORD *)(v4 + 8 * v8) != v9[1] ) /*0x6891*/
            {
              if ( ++v8 >= v5 ) /*0x6899*/
                goto LABEL_15; /*0x6899*/
            }
            v3 = (*(__int64 (__fastcall **)(_QWORD *))(*v9 + 16LL))(v9); /*0x68a3*/
            if ( v3 >= 0 ) /*0x68a9*/
            {
              v10 = (void (__fastcall ***)(_QWORD, __int64))i[2]; /*0x68ab*/
              if ( v10 ) /*0x68b2*/
                (**v10)(v10, 1); /*0x68bc*/
              RstInstallConfigAccess(Private_1, &p_i); /*0x68c7*/
              i = *Private_1; /*0x68cc*/
              if ( !*Private_1 ) /*0x68cc*/
                break; /*0x68cc*/
            }
          }
        }
LABEL_15:
        ; /*0x68d4*/
      }
      for ( j = *Private_1; ; j = (_QWORD *)*j ) /*0x68e1*/
      {
        p_i = j; /*0x694c*/
        if ( !j ) /*0x6954*/
          break; /*0x6954*/
        if ( !(*(unsigned __int8 (__fastcall **)(_QWORD))(*(_QWORD *)j[2] + 104LL))(j[2]) ) /*0x68ed*/
        {
          v12 = 0; /*0x68f4*/
          if ( v5 ) /*0x68f9*/
          {
            v13 = (_QWORD *)j[2]; /*0x68fb*/
            while ( *(_QWORD *)(v4 + 8 * v12) != v13[1] ) /*0x6907*/
            {
              if ( ++v12 >= v5 ) /*0x690f*/
                goto LABEL_28; /*0x690f*/
            }
            v3 = (*(__int64 (__fastcall **)(_QWORD *))(*v13 + 16LL))(v13); /*0x6919*/
            if ( v3 >= 0 ) /*0x691f*/
            {
              v14 = (void (__fastcall ***)(_QWORD, __int64))j[2]; /*0x6921*/
              if ( v14 ) /*0x6928*/
                (**v14)(v14, 1); /*0x6932*/
              RstInstallConfigAccess(Private_1, &p_i); /*0x693c*/
              j = *Private_1; /*0x6941*/
              if ( !*Private_1 ) /*0x6941*/
                break; /*0x6941*/
            }
          }
        }
LABEL_28:
        ; /*0x6949*/
      }
    }
    else
    {
      return 0x8000000000000002uLL; /*0x6858*/
    }
  }
  return v3; /*0x6963*/
}

// Function: RstConfigAccessRoute @ 0x696c (0xa7 bytes)
// Index: 173/906

__int64 __fastcall RstConfigAccessRoute(__int64 a1)
{
  _QWORD **v1; // rdi
  __int64 v2; // rsi
  __int64 **i; // rbx
  _QWORD *j; // rbx
  void (__fastcall ***v5)(_QWORD, __int64); // rcx
  _QWORD *p_i; // [rsp+30h] [rbp+8h] BYREF

  v1 = (_QWORD **)(a1 + 24); /*0x697b*/
  v2 = 0; /*0x697f*/
  for ( i = *(__int64 ***)(a1 + 24); i; i = (__int64 **)*i ) /*0x6981*/
  {
    if ( (*(unsigned __int8 (__fastcall **)(__int64 *))(*i[2] + 104))(i[2]) ) /*0x698d*/
      v2 = (*(__int64 (__fastcall **)(__int64 *))(*i[2] + 16))(i[2]); /*0x699e*/
  }
  for ( j = *v1; j; j = (_QWORD *)*j ) /*0x69a9*/
  {
    if ( !(*(unsigned __int8 (__fastcall **)(_QWORD))(*(_QWORD *)j[2] + 104LL))(j[2]) ) /*0x69b5*/
      v2 = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)j[2] + 16LL))(j[2]); /*0x69c6*/
  }
  while ( *v1 ) /*0x69fe*/
  {
    v5 = (void (__fastcall ***)(_QWORD, __int64))(*v1)[2]; /*0x69d3*/
    p_i = *v1; /*0x69d7*/
    if ( v5 ) /*0x69df*/
      (**v5)(v5, 1); /*0x69e9*/
    RstInstallConfigAccess(v1, &p_i); /*0x69f3*/
  }
  return v2; /*0x6a0d*/
}

// Function: RstConfigAccessCallback @ 0x6a14 (0x1e bytes)
// Index: 174/906

_QWORD *__fastcall RstConfigAccessCallback(__int64 a1, __int64 a2)
{
  _QWORD *result; // rax

  for ( result = *(_QWORD **)(a1 + 24); result; result = (_QWORD *)*result ) /*0x6a14*/
  {
    if ( *(_QWORD *)(result[2] + 8LL) == a2 ) /*0x6a22*/
      return (_QWORD *)result[2]; /*0x6a2e*/
  }
  return result; /*0x6a2c*/
}

// Function: RstFormCallbackHandler @ 0x6a34 (0x7d bytes)
// Index: 175/906

__int64 __fastcall RstFormCallbackHandler(__int64 a1, RST_PRIVATE_DATA *Private, __int64 a3)
{
  CfgArrayAllocBlock((_QWORD *)a1, Private); /*0x6a4c*/
  *(_QWORD *)(a1 + 16) = Private; /*0x6a53*/
  *(_WORD *)(a1 + 192) = 0; /*0x6a5c*/
  *(_QWORD *)(a1 + 392) = 0; /*0x6a63*/
  *(_QWORD *)(a1 + 400) = 0; /*0x6a6a*/
  *(_QWORD *)(a1 + 408) = 0; /*0x6a71*/
  *(_BYTE *)(a1 + 433) = 0; /*0x6a78*/
  *(_BYTE *)(a1 + 432) = 0; /*0x6a7e*/
  *(_QWORD *)(a1 + 424) = 0; /*0x6a84*/
  *(_QWORD *)(a1 + 416) = 0; /*0x6a8b*/
  *(_QWORD *)(a1 + 184) = a3; /*0x6a99*/
  *(_QWORD *)a1 = off_23540; /*0x6aa3*/
  return a1; /*0x6aab*/
}

// Function: RstNoop @ 0x6ab4 (0x3 bytes)
// Index: 176/906

char RstNoop()
{
  return 1; /*0x6ab6*/
}

// Function: RstBeginSession @ 0x6ab8 (0x157 bytes)
// Index: 177/906

__int64 __fastcall RstBeginSession(_QWORD *a1)
{
  __int64 v1; // rbp
  __int64 v3; // rcx
  unsigned int v4; // eax
  int v5; // edi
  unsigned __int64 v6; // rbx
  unsigned __int64 v7; // r12
  __int16 v8; // ax
  __int64 v9; // rcx
  CHAR16 *FirstString; // rcx
  _BYTE *v11; // rax
  char i; // [rsp+30h] [rbp-48h] BYREF
  char n23; // [rsp+31h] [rbp-47h]
  int v15; // [rsp+34h] [rbp-44h]
  unsigned __int64 v16; // [rsp+38h] [rbp-40h]

  v1 = 0; /*0x6ad1*/
  if ( !a1[23] || !a1[2] ) /*0x6ae3*/
    return 0x8000000000000007uLL; /*0x6bea*/
  MemZero(&i, 0, 60); /*0x6af7*/
  v3 = a1[23]; /*0x6afc*/
  i = 3; /*0x6b03*/
  v4 = sub_A68C(v3); /*0x6b08*/
  v5 = GuidCompare(v4); /*0x6b1b*/
  v6 = (unsigned __int64)(unsigned __int16)sub_A438(a1[23]) << 32; /*0x6b2c*/
  v7 = v6 | (unsigned int)sub_A4C8(a1[23]); /*0x6b3d*/
  if ( v5 == 1 ) /*0x6b43*/
  {
    i = 3; /*0x6b48*/
    n23 = 23; /*0x6b4d*/
    Assert_57(&i, 0x10u); /*0x6b52*/
    v16 = v7; /*0x6b57*/
    v15 = 1; /*0x6b5c*/
  }
  else
  {
    n23 = 18; /*0x6b67*/
    Assert_57(&i, 0xAu); /*0x6b6c*/
    v8 = sub_A4C8(a1[23]); /*0x6b78*/
    v9 = a1[23]; /*0x6b7d*/
    LOWORD(v15) = v8; /*0x6b84*/
    HIWORD(v15) = 0x8000; /*0x6b8e*/
    LOWORD(v16) = (unsigned __int8)sub_A438(v9); /*0x6b9b*/
  }
  FirstString = *(CHAR16 **)(a1[2] + 40LL); /*0x6ba4*/
  a1[3] = FirstString; /*0x6ba8*/
  if ( FirstString ) /*0x6baf*/
  {
    v11 = Assert_85(FirstString, &i); /*0x6bb6*/
    a1[3] = v11; /*0x6bc6*/
    return (*(__int64 (__fastcall **)(_QWORD *, void *, _BYTE *, _QWORD, _QWORD))(qword_58070 + 328))( /*0x6be2*/
             a1 + 1,
             &unk_27730,
             v11,
             0,
             0);
  }
  return v1; /*0x6c09*/
}

// Function: RsteDeviceInit @ 0x6eac (0x8a bytes)
// Index: 181/906

__int64 __fastcall RsteDeviceInit(_QWORD *a1)
{
  __int64 result; // rax
  __int64 v3; // rdi

  if ( !a1[23] ) /*0x6eb6*/
    return 0x8000000000000002uLL; /*0x6ec3*/
  result = RstBeginSession(a1); /*0x6ecf*/
  if ( result >= 0 ) /*0x6ed7*/
  {
    result = RstDeviceProbe((__int64)a1); /*0x6edc*/
    v3 = result; /*0x6ee1*/
    if ( result >= 0 ) /*0x6ee7*/
    {
      if ( (unsigned int)sub_A4D0(a1[23]) != -1 ) /*0x6ef8*/
        v3 = RstDeviceConfigure((__int64)a1); /*0x6f02*/
      if ( (unsigned int)sub_A4D0(a1[23]) == -1 ) /*0x6f14*/
        sub_A684(a1[23], 0, a1 + 1); /*0x6f23*/
      return v3; /*0x6f28*/
    }
  }
  return result; /*0x6f30*/
}

// Function: RsteDeviceAlloc2 @ 0x6f38 (0xe9 bytes)
// Index: 182/906

unsigned __int64 __fastcall RsteDeviceAlloc2(__int64 a1, __int64 a2, __int64 a3, unsigned __int64 a4, __int64 a5)
{
  __int64 v5; // rbx
  char v7; // r12
  void (__fastcall ***v10)(_QWORD, __int16 *); // rcx
  __int64 v11; // [rsp+20h] [rbp-28h] BYREF
  int v12; // [rsp+28h] [rbp-20h]
  int v13; // [rsp+2Ch] [rbp-1Ch]
  bool v14; // [rsp+30h] [rbp-18h]

  v5 = 0; /*0x6f51*/
  v7 = a2; /*0x6f56*/
  if ( !*(_QWORD *)(a1 + 184) ) /*0x6f5c*/
    return 0x8000000000000007uLL; /*0x6f65*/
  if ( !a5 ) /*0x6f7c*/
    return 0x8000000000000002uLL; /*0x6f7e*/
  if ( !a4 ) /*0x6f8d*/
    return 0x8000000000000004uLL; /*0x6f8f*/
  v11 = a3; /*0x6f9b*/
  if ( (unsigned __int8)RstDebugEnabled(a1, a2) && !*(_DWORD *)(a1 + 100) ) /*0x6fa9*/
    DebugAssert("d:\\qba1\\workspace\\27822\\src\\lib\\efidriver\\BaseDevice.h", 0xD3u, "mBlkMedia.BlockSize != ( 0 )"); /*0x6fc1*/
  v10 = *(void (__fastcall ****)(_QWORD, __int16 *))(a1 + 184); /*0x6fd1*/
  v12 = a4 / *(unsigned int *)(a1 + 100); /*0x6fe0*/
  v13 = a5; /*0x6fe4*/
  v14 = v7 == 0; /*0x6fe8*/
  if ( RstHelper_a454(v10, &v11) ) /*0x6fed*/
    return 0x8000000000000007uLL; /*0x6fff*/
  return v5; /*0x701a*/
}

// Function: RstReturn2 @ 0x7024 (0x1b bytes)
// Index: 183/906

unsigned __int64 __fastcall RstReturn2(__int64 a1, __int64 a2, unsigned __int64 a3, __int64 a4)
{
  __int64 v5; // r8

  v5 = a2; /*0x7030*/
  LOBYTE(a2) = 1; /*0x7033*/
  return RsteDeviceAlloc2(a1, a2, v5, a3, a4); /*0x703a*/
}

// Function: RstReturn2_0 @ 0x7040 (0x1b bytes)
// Index: 184/906

unsigned __int64 __fastcall RstReturn2_0(__int64 a1, __int64 a2, unsigned __int64 a3, __int64 a4)
{
  return RsteDeviceAlloc2(a1, 0, a2, a3, a4); /*0x7056*/
}

// Function: RstReturn0 @ 0x705c (0x6 bytes)
// Index: 185/906

__int64 RstReturn0()
{
  return 1; /*0x7061*/
}

// Function: RstGetVariable @ 0x7064 (0xa4 bytes)
// Index: 186/906

unsigned __int64 __fastcall RstGetVariable(__int64 a1, __int64 a2, _QWORD *a3)
{
  _BYTE *i; // rdi
  const CHAR8 *v6; // rax
  CHAR8 *v7; // rsi
  unsigned int n99; // ebx

  if ( !*(_QWORD *)(a1 + 184) ) /*0x7078*/
    return 0x8000000000000002uLL; /*0x7093*/
  i = (_BYTE *)(a1 + 192); /*0x7095*/
  if ( !*(_WORD *)(a1 + 192) ) /*0x709c*/
  {
    v6 = (const CHAR8 *)sub_A2A4(*(_QWORD *)(a1 + 184)); /*0x70a4*/
    v7 = (CHAR8 *)v6; /*0x70a9*/
    if ( !v6 ) /*0x70af*/
      return 0x8000000000000007uLL; /*0x70bb*/
    n99 = AsciiStrLen(v6); /*0x70c8*/
    if ( n99 > 0x63 ) /*0x70d6*/
      n99 = 99; /*0x70d6*/
    MemZero(i, 0, 200); /*0x70db*/
    sub_872C(i, n99, v7); /*0x70e8*/
  }
  *a3 = i; /*0x70ed*/
  return 0; /*0x7102*/
}

// Function: RstSetVariable @ 0x7108 (0x87 bytes)
// Index: 187/906

__int64 __fastcall RstSetVariable(_QWORD *a1)
{
  if ( !a1[1] || !a1[23] ) /*0x711c*/
    return 0x8000000000000002uLL; /*0x717a*/
  RstDeviceCheck((__int64)a1); /*0x7126*/
  if ( (unsigned int)sub_A4D0(a1[23]) == -1 ) /*0x713a*/
    sub_A684(a1[23], 1, a1 + 1); /*0x714c*/
  sub_7DD0((__int64)a1); /*0x7154*/
  return (*(__int64 (__fastcall **)(_QWORD, void *, _QWORD, _QWORD))(qword_58070 + 336))(a1[1], &unk_27730, a1[3], 0); /*0x7189*/
}

// Function: RstGpioRead @ 0x7190 (0x11c bytes)
// Index: 188/906

__int16 __fastcall RstGpioRead(unsigned __int8 n12)
{
  if ( n12 <= 0xCu ) /*0x7198*/
  {
    if ( n12 == 12 ) /*0x719e*/
      return 53; /*0x722e*/
    if ( n12 > 6u ) /*0x71a7*/
    {
      switch ( n12 ) /*0x71f7*/
      {
        case 7u: /*0x71f7*/
          return 48; /*0x7228*/
        case 8u: /*0x71f7*/
          return 49; /*0x7222*/
        case 9u: /*0x71f7*/
          return 50; /*0x721c*/
        case 0xAu: /*0x71f7*/
          return 51; /*0x7216*/
        case 0xBu: /*0x71f7*/
          return 52; /*0x7210*/
      }
    }
    else
    {
      switch ( n12 ) /*0x71a9*/
      {
        case 6u: /*0x71a9*/
          return 47; /*0x71f3*/
        case 0u: /*0x71a9*/
          return 41; /*0x71ed*/
        case 1u: /*0x71a9*/
          return 42; /*0x71e7*/
        case 2u: /*0x71a9*/
          return 43; /*0x71e1*/
        case 3u: /*0x71a9*/
          return 44; /*0x71db*/
        case 4u: /*0x71a9*/
          return 45; /*0x71d5*/
        case 5u: /*0x71a9*/
          return 46; /*0x71cf*/
      }
    }
    return 0; /*0x71c6*/
  }
  if ( n12 <= 0x12u ) /*0x7232*/
  {
    switch ( n12 ) /*0x7234*/
    {
      case 0x12u: /*0x7234*/
        return 59; /*0x7270*/
      case 0xDu: /*0x7234*/
        return 54; /*0x726a*/
      case 0xEu: /*0x7234*/
        return 55; /*0x7264*/
      case 0xFu: /*0x7234*/
        return 56; /*0x725e*/
      case 0x10u: /*0x7234*/
        return 57; /*0x7258*/
      case 0x11u: /*0x7234*/
        return 58; /*0x7252*/
    }
    return 0; /*0x724d*/
  }
  switch ( n12 ) /*0x7274*/
  {
    case 0x13u: /*0x7274*/
      return 60; /*0x72a6*/
    case 0x14u: /*0x7274*/
      return 61; /*0x72a0*/
    case 0x15u: /*0x7274*/
      return 62; /*0x729a*/
    case 0x16u: /*0x7274*/
      return 63; /*0x7294*/
  }
  if ( n12 != 23 ) /*0x7288*/
    return 0; /*0x728d*/
  return 64; /*0x71cf*/
}

// Function: RstGpioWrite @ 0x72ac (0x240 bytes)
// Index: 189/906

__int16 __fastcall RstGpioWrite(unsigned __int8 n24)
{
  if ( n24 <= 0x18u ) /*0x72b4*/
  {
    if ( n24 == 24 ) /*0x72ba*/
      return 89; /*0x73e2*/
    if ( n24 > 0xCu ) /*0x72c3*/
    {
      if ( n24 > 0x12u ) /*0x7361*/
      {
        switch ( n24 ) /*0x73a7*/
        {
          case 0x13u: /*0x73a7*/
            return 84; /*0x73dc*/
          case 0x14u: /*0x73a7*/
            return 85; /*0x73d6*/
          case 0x15u: /*0x73a7*/
            return 86; /*0x73d0*/
          case 0x16u: /*0x73a7*/
            return 87; /*0x73ca*/
          case 0x17u: /*0x73a7*/
            return 88; /*0x73c4*/
        }
      }
      else
      {
        switch ( n24 ) /*0x7363*/
        {
          case 0x12u: /*0x7363*/
            return 83; /*0x73a3*/
          case 0xDu: /*0x7363*/
            return 78; /*0x739d*/
          case 0xEu: /*0x7363*/
            return 79; /*0x7397*/
          case 0xFu: /*0x7363*/
            return 80; /*0x7391*/
          case 0x10u: /*0x7363*/
            return 81; /*0x738b*/
          case 0x11u: /*0x7363*/
            return 82; /*0x7385*/
        }
      }
    }
    else
    {
      if ( n24 == 12 ) /*0x72c9*/
        return 77; /*0x735d*/
      if ( n24 > 6u ) /*0x72d2*/
      {
        switch ( n24 ) /*0x7322*/
        {
          case 7u: /*0x7322*/
            return 72; /*0x7357*/
          case 8u: /*0x7322*/
            return 73; /*0x7351*/
          case 9u: /*0x7322*/
            return 74; /*0x734b*/
          case 0xAu: /*0x7322*/
            return 75; /*0x7345*/
          case 0xBu: /*0x7322*/
            return 76; /*0x733f*/
        }
      }
      else
      {
        switch ( n24 ) /*0x72d4*/
        {
          case 6u: /*0x72d4*/
            return 71; /*0x731e*/
          case 0u: /*0x72d4*/
            return 65; /*0x7318*/
          case 1u: /*0x72d4*/
            return 66; /*0x7312*/
          case 2u: /*0x72d4*/
            return 67; /*0x730c*/
          case 3u: /*0x72d4*/
            return 68; /*0x7306*/
          case 4u: /*0x72d4*/
            return 69; /*0x7300*/
          case 5u: /*0x72d4*/
            return 70; /*0x72fa*/
        }
      }
    }
    return 0; /*0x72f1*/
  }
  if ( n24 <= 0x24u ) /*0x73e6*/
  {
    if ( n24 == 36 ) /*0x73ec*/
      return 101; /*0x746e*/
    if ( n24 > 0x1Eu ) /*0x73f1*/
    {
      switch ( n24 ) /*0x7437*/
      {
        case 0x1Fu: /*0x7437*/
          return 96; /*0x7468*/
        case 0x20u: /*0x7437*/
          return 97; /*0x7462*/
        case 0x21u: /*0x7437*/
          return 98; /*0x745c*/
        case 0x22u: /*0x7437*/
          return 99; /*0x7456*/
        case 0x23u: /*0x7437*/
          return 100; /*0x7450*/
      }
    }
    else
    {
      switch ( n24 ) /*0x73f3*/
      {
        case 0x1Eu: /*0x73f3*/
          return 95; /*0x7433*/
        case 0x19u: /*0x73f3*/
          return 90; /*0x742d*/
        case 0x1Au: /*0x73f3*/
          return 91; /*0x7427*/
        case 0x1Bu: /*0x73f3*/
          return 92; /*0x7421*/
        case 0x1Cu: /*0x73f3*/
          return 93; /*0x741b*/
        case 0x1Du: /*0x73f3*/
          return 94; /*0x7415*/
      }
    }
    return 0; /*0x740c*/
  }
  if ( n24 <= 0x2Au ) /*0x7472*/
  {
    switch ( n24 ) /*0x7474*/
    {
      case '*': /*0x7474*/
        return 107; /*0x74b0*/
      case '%': /*0x7474*/
        return 102; /*0x74aa*/
      case '&': /*0x7474*/
        return 103; /*0x74a4*/
      case '\'': /*0x7474*/
        return 104; /*0x749e*/
      case '(': /*0x7474*/
        return 105; /*0x7498*/
      case ')': /*0x7474*/
        return 106; /*0x7492*/
    }
    return 0; /*0x748d*/
  }
  switch ( n24 ) /*0x74b4*/
  {
    case '+': /*0x74b4*/
      return 108; /*0x74e6*/
    case ',': /*0x74b4*/
      return 109; /*0x74e0*/
    case '-': /*0x74b4*/
      return 110; /*0x74da*/
    case '.': /*0x74b4*/
      return 111; /*0x74d4*/
  }
  if ( n24 != 47 ) /*0x74c8*/
    return 0; /*0x74cd*/
  return 112; /*0x72fa*/
}

// Function: RstGpioConfigure @ 0x74ec (0x1b2 bytes)
// Index: 190/906

__int16 __fastcall RstGpioConfigure(int n19)
{
  __int16 n9; // dx
  int v2; // ecx
  int v3; // ecx
  int v4; // ecx
  int v5; // ecx
  int v6; // ecx
  int v7; // ecx
  int v8; // ecx
  int v10; // ecx
  int v11; // ecx
  int v12; // ecx
  int v13; // ecx
  int v14; // ecx
  int v15; // ecx
  int v16; // ecx
  int v17; // ecx
  int v18; // ecx
  int v19; // ecx
  int v20; // ecx
  int v21; // ecx
  int v22; // ecx
  int v23; // ecx
  int v24; // ecx
  int v25; // ecx
  int v26; // ecx
  int v27; // ecx
  int v28; // ecx
  int v29; // ecx
  int v30; // ecx
  int v31; // ecx
  int v32; // ecx

  if ( n19 <= 19 ) /*0x74f5*/
  {
    if ( n19 == 19 ) /*0x74fb*/
      return 21; /*0x75d6*/
    n9 = 9; /*0x7501*/
    if ( n19 > 9 ) /*0x7507*/
    {
      v10 = n19 - 10; /*0x756e*/
      if ( !v10 ) /*0x7571*/
        return 12; /*0x75d0*/
      v11 = v10 - 1; /*0x7578*/
      if ( !v11 ) /*0x757a*/
        return 13; /*0x75ca*/
      v12 = v11 - 1; /*0x757c*/
      if ( !v12 ) /*0x757e*/
        return 14; /*0x75c4*/
      v13 = v12 - 1; /*0x7580*/
      if ( !v13 ) /*0x7582*/
        return 15; /*0x75be*/
      v14 = v13 - 1; /*0x7584*/
      if ( !v14 ) /*0x7586*/
        return 16; /*0x75b8*/
      v15 = v14 - 1; /*0x7588*/
      if ( !v15 ) /*0x758a*/
        return 17; /*0x75b2*/
      v16 = v15 - 1; /*0x758c*/
      if ( !v16 ) /*0x758e*/
        return 18; /*0x75ac*/
      v17 = v16 - 1; /*0x7590*/
      if ( !v17 ) /*0x7592*/
        return 19; /*0x75a6*/
      if ( v17 == 1 ) /*0x7596*/
        return 20; /*0x75a1*/
      return 40; /*0x7596*/
    }
    if ( n19 == 9 ) /*0x7509*/
      return 11; /*0x756d*/
    if ( !n19 ) /*0x750d*/
      return 2; /*0x7567*/
    v2 = n19 - 1; /*0x7512*/
    if ( !v2 ) /*0x7514*/
      return 3; /*0x7561*/
    v3 = v2 - 1; /*0x7516*/
    if ( !v3 ) /*0x7518*/
      return 4; /*0x755b*/
    v4 = v3 - 1; /*0x751a*/
    if ( !v4 ) /*0x751c*/
      return 5; /*0x7555*/
    v5 = v4 - 1; /*0x751e*/
    if ( !v5 ) /*0x7520*/
      return 6; /*0x754f*/
    v6 = v5 - 1; /*0x7522*/
    if ( !v6 ) /*0x7524*/
      return 7; /*0x7549*/
    v7 = v6 - 1; /*0x7526*/
    if ( !v7 ) /*0x7528*/
      return 8; /*0x7543*/
    v8 = v7 - 1; /*0x752a*/
    if ( v8 ) /*0x752c*/
    {
      if ( v8 == 1 ) /*0x7530*/
        return 10; /*0x7539*/
      return 40; /*0x7530*/
    }
    return n9; /*0x753d*/
  }
  n9 = 29; /*0x75d7*/
  if ( n19 <= 29 ) /*0x75de*/
  {
    if ( n19 == 29 ) /*0x75e0*/
      return 31; /*0x7641*/
    v18 = n19 - 20; /*0x75e2*/
    if ( !v18 ) /*0x75e5*/
      return 22; /*0x763b*/
    v19 = v18 - 1; /*0x75ea*/
    if ( !v19 ) /*0x75ec*/
      return 23; /*0x7635*/
    v20 = v19 - 1; /*0x75ee*/
    if ( !v20 ) /*0x75f0*/
      return 24; /*0x762f*/
    v21 = v20 - 1; /*0x75f2*/
    if ( !v21 ) /*0x75f4*/
      return 25; /*0x7629*/
    v22 = v21 - 1; /*0x75f6*/
    if ( !v22 ) /*0x75f8*/
      return 26; /*0x7623*/
    v23 = v22 - 1; /*0x75fa*/
    if ( !v23 ) /*0x75fc*/
      return 27; /*0x761d*/
    v24 = v23 - 1; /*0x75fe*/
    if ( !v24 ) /*0x7600*/
      return 28; /*0x7617*/
    v25 = v24 - 1; /*0x7602*/
    if ( v25 ) /*0x7604*/
    {
      if ( v25 == 1 ) /*0x760c*/
        return 30; /*0x7611*/
      return 40; /*0x760c*/
    }
    return n9; /*0x7604*/
  }
  v26 = n19 - 30; /*0x7642*/
  if ( !v26 ) /*0x7645*/
    return 32; /*0x7698*/
  v27 = v26 - 1; /*0x764c*/
  if ( !v27 ) /*0x764e*/
    return 33; /*0x7692*/
  v28 = v27 - 1; /*0x7650*/
  if ( !v28 ) /*0x7652*/
    return 34; /*0x768c*/
  v29 = v28 - 1; /*0x7654*/
  if ( !v29 ) /*0x7656*/
    return 35; /*0x7686*/
  v30 = v29 - 1; /*0x7658*/
  if ( !v30 ) /*0x765a*/
    return 36; /*0x7680*/
  v31 = v30 - 1; /*0x765c*/
  if ( !v31 ) /*0x765e*/
    return 37; /*0x767a*/
  v32 = v31 - 1; /*0x7660*/
  if ( !v32 ) /*0x7662*/
    return 38; /*0x7674*/
  if ( v32 != 1 ) /*0x7666*/
    return 40; /*0x766d*/
  return 39; /*0x7539*/
}

// Function: RstGetControllerInfo @ 0x76a0 (0xeb bytes)
// Index: 191/906

EFI_STRING __fastcall RstGetControllerInfo(CHAR16 *Destination, __int64 a2, void *HiiHandle)
{
  unsigned __int8 n12; // r10
  EFI_STRING_ID StringId; // di
  unsigned __int16 v7; // r9
  const CHAR8 *StringToLanguage; // rax
  unsigned __int16 v9; // ax
  __int64 v10; // rax
  _WORD i[24]; // [rsp+30h] [rbp-168h] BYREF
  CHAR8 Language[304]; // [rsp+60h] [rbp-138h] BYREF

  RstGpioConfigure(*((_DWORD *)Destination + 35)); /*0x76c1*/
  StringId = RstGpioRead(n12); /*0x76dc*/
  StringToLanguage = (const CHAR8 *)HiiGetStringToLanguage(HiiHandle, v7, 0); /*0x76df*/
  HiiGetString(HiiHandle, StringId, StringToLanguage); /*0x76f0*/
  MemZero(i, 0, 34); /*0x7700*/
  MemZero(Language, 0, 300); /*0x7712*/
  sub_872C(i, 0x11u, (_BYTE *)Destination + 4); /*0x7725*/
  v9 = RstGpioConfigure(*((_DWORD *)Destination + 35)); /*0x7730*/
  v10 = HiiGetStringToLanguage(HiiHandle, v9, 0); /*0x773e*/
  HiiCfgArrayGet(Language, 0x12Cu, (unsigned __int8 *)L"%s, %s", i, v10); /*0x775e*/
  return HiiGetString(HiiHandle, StringId, Language); /*0x7786*/
}

// Function: RstLanguageHandler @ 0x778c (0x12e bytes)
// Index: 192/906

EFI_STRING __fastcall RstLanguageHandler(CHAR16 *Source, unsigned __int8 n24, void *HiiHandle)
{
  EFI_STRING_ID StringId; // bp
  unsigned __int16 v7; // r9
  const CHAR8 *StringToLanguage; // rax
  __int64 v9; // rax
  CHAR16 *v10; // r8
  unsigned __int16 v11; // ax
  __int64 v12; // rax
  _QWORD v14[3]; // [rsp+30h] [rbp-188h] BYREF
  _WORD i[28]; // [rsp+48h] [rbp-170h] BYREF
  CHAR8 Language[304]; // [rsp+80h] [rbp-138h] BYREF

  RstGpioConfigure(*((_DWORD *)Source + 36)); /*0x77b2*/
  StringId = RstGpioWrite(n24); /*0x77cd*/
  StringToLanguage = (const CHAR8 *)HiiGetStringToLanguage(HiiHandle, v7, 0); /*0x77d0*/
  HiiGetString(HiiHandle, StringId, StringToLanguage); /*0x77e1*/
  MemZero(i, 0, 44); /*0x77f1*/
  MemZero(Language, 0, 300); /*0x7806*/
  if ( n24 == 0xFF ) /*0x780f*/
    v9 = 0x8000000000000002uLL; /*0x7828*/
  else
    v9 = sub_BBD4((__int64)v14, n24, "en"); /*0x7821*/
  v10 = (CHAR16 *)v14; /*0x783c*/
  if ( v9 ) /*0x7844*/
    v10 = Source + 2; /*0x7846*/
  sub_872C(i, 0x2Cu, v10); /*0x784a*/
  v11 = RstGpioConfigure(*((_DWORD *)Source + 36)); /*0x7855*/
  v12 = HiiGetStringToLanguage(HiiHandle, v11, 0); /*0x7863*/
  HiiCfgArrayGet(Language, 0x12Cu, (unsigned __int8 *)L"%s, %s", i, v12); /*0x7886*/
  return HiiGetString(HiiHandle, StringId, Language); /*0x78b5*/
}

// Function: RstGetString @ 0x78bc (0x98 bytes)
// Index: 193/906

__int64 __fastcall RstGetString(__int64 a1, __int64 a2)
{
  __int64 v4; // rbx
  __int64 v5; // rax

  LocateHandleBuffer(*(_QWORD *)(qword_35418 + 624), SystemTable); /*0x78e1*/
  v4 = (*(__int64 (__fastcall **)(__int64, void *, __int64, _QWORD))(qword_58070 + 328))(a2, &unk_271D8, a1 + 8, 0); /*0x7929*/
  v5 = HiiPackageListBuild((__int64)&unk_271C8, *(_QWORD *)(qword_35418 + 624), &unk_271F0, 0, 0); /*0x792c*/
  *(_QWORD *)(a1 + 24) = v5; /*0x793e*/
  if ( !v5 ) /*0x7942*/
    return 0x8000000000000002uLL; /*0x7942*/
  return v4; /*0x794e*/
}

// Function: RstIsDebugEnabled @ 0x7954 (0xdf bytes)
// Index: 194/906

char RstIsDebugEnabled()
{
  char v0; // di
  unsigned int v1; // eax
  unsigned __int8 n0x18; // si
  unsigned __int64 v3; // rbx
  unsigned __int8 v4; // si
  unsigned __int64 v5; // rbx
  __int64 i[17]; // [rsp+20h] [rbp-F8h] BYREF
  int n21; // [rsp+ACh] [rbp-6Ch]
  int n5; // [rsp+B0h] [rbp-68h]

  v0 = 0; /*0x7966*/
  v1 = sub_B334(); /*0x7969*/
  n0x18 = 0; /*0x796e*/
  v3 = v1; /*0x7971*/
  while ( v3 ) /*0x7975*/
  {
    if ( !(unsigned int)RstHelper_c8a8(n0x18, (__int64)i) ) /*0x797f*/
    {
      if ( (v3 & 1) != 0 && n21 != 21 && (n21 <= 23 || n21 > 25 && (n21 <= 31 || n21 > 36)) ) /*0x79ab*/
        ++v0; /*0x79ad*/
      v3 >>= 1; /*0x79b0*/
      ++n0x18; /*0x79b3*/
    }
  }
  v4 = 0; /*0x79bd*/
  v5 = sub_B1C4(0); /*0x79c5*/
  while ( v5 ) /*0x79cb*/
  {
    if ( !(unsigned int)RstHelper_ce6c(v4, (__int64)i) ) /*0x79d6*/
    {
      if ( (v5 & 1) != 0 && n5 && n5 != 5 && (n5 <= 6 || n5 > 9 && n5 != 13 && (n5 <= 17 || n5 > 19)) ) /*0x7a0b*/
        ++v0; /*0x7a0d*/
      v5 >>= 1; /*0x7a10*/
      ++v4; /*0x7a13*/
    }
  }
  return v0; /*0x7a2e*/
}

// Function: RstProcessForm @ 0x7a34 (0x23a bytes)
// Index: 195/906

void __fastcall RstProcessForm(RST_PRIVATE_DATA *Private)
{
  _DWORD *v1; // rdx
  void *HiiHandle_1; // r8
  void *HiiHandle; // r14
  _DWORD *v4; // rsi
  unsigned int v6; // eax
  __int64 v7; // r13
  unsigned __int8 n0x18; // di
  unsigned __int64 v9; // rbx
  __int64 v10; // rdx
  __int64 v11; // r8
  __int16 v12; // ax
  __int64 v13; // r8
  unsigned __int8 n24; // di
  unsigned __int64 v15; // rbx
  unsigned __int8 v16; // bp
  __int64 v17; // r8
  __int16 v18; // ax
  __int64 v19; // r8
  CHAR16 Source[70]; // [rsp+20h] [rbp-1F8h] BYREF
  int n21; // [rsp+ACh] [rbp-16Ch]
  CHAR16 Destination[72]; // [rsp+110h] [rbp-108h] BYREF
  int n5; // [rsp+1A0h] [rbp-78h]

  HiiHandle = HiiHandle_1; /*0x7a54*/
  v4 = v1; /*0x7a57*/
  if ( !sub_B120() ) /*0x7a5d*/
  {
    *v4 = 0; /*0x7a67*/
    return; /*0x7a69*/
  }
  v6 = sub_B334(); /*0x7a6e*/
  LOBYTE(v7) = 0; /*0x7a73*/
  n0x18 = 0; /*0x7a76*/
  v9 = v6; /*0x7a79*/
  if ( v6 ) /*0x7a80*/
  {
    while ( 1 ) /*0x7a86*/
    {
      if ( (v9 & 1) == 0 ) /*0x7a89*/
        goto LABEL_13; /*0x7a89*/
      if ( !(unsigned int)RstHelper_c8a8(n0x18, (__int64)Source) ) /*0x7a97*/
        break; /*0x7a97*/
LABEL_14:
      if ( !v9 ) /*0x7b4c*/
        goto LABEL_15; /*0x7b4c*/
    }
    if ( n21 != 21 && (n21 <= 23 || n21 > 25 && (n21 <= 31 || n21 > 36)) ) /*0x7aca*/
    {
      *v4 = 3; /*0x7acc*/
      if ( Private ) /*0x7ad5*/
      {
        StrnCpy(Destination, Source, 0xA8u); /*0x7aea*/
        LOBYTE(v10) = n0x18; /*0x7afa*/
        RstGetControllerInfo(Destination, v10, HiiHandle); /*0x7afd*/
        v11 = 3LL * (unsigned __int8)v7; /*0x7b0a*/
        *((_QWORD *)Private->Vtable + v11 + 2) = 0; /*0x7b11*/
        *((_QWORD *)Private->Vtable + v11) = HiiHandle; /*0x7b1b*/
        v12 = RstGpioRead(n0x18); /*0x7b1f*/
        *((_WORD *)Private->Vtable + 4 * v13 + 4) = v12; /*0x7b28*/
        v7 = (unsigned __int8)(v7 + 1); /*0x7b35*/
        *((_QWORD *)Private->Vtable + 3 * v7) = 0; /*0x7b3e*/
      }
    }
LABEL_13:
    v9 >>= 1; /*0x7b43*/
    ++n0x18; /*0x7b46*/
    goto LABEL_14; /*0x7b46*/
  }
LABEL_15:
  n24 = 0; /*0x7b52*/
  v15 = sub_B1C4(0); /*0x7b5c*/
  if ( v15 ) /*0x7b62*/
  {
    v16 = v7 + 1; /*0x7b68*/
    while ( 1 ) /*0x7b6c*/
    {
      if ( (v15 & 1) == 0 ) /*0x7b6f*/
        goto LABEL_28; /*0x7b6f*/
      if ( !(unsigned int)RstHelper_ce6c(n24, (__int64)Destination) ) /*0x7b81*/
        break; /*0x7b81*/
LABEL_29:
      if ( !v15 ) /*0x7c46*/
        return; /*0x7c46*/
    }
    if ( n5 && n5 != 5 && (n5 <= 6 || n5 > 9 && n5 != 13 && (n5 <= 17 || n5 > 19)) ) /*0x7bc5*/
    {
      *v4 = 3; /*0x7bc7*/
      if ( Private ) /*0x7bd0*/
      {
        StrnCpy(Source, Destination, 0xF0u); /*0x7be5*/
        RstLanguageHandler(Source, n24, HiiHandle); /*0x7bf5*/
        v17 = 3LL * (unsigned __int8)v7; /*0x7c02*/
        *((_QWORD *)Private->Vtable + v17 + 2) = 0; /*0x7c09*/
        *((_QWORD *)Private->Vtable + v17) = HiiHandle; /*0x7c13*/
        v18 = RstGpioWrite(n24); /*0x7c17*/
        *((_WORD *)Private->Vtable + 4 * v19 + 4) = v18; /*0x7c20*/
        LOBYTE(v7) = v7 + 1; /*0x7c2a*/
        *((_QWORD *)Private->Vtable + 3 * v16++) = 0; /*0x7c35*/
      }
    }
LABEL_28:
    v15 >>= 1; /*0x7c3d*/
    ++n24; /*0x7c40*/
    goto LABEL_29; /*0x7c40*/
  }
}

// Function: RstGetBrowserData @ 0x7c70 (0xbd bytes)
// Index: 196/906

__int64 __fastcall RstGetBrowserData(__int64 a1, __int64 a2, __int64 a3, _DWORD *a4, unsigned __int64 *Private_1)
{
  RST_PRIVATE_DATA *Private; // rdi
  unsigned __int8 IsDebugEnabled; // al

  if ( a2 && a2 != qword_35418[78] ) /*0x7c99*/
    return 0x8000000000000003uLL; /*0x7ca5*/
  if ( a3 ) /*0x7caa*/
    return (a4 != 0) - 0x7FFFFFFFFFFFFFFELL; /*0x7cc2*/
  Private = (RST_PRIVATE_DATA *)Private_1; /*0x7cc4*/
  *a4 = 0; /*0x7cc9*/
  if ( Private_1 ) /*0x7cd0*/
  {
    IsDebugEnabled = RstIsDebugEnabled(); /*0x7cd2*/
    if ( IsDebugEnabled ) /*0x7cdc*/
    {
      if ( (*(__int64 (__fastcall **)(__int64, __int64, unsigned __int64 *))(qword_58070 + 64))( /*0x7cfd*/
             4,
             24LL * ((unsigned int)IsDebugEnabled + 1),
             Private_1) < 0 )
        return 0x8000000000000009uLL; /*0x7d09*/
    }
    else
    {
      Private = 0; /*0x7d0b*/
    }
  }
  RstProcessForm(Private); /*0x7d16*/
  return 0; /*0x7d27*/
}

// Function: RstSetBrowserData @ 0x7e18 (0xba bytes)
// Index: 201/906

char __fastcall RstSetBrowserData(
        __int64 a1,
        int a2,
        unsigned __int64 a3,
        unsigned __int64 a4,
        unsigned __int64 a5,
        unsigned __int64 *a6)
{
  unsigned __int64 v7; // rax
  unsigned __int64 v8; // rcx

  if ( !a6 ) /*0x7e2b*/
    return 0; /*0x7e2b*/
  if ( !a1 ) /*0x7e34*/
    goto LABEL_17; /*0x7e34*/
  if ( *(_DWORD *)(a1 + 88) != a2 ) /*0x7e3d*/
  {
    v7 = 0x800000000000000DuLL; /*0x7e3f*/
LABEL_18:
    *a6 = v7; /*0x7ec7*/
    return 0; /*0x7ec7*/
  }
  if ( !a5 ) /*0x7e53*/
  {
LABEL_17:
    v7 = 0x8000000000000002uLL; /*0x7ebd*/
    goto LABEL_18; /*0x7ebd*/
  }
  if ( a4 ) /*0x7e58*/
  {
    v8 = *(unsigned int *)(a1 + 100); /*0x7e5f*/
    if ( a4 % v8 ) /*0x7e67*/
    {
      v7 = 0x8000000000000004uLL; /*0x7e6f*/
      goto LABEL_18; /*0x7e79*/
    }
    if ( a3 <= *(_QWORD *)(a1 + 112) /*0x7eb3*/
      && a4 / v8 + a3 - 1 <= *(_QWORD *)(a1 + 112)
      && a4 + a5 <= 0x100000000LL
      && a5 <= 0x100000000LL
      && (!*(_DWORD *)(a1 + 104) || ((*(_DWORD *)(a1 + 104) - 1) & (unsigned int)a5) == 0) )
    {
      *a6 = 0; /*0x7eb5*/
      return 1; /*0x7ebb*/
    }
    goto LABEL_17; /*0x7eb3*/
  }
  *a6 = 0; /*0x7e5a*/
  return 0; /*0x7ed1*/
}

// Function: RstDriverInit2 @ 0x9338 (0x2d bytes)
// Index: 243/906

__int64 __fastcall RstDriverInit2(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  UefiBootServicesTableLibConstructor((__int64)ImageHandle, (__int64)SystemTable); /*0x9348*/
  UefiRuntimeServicesTableLibConstructor(ImageHandle, SystemTable); /*0x9353*/
  return 0; /*0x935f*/
}

// Function: RstLinkedListGetNth @ 0xde68 (0x24 bytes)
// Index: 364/906

_QWORD *__fastcall RstLinkedListGetNth(_QWORD **a1, __int16 a2)
{
  _QWORD *result; // rax

  if ( a2 < 0 ) /*0xde6f*/
    return 0; /*0xde71*/
  result = *a1; /*0xde74*/
  while ( result && a2 > 0 ) /*0xde7d*/
  {
    result = (_QWORD *)*result; /*0xde7f*/
    --a2; /*0xde82*/
  }
  return result; /*0xde73*/
}

// Function: RstListNodeInit @ 0x10d8c (0x1c bytes)
// Index: 450/906

_QWORD *__fastcall RstListNodeInit(_QWORD *a1)
{
  a1[1] = 0; /*0x10d8e*/
  *a1 = 0; /*0x10d92*/
  a1[13] = 0; /*0x10d95*/
  a1[12] = 0; /*0x10d99*/
  a1[16] = a1; /*0x10d9d*/
  return a1; /*0x10da7*/
}

// Function: RstGetFieldCount @ 0x11d88 (0x12 bytes)
// Index: 474/906

__int64 __fastcall RstGetFieldCount(__int64 Destination, char a2)
{
  __int64 result; // rax

  result = *(unsigned int *)(Destination + 4); /*0x11d88*/
  if ( a2 ) /*0x11d8d*/
  {
    if ( (unsigned int)result > 1 ) /*0x11d96*/
      return 1; /*0x11d96*/
  }
  return result; /*0x11d99*/
}

// Function: RstGetFieldSize @ 0x11de4 (0x12 bytes)
// Index: 476/906

__int64 __fastcall RstGetFieldSize(CHAR16 *Destination, char a2)
{
  __int64 n0x18; // rax

  n0x18 = *((unsigned int *)Destination + 3); /*0x11de4*/
  if ( a2 ) /*0x11de9*/
  {
    if ( (unsigned int)n0x18 > 0x18 ) /*0x11df2*/
      return 24; /*0x11df2*/
  }
  return n0x18; /*0x11df5*/
}

// Function: RstGetFieldBlockSize @ 0x11df8 (0x4 bytes)
// Index: 477/906

__int64 __fastcall RstGetFieldBlockSize(CHAR16 *Destination)
{
  return *((unsigned int *)Destination + 4); /*0x11dfb*/
}

// Function: RstPplRecoveryLogSetOffset @ 0x1c974 (0x47 bytes)
// Index: 784/906

void __fastcall RstPplRecoveryLogSetOffset(__int64 a1, __int64 a2)
{
  if ( (unsigned __int8)RstDebugEnabled(a1, a2) && *(_WORD *)(a1 + 32) ) /*0x1c98d*/
    DebugAssert("PplRecoveryLog.cpp", 0x5Au, "m_nOffs == 0"); /*0x1c9a7*/
  *(_QWORD *)(a1 + 24) = a2; /*0x1c9ac*/
}