// StrCatS - decompiled from Platform.efi
RETURN_STATUS __cdecl StrCatS(CHAR16 *Destination, UINTN DestMax, const CHAR16 *Source)
{
  UINTN v6; // rax
  UINTN v7; // rbp
  UINTN v8; // r15
  const char *(Destination____((void__)_0)); // r8
  __int64 n427; // rdx
  UINTN v12; // rax
  UINTN v13; // r14
  CHAR16 *v14; // rax

  if ( ((unsigned __int8)Destination & 1) != 0 ) /*0x51cb*/
    Assert( /*0x51dc*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
      415,
      (__int64)"((UINTN) Destination & 0x00000001) == 0");
  if ( ((unsigned __int8)Source & 1) != 0 ) /*0x51e4*/
    Assert( /*0x51f5*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
      416,
      (__int64)"((UINTN) Source & 0x00000001) == 0");
  v6 = StrLen(Destination); /*0x5200*/
  v7 = DestMax - v6; /*0x520b*/
  v8 = v6; /*0x520e*/
  if ( !Destination ) /*0x5214*/
  {
    (Destination____((void__)_0)) = "(Destination != ((void *) 0))"; /*0x5216*/
    n427 = 427; /*0x521d*/
LABEL_7:
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", n427, (__int64)(Destination____((void__)_0))); /*0x5222*/
    return 0x8000000000000002uLL; /*0x5234*/
  }
  if ( !Source ) /*0x523c*/
  {
    (Destination____((void__)_0)) = "(Source != ((void *) 0))"; /*0x523e*/
    n427 = 428; /*0x5245*/
    goto LABEL_7; /*0x524a*/
  }
  if ( DestMax > 0xF4240 ) /*0x5253*/
  {
    (Destination____((void__)_0)) = "(DestMax <= (_gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength))"; /*0x5255*/
    n427 = 434; /*0x525c*/
    goto LABEL_7; /*0x5261*/
  }
  if ( !DestMax ) /*0x5266*/
  {
    (Destination____((void__)_0)) = "(DestMax != 0)"; /*0x5268*/
    n427 = 440; /*0x526f*/
    goto LABEL_7; /*0x5274*/
  }
  if ( !v7 ) /*0x5279*/
  {
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", 445, (__int64)"(CopyLen != 0)"); /*0x528a*/
    return 0x8000000000000004uLL; /*0x5299*/
  }
  v12 = StrLen(Source); /*0x52a4*/
  v13 = v12; /*0x52a9*/
  if ( v7 <= v12 ) /*0x52af*/
  {
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", 451, (__int64)"(CopyLen > SourceLen)"); /*0x52c0*/
    return 0x8000000000000005uLL; /*0x52cf*/
  }
  if ( Source > Destination ) /*0x52d4*/
    goto LABEL_21; /*0x52d4*/
  if ( Destination >= &Source[v12 + 1] ) /*0x52e1*/
  {
    if ( Destination > Source ) /*0x52e6*/
      goto LABEL_24; /*0x52e6*/
LABEL_21:
    if ( Source >= &Destination[DestMax] ) /*0x52ef*/
      goto LABEL_23; /*0x52ef*/
  }
  Assert( /*0x52f1*/
    (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
    456,
    (__int64)"InternalSafeStringNoStrOverlap (Destination, DestMax, (CHAR16 *)Source, SourceLen + 1)");
LABEL_23:
  if ( Source > Destination ) /*0x5308*/
  {
LABEL_26:
    if ( Source < &Destination[DestMax] ) /*0x5323*/
      return 0x800000000000000FuLL; /*0x5323*/
    goto LABEL_28; /*0x5323*/
  }
LABEL_24:
  if ( Destination < &Source[v13 + 1] ) /*0x5315*/
    return 0x800000000000000FuLL; /*0x532f*/
  if ( Source >= Destination ) /*0x531a*/
    goto LABEL_26; /*0x531a*/
LABEL_28:
  v14 = &Destination[v8]; /*0x5331*/
  while ( *Source ) /*0x5348*/
    *v14++ = *Source++; /*0x5337*/
  *v14 = 0; /*0x534a*/
  return 0; /*0x535f*/
}
