Newer
Older
AMI-Aptio-BIOS-Reversed / EarlyVideoPei / ImageDecodeBlocks.c
@Ajax Dong Ajax Dong 2 days ago 3 KB Init
_BYTE *__fastcall ImageDecodeBlocks(_BYTE *count_5, int a2)
{
  _BYTE *count_1; // eax
  int v3; // ebp
  int v4; // edi
  int v5; // eax
  int v6; // ecx
  int v7; // edx
  int v8; // ebx
  unsigned int count; // esi
  char *buf; // ebp
  int v11; // edi
  char *dst_2; // ecx
  _BYTE *count_7; // ebx
  char *v14; // ecx
  int v15; // esi
  char *v16; // eax
  int n4; // edx
  char *dst; // esi
  int n4_1; // edi
  unsigned int count_3; // eax
  bool v21; // zf
  int v22; // [esp+4h] [ebp-278h]
  _BYTE *count_6; // [esp+8h] [ebp-274h]
  char *dst_1; // [esp+8h] [ebp-274h]
  int v25; // [esp+Ch] [ebp-270h]
  int v26; // [esp+Ch] [ebp-270h]
  int v27; // [esp+10h] [ebp-26Ch]
  int v28; // [esp+10h] [ebp-26Ch]
  unsigned int count_2; // [esp+18h] [ebp-264h]
  _BYTE *count_4; // [esp+20h] [ebp-25Ch]
  char buf_; // [esp+24h] [ebp-258h] BYREF
  char v34; // [esp+25h] [ebp-257h] BYREF

  v22 = 0;
  count_1 = count_5;
  v3 = a2;
  if ( count_5 )
  {
    if ( a2 )
    {
      v4 = 4 * a2;
      v27 = 4 * a2;
      if ( (unsigned int)(4 * a2) <= 0x96 )
      {
        v25 = -1879048192;
        v5 = DebugHexPrint();
        if ( v5 && *(_BYTE *)(v5 + 24) && (*(_DWORD *)(v5 + 56) || *(_DWORD *)(v5 + 60)) )
        {
          v6 = *(_DWORD *)(v5 + 56);
          v7 = *(_DWORD *)(v5 + 40);
          v22 = v6;
          v25 = v7;
        }
        else
        {
          v6 = 0;
          v7 = -1879048192;
        }
        v8 = 974 - v4 + ((748 - v4) << 10);
        count_1 = (_BYTE *)(v4 + 8);
        count_6 = (_BYTE *)(v4 + 8);
        if ( v4 != -8 )
        {
          count = 16 * (v3 + 2);
          buf = (char *)(v6 + 4 * (v8 - 4100));
          v11 = v7 - v6;
          do
          {
            if ( count )
            {
              SetMem(&buf[v11], count, 255);
              count_1 = count_6;
              v6 = v22;
            }
            if ( v6 && count )
            {
              SetMem(buf, count, 255);
              count_1 = count_6;
              v6 = v22;
            }
            buf += 4096;
            count_6 = --count_1;
          }
          while ( count_1 );
          v4 = v27;
          v3 = a2;
        }
        if ( v3 )
        {
          count_1 = (_BYTE *)(16 * v3);
          v26 = v25 - v6;
          dst_2 = (char *)(v6 + 4 * v8);
          count_7 = count_5;
          count_4 = (_BYTE *)(16 * v3);
          count_2 = 4 * v4;
          dst_1 = dst_2;
          v28 = v3;
          do
          {
            if ( count_1 )
              SetMem(&buf_, (unsigned int)count_1, 0);
            v14 = &v34;
            v15 = v3;
            do
            {
              if ( (*count_7 & 1) == 0 )
              {
                v16 = v14;
                n4 = 4;
                do
                {
                  *(_WORD *)(v16 - 1) = -1;
                  v16 += 4;
                  *(v16 - 3) = -1;
                  --n4;
                }
                while ( n4 );
              }
              ++count_7;
              v14 += 16;
              --v15;
            }
            while ( v15 );
            dst = dst_1;
            n4_1 = 4;
            dst_1 += 0x4000;
            do
            {
              count_3 = count_2;
              if ( count_2 )
              {
                CopyMem(&dst[v26], &buf_, count_2);
                count_3 = count_2;
              }
              if ( v22 )
              {
                if ( count_3 )
                  CopyMem(dst, &buf_, count_3);
              }
              dst += 4096;
              --n4_1;
            }
            while ( n4_1 );
            v21 = v28-- == 1;
            v3 = a2;
            count_1 = count_4;
          }
          while ( !v21 );
        }
      }
    }
  }
  return count_1;
}