Newer
Older
AMI-Aptio-BIOS-Reversed / Platform / PrintLibInternalSPrint.c
@Ajax Dong Ajax Dong 2 days ago 5 KB Init
// PrintLibInternalSPrint - decompiled from Platform.efi
unsigned __int64 __fastcall PrintLibInternalSPrint(
        _WORD *Source,
        unsigned __int64 n0x1E8481,
        __int64 n160,
        signed __int64 a4,
        unsigned __int64 n0x26)
{
  char n160_1; // si
  _BYTE *Source_1; // rbx
  const char *(Buffer____((void__)_0)); // r8
  __int64 n366; // rdx
  unsigned __int64 v12; // rdi
  unsigned __int64 n37; // rdi
  __int64 v14; // r14
  unsigned __int64 n37_1; // r14
  unsigned __int64 v16; // rdx
  signed __int64 v17; // rax
  _BYTE *Source_2; // r14
  __int64 i; // rax
  _BYTE *PciCfg; // rbp
  unsigned __int64 v21; // r11
  unsigned __int64 v22; // r8
  unsigned __int64 v23; // rdx
  int v24; // esi
  __int16 v25; // r9
  __int64 j; // rcx
  __int64 k; // rax
  __int64 v28; // rax
  _BYTE *Source_3; // r14
  _BYTE _r_n[48]; // [rsp+30h] [rbp-58h] BYREF

  n160_1 = n160; /*0x636b*/
  Source_1 = Source; /*0x6371*/
  if ( !Source ) /*0x6377*/
  {
    (Buffer____((void__)_0)) = "(Buffer != ((void *) 0))"; /*0x6379*/
    n366 = 366; /*0x6380*/
LABEL_3:
    Assert( /*0x6385*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BasePrintLib\\PrintLibInternal.c",
      n366,
      (__int64)(Buffer____((void__)_0)));
    return 0x8000000000000002uLL; /*0x639b*/
  }
  if ( n0x1E8481 > 0x1E8481 ) /*0x63a7*/
  {
    (Buffer____((void__)_0)) = "(BufferSize <= (_gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength) * sizeof (CHAR16) + 1)"; /*0x63a9*/
    n366 = 385; /*0x63b0*/
    goto LABEL_3; /*0x63b5*/
  }
  v12 = n160 & 0xFFFFFFFFFFFFFF56uLL; /*0x63ba*/
  if ( (n160 & 0xFFFFFFFFFFFFFF56uLL) != 0 ) /*0x63c1*/
    Assert( /*0x63d6*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BasePrintLib\\PrintLibInternal.c",
      392,
      (__int64)"((Flags & ~(0x01 | 0x08 | 0x20 | 0x80)) == 0)");
  if ( v12 ) /*0x63de*/
    return 0x8000000000000002uLL; /*0x63de*/
  if ( (n160_1 & 0x88) == 0x88 ) /*0x63ef*/
  {
    Assert( /*0x6404*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BasePrintLib\\PrintLibInternal.c",
      393,
      (__int64)"(((Flags & 0x08) == 0) || ((Flags & 0x80) == 0))");
    return 0x8000000000000002uLL; /*0x640c*/
  }
  if ( n0x26 >= 0x26 ) /*0x641a*/
  {
    (Buffer____((void__)_0)) = "(Width < 38)"; /*0x641c*/
    n366 = 398; /*0x6423*/
    goto LABEL_3; /*0x6428*/
  }
  if ( !n0x26 || (n160_1 & 8) != 0 ) /*0x6436*/
    n160_1 &= ~0x20u; /*0x6438*/
  n37 = 37; /*0x6442*/
  if ( n0x26 ) /*0x6447*/
    n37 = n0x26; /*0x6447*/
  v14 = 0; /*0x6452*/
  if ( (n160_1 & 0x20) != 0 )
  {
    n37_1 = n37; /*0x6476*/
  }
  else
  {
    if ( a4 >= 0 || n160_1 < 0 ) /*0x6483*/
    {
      v16 = a4; /*0x6491*/
    }
    else
    {
      v14 = 1; /*0x6488*/
      v16 = -a4; /*0x648c*/
    }
    v17 = ReadPciCfg(_r_n, v16, n160_1 < 0 ? 16LL : 10LL) - _r_n;
    n37_1 = v17 + v14; /*0x64a9*/
    if ( (n160_1 & 8) != 0 ) /*0x64b0*/
      n37_1 += (v17 - 1) / 3uLL; /*0x64c6*/
  }
  if ( n37_1 < n37 ) /*0x64cc*/
    n37 = n37_1; /*0x64cc*/
  if ( n0x1E8481 >= 2 * n37 + 2 )
  {
    Source_2 = &Source_1[2 * n37]; /*0x650c*/
    if ( a4 < 0 && (n160_1 & 0x80) == 0 ) /*0x6518*/
    {
      a4 = -a4; /*0x651a*/
      for ( i = 0; i < 1; ++i ) /*0x651d*/
      {
        if ( Source_1 >= Source_2 ) /*0x6523*/
          break; /*0x6523*/
        *(_WORD *)Source_1 = 45; /*0x6525*/
        Source_1 += 2; /*0x652d*/
      }
      --n37; /*0x6537*/
    }
    PciCfg = ReadPciCfg(_r_n, a4, n160_1 < 0 ? 16LL : 10LL);
    v21 = PciCfg - _r_n; /*0x6555*/
    if ( (n160_1 & 0x20) != 0 ) /*0x6560*/
      Source_1 = WritePciCfg(Source_1, Source_2, n37 - v21, 48, 2); /*0x6582*/
    v22 = 0; /*0x6595*/
    v23 = 3 - v21 % 3; /*0x65a7*/
    if ( !(v21 % 3) ) /*0x65a4*/
      v23 = 0; /*0x65ad*/
    if ( v21 ) /*0x65b4*/
    {
      v24 = n160_1 & 8; /*0x65b6*/
      do /*0x661d*/
      {
        v25 = (char)*PciCfg; /*0x65b9*/
        for ( j = 0; j < 1; ++j ) /*0x65be*/
        {
          if ( Source_1 >= Source_2 ) /*0x65c4*/
            break; /*0x65c4*/
          *(_WORD *)Source_1 = v25; /*0x65c9*/
          Source_1 += 2; /*0x65d6*/
        }
        --PciCfg; /*0x65e0*/
        if ( v24 ) /*0x65e6*/
        {
          if ( ++v23 == 3 ) /*0x65ef*/
          {
            v23 = 0; /*0x65f5*/
            if ( v22 + 1 < v21 ) /*0x65fb*/
            {
              for ( k = 0; k < 1; ++k ) /*0x65fd*/
              {
                if ( Source_1 >= Source_2 ) /*0x6603*/
                  break; /*0x6603*/
                *(_WORD *)Source_1 = 44; /*0x6605*/
                Source_1 += 2; /*0x660d*/
              }
            }
          }
        }
        ++v22; /*0x6617*/
      }
      while ( v22 < v21 ); /*0x661d*/
    }
    v28 = 0; /*0x661f*/
    Source_3 = Source_2 + 2; /*0x6622*/
    do /*0x663a*/
    {
      if ( Source_1 >= Source_3 ) /*0x6629*/
        break; /*0x6629*/
      *(_WORD *)Source_1 = 0; /*0x662b*/
      ++v28; /*0x662f*/
      Source_1 += 2; /*0x6632*/
    }
    while ( v28 < 1 ); /*0x663a*/
    return 0; /*0x663c*/
  }
  else
  {
    Assert( /*0x64f0*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BasePrintLib\\PrintLibInternal.c",
      441,
      (__int64)"(BufferSize >= (Width + 1) * Increment)");
    return 0x8000000000000005uLL; /*0x64fa*/
  }
}