// SetSetupVariable - decompiled from Platform.efi
__int64 __fastcall SetSetupVariable(const void *SourceBuffer)
{
  char *Buffer; // rsi
  __int64 v3; // rdi
  __int64 v4; // rbx
  __int64 *v5; // r14
  void *DestinationBuffer; // rax
  void *DestinationBuffer_1; // rbp
  __int64 v8; // rax
  __int64 v9; // r14
  void *va_; // [rsp+50h] [rbp+8h] BYREF

  if ( !SourceBuffer ) /*0x8437*/
    return 0x8000000000000002uLL; /*0x8439*/
  Buffer = (char *)&Buffer_; /*0x844b*/
  CopyMem(&Buffer_, SourceBuffer, 0x2A3Bu); /*0x845b*/
  v3 = 0; /*0x8460*/
  if ( !off_FD00 ) /*0x8469*/
    return 0; /*0x8518*/
  v4 = 0; /*0x8476*/
  v5 = (__int64 *)&off_FD00; /*0x8478*/
  while ( 1 ) /*0x848d*/
  {
    DestinationBuffer = (void *)SetupPolicyInit( /*0x848d*/
                                  *(__int64 *)((char *)&off_FD00 + v4 + 8),
                                  &va_,
                                  *v5,
                                  *(_UNKNOWN **)((char *)&off_FD00 + v4 + 16));
    DestinationBuffer_1 = DestinationBuffer; /*0x8492*/
    if ( !DestinationBuffer ) /*0x8498*/
      break; /*0x8498*/
    CopyMem(DestinationBuffer, Buffer, *(UINTN *)((char *)&off_FD00 + v4 + 16)); /*0x84a9*/
    v8 = (*(__int64 (__fastcall **)(_QWORD, __int64, _QWORD, _QWORD, void *))(RuntimeServices + 88))( /*0x84cc*/
           *(_UNKNOWN **)((char *)&off_FD00 + v4 + 8),
           *v5,
           (unsigned int)va_,
           *(_UNKNOWN **)((char *)&off_FD00 + v4 + 16),
           DestinationBuffer_1);
    v9 = v8; /*0x84d0*/
    if ( v8 < 0 ) /*0x84d6*/
    {
      DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v8); /*0x8542*/
      Assert((__int64)"e:\\hs\\PurleyRpPkg\\Library\\SetupLib\\DxeSetupLib.c", 405, (__int64)"!EFI_ERROR (Status)"); /*0x855a*/
      return v9; /*0x8562*/
    }
    if ( byte_FF20 ) /*0x84e2*/
      (*(void (__fastcall **)(void *))(qword_FF18 + 88))(DestinationBuffer_1); /*0x84eb*/
    else
      (*(void (__fastcall **)(void *))(BootServices + 72))(DestinationBuffer_1); /*0x84f7*/
    Buffer = &Buffer[*(_QWORD *)((char *)&off_FD00 + v4 + 16)]; /*0x84fa*/
    ++v3; /*0x84ff*/
    v4 = 24 * v3; /*0x8506*/
    v5 = (__int64 *)(&off_FD00 + 3 * v3); /*0x850a*/
    if ( !*v5 ) /*0x850e*/
      return 0; /*0x8512*/
  }
  Assert((__int64)"e:\\hs\\PurleyRpPkg\\Library\\SetupLib\\DxeSetupLib.c", 399, (__int64)"Variable != ((void *) 0)"); /*0x8577*/
  return 0x800000000000000EuLL; /*0x8529*/
}
