woutput_s

__int64 __fastcall woutput_s(__int64 a1, unsigned __int16 *a2, int *a3){
  int v5; 
  int v6; 
  wchar_t *v7; 
  __int64 v8; 
  int v9; 
  unsigned __int16 v10; 
  int v11; 
  __int64 v12; 
  int v13; 
  int v14; 
  unsigned __int64 v15; 
  __int64 v16; 
  unsigned __int16 *v17; 
  unsigned int v18; 
  __int16 v19; 
  int v20; 
  int v21; 
  int v22; 
  const char *v23; 
  const wchar_t *v24; 
  unsigned __int64 v25; 
  char v26; 
  char *v27; 
  int v28; 
  int v29; 
  unsigned __int64 v30; 
  char v31; 
  __int16 v32; 
  int v33; 
  __int64 v34; 
  int v35; 
  __int16 v36; 
  int v37; 
  __int64 v38; 
  int v39; 
  const char *v40; 
  int v41; 
  int v42; 
  __int64 v43; 
  bool i; 
  unsigned __int16 v46; 
  int v47; 
  unsigned __int64 v48; 
  __int64 v49; 
  int v50; 
  int v51; 
  int v52; 
  int v53; 
  int v54; 
  int v55; 
  __int16 v56[2]; 
  int v57; 
  char SrcCh[4]; 
  __int16 v59[2]; 
  int v60; 
  __int64 v61; 
  int v62; 
  int v63; 
  int v64; 
  unsigned __int16 *v65; 
  wchar_t DstCh[512]; 

  v61 = a1;
  v62 = 0;
  v5 = 0;
  v60 = 0;
  v6 = 0;
  v54 = 0;
  v7 = 0i64;
  v53 = 0;
  v63 = 0;
  memset(DstCh, 0i64, sizeof(DstCh));
  v8 = v61;
  v9 = 0;
  v56[0] = 0;
  v57 = 0;
  if( !v61 || !a2 )
    goto LABEL_199;
  v10 = *a2;
  v11 = 0;
  v52 = 0;
  LODWORD(v12) = 0;
  v13 = 0;
  if( !v10 )
    return(unsigned int)v11;
  do
  {
    v65 = ++a2;
    if( v11 < 0 )
      break;
    if( (unsigned __int16)(v10 - 32) > 0x5Au )
      v14 = v9;
    else
      v14 = *((_BYTE *)&_lookuptable_s[-4] + v10) & 0xF;
    v13 = *((unsigned __int8 *)_lookuptable_s + (unsigned int)(v14 + v13 + 8 * v14)) >> 4;
    v55 = v13;
    switch( v13 )
    {
      case 8:
        goto LABEL_199;
      case 0:
        goto LABEL_175;
      case 1:
        v6 = -1;
        v63 = v9;
        v54 = -1;
        v5 = v9;
        v60 = v9;
        v53 = v9;
        v57 = v9;
        break;
      case 2:
        switch( v10 )
        {
          case ' ':
            v5 |= 2u;
            break;
            v5 |= 0x80u;
            break;
          case '+':
            v5 |= 1u;
            break;
          case '-':
            v5 |= 4u;
            break;
          case '0':
            v5 |= 8u;
            break;
        }
        break;
      case 3:
        if( v10 == 42 )
        {
          v50 = *a3;
          a3 += 2;
          v51 = v5 | 4;
          if( v50 >= 0 )
            v51 = v5;
          v5 = v51;
          v60 = abs32(v50);
          v9 = 0;
        }
        else
        {
          v60 = v10 + 2 * (5 * v60 - 24);
        }
        break;
      case 4:
        v6 = v9;
        v54 = v9;
        break;
      case 5:
        if( v10 == 42 )
        {
          v6 = *a3;
          a3 += 2;
          v54 = v6;
          if( v6 < 0 )
          {
            v6 = -1;
            v54 = -1;
          }
        }
        else
        {
          v6 = v10 + 2 * (5 * v6 - 24);
          v54 = v6;
        }
        break;
      case 6:
        switch( v10 )
        {
          case 'I':
            goto LABEL_157;
          case 'h':
            v5 |= 0x20u;
            goto LABEL_146;
          case 'j':
            goto LABEL_157;
          case 'l':
            v46 = *a2;
            if( *a2 == 108 )
              ++a2;
            v47 = 4096;
            if( v46 != 108 )
              v47 = 16;
            v5 |= v47;
            goto LABEL_146;
          case 't':
            goto LABEL_157;
          case 'w':
            v5 |= 0x800u;
            goto LABEL_146;
          case 'z':
LABEL_157:
            v5 |= 0x8000u;
            if( v10 == 73 )
            {
              if( *a2 == 54 && a2[1] == 52 )
              {
                a2 += 2;
                goto LABEL_146;
              }
              if( *a2 == 51 && a2[1] == 50 )
              {
                a2 += 2;
                v5 &= ~0x8000u;
                goto LABEL_146;
              }
            }
            else if( v10 == 106 )
            {
              goto LABEL_146;
            }
            v48 = *a2;
            LOWORD(v48) = v48 - 88;
            if( (unsigned __int16)v48 <= 0x20u )
            {
              v49 = 0x120821001i64;
              if( _bittest64(&v49, v48) )
                goto LABEL_146;
            }
            v55 = v9;
LABEL_175:
            v57 = 1;
            write_char_1(v10, v8, &v52);
            v11 = v52;
LABEL_145:
            v13 = v55;
            break;
        }
        break;
      case 7:
        if( v10 > 0x69u )
        {
          switch( v10 )
          {
            case 'n':
              goto LABEL_199;
            case 'o':
              v15 = 8i64;
              if( (v5 & 0x80u) != 0 )
                v5 |= 0x200u;
              goto LABEL_27;
            case 'p':
              v6 = 16;
              v5 |= 0x8000u;
              goto LABEL_74;
          }
          if( v10 != 115 )
          {
            if( v10 != 117 )
            {
              if( v10 != 120 )
                goto LABEL_107;
              v21 = 39;
              goto LABEL_75;
            }
LABEL_26:
            v15 = 10i64;
LABEL_27:
            a3 += 2;
            if( (v5 & 0x8000) != 0 || (v5 & 0x1000) != 0 )
            {
              v16 = *((_QWORD *)a3 - 1);
            }
            else if( (v5 & 0x20) != 0 )
            {
              if( (v5 & 0x40) != 0 )
                v16 = *((__int16 *)a3 - 4);
              else
                v16 = *((unsigned __int16 *)a3 - 4);
            }
            else if( (v5 & 0x40) != 0 )
            {
              v16 = *(a3 - 2);
            }
            else
            {
              v16 = (unsigned int)*(a3 - 2);
            }
            if( (v5 & 0x40) != 0 && v16 < 0 )
            {
              v16 = -v16;
              v5 |= 0x100u;
            }
            v25 = (unsigned int)v16;
            if( (v5 & 0x9000) != 0 )
              v25 = v16;
            if( v6 >= 0 )
            {
              v5 &= ~8u;
              if( v6 > 512 )
                v6 = 512;
            }
            else
            {
              v6 = 1;
            }
            v26 = v62;
            v27 = (char *)&DstCh[255] + 1;
            v53 &= -(v25 != 0);
            v28 = v53;
            while( 1 )
            {
              v29 = v6--;
              if( v29 <= 0 && !v25 )
                break;
              v30 = v25 % v15;
              v25 /= v15;
              v31 = v30 + 48;
              if( (int)v30 + 48 > 57 )
                v31 = v30 + v26 + 48;
              *v27-- = v31;
            }
            v54 = v6;
            LODWORD(v12) = (unsigned int)&DstCh[64] + 383 - (_DWORD)v27;
            v7 = (wchar_t *)(v27 + 1);
            if( (v5 & 0x200) != 0 )
            {
              v9 = 0;
              if( !(_DWORD)v12 || (v53 = v28, *(_BYTE *)v7 != 48) )
              {
                v7 = (wchar_t *)((char *)v7 - 1);
                v53 = v28;
                LODWORD(v12) = v12 + 1;
                *(_BYTE *)v7 = 48;
              }
            }
            else
            {
              v9 = 0;
            }
            goto LABEL_107;
          }
        }
        else
        {
          if( v10 == 105 )
            goto LABEL_25;
          if( v10 == 67 )
          {
            if( (v5 & 0x830) == 0 )
              v5 |= 0x20u;
            goto LABEL_45;
          }
          if( v10 != 83 )
          {
            if( v10 != 88 )
            {
              if( v10 == 90 )
              {
                v17 = *(unsigned __int16 **)a3;
                a3 += 2;
                if( v17 && (v7 = (wchar_t *)*((_QWORD *)v17 + 1)) != 0i64 )
                {
                  v18 = *v17;
                  if( v17[1] < (unsigned __int16)v18 )
                    goto LABEL_199;
                  LODWORD(v12) = *v17;
                  if( (v5 & 0x800) != 0 )
                  {
                    if( (v18 & 1) != 0 || ((unsigned __int8)v7 & 1) != 0 )
                      goto LABEL_199;
                    LODWORD(v12) = v18 >> 1;
                    v57 = 1;
                  }
                  else
                  {
                    v57 = v9;
                  }
                }
                else
                {
                  v12 = -1i64;
                  v7 = (wchar_t *)"(null)";
                  do
                    ++v12;
                  while( aNull_2[v12] != (_BYTE)v9 );
                }
                goto LABEL_107;
              }
              if( v10 != 99 )
              {
                if( v10 == 100 )
                {
LABEL_25:
                  v5 |= 0x40u;
                  goto LABEL_26;
                }
LABEL_107:
                if( v63 != v9 )
                {
                  v13 = v55;
                  v8 = v61;
                  break;
                }
                if( (v5 & 0x40) == 0 )
                  goto LABEL_116;
                if( (v5 & 0x100) != 0 )
                {
                  v32 = 45;
                  goto LABEL_113;
                }
                if( (v5 & 1) != 0 )
                {
                  v32 = 43;
                  goto LABEL_113;
                }
                if( (v5 & 2) != 0 )
                {
                  v32 = 32;
LABEL_113:
                  v33 = 1;
                  v59[0] = v32;
                  v53 = 1;
                }
                else
                {
LABEL_116:
                  v33 = v53;
                }
                v34 = v61;
                v35 = v60 - v12 - v33;
                v64 = v35;
                if( (v5 & 0xC) == 0 && v35 > 0 )
                {
                  v36 = 32;
                  do
                    write_char_1(v36, v34, &v52);
                  while( v52 != -1 && v37 > 0 );
                  v33 = v53;
                }
                write_string_2(v59, v33, v34, &v52);
                v38 = v61;
                if( (v5 & 0xC) == 8 && v35 > 0 )
                {
                  do
                    write_char_1(48, v38, &v52);
                  while( v52 != -1 && v39 > 0 );
                  v35 = v64;
                }
                if( v57 || (int)v12 <= 0 )
                {
                  write_string_2((__int16 *)v7, v12, v38, &v52);
                  v8 = v61;
                  v9 = 0;
LABEL_138:
                  v11 = v52;
                }
                else
                {
                  v40 = (const char *)v7;
                  v41 = v12;
                  while( 1 )
                  {
                    --v41;
                    v42 = safecrt_mbtowc((wchar_t *)v56, v40, _mb_cur_max);
                    if( v42 == 2 )
                      --v41;
                    v8 = v61;
                    if( v42 <= 0 )
                      break;
                    write_char_1(v56[0], v61, &v52);
                    v40 += v43;
                    v9 = 0;
                    if( v41 <= 0 )
                    {
                      a2 = v65;
                      goto LABEL_138;
                    }
                  }
                  a2 = v65;
                  v11 = -1;
                  v52 = -1;
                  v9 = 0;
                }
                if( v11 >= 0 )
                {
                  for( i = (v5 & 4) == 0; !i && v35 > 0; i = v52 == -1 )
                  {
                    --v35;
                    write_char_1(32, v8, &v52);
                    v11 = v52;
                  }
                }
                v6 = v54;
                goto LABEL_145;
              }
LABEL_45:
              v19 = *(_WORD *)a3;
              a3 += 2;
              v56[0] = v19;
              v57 = 1;
              if( (v5 & 0x20) != 0 )
              {
                SrcCh[0] = v19;
                SrcCh[1] = v9;
                v20 = safecrt_mbtowc(DstCh, SrcCh, _mb_cur_max);
                v9 = 0;
                if( v20 < 0 )
                  v63 = 1;
              }
              else
              {
                DstCh[0] = v19;
              }
              v7 = DstCh;
              LODWORD(v12) = 1;
              goto LABEL_107;
            }
LABEL_74:
            v21 = 7;
LABEL_75:
            v62 = v21;
            if( (v5 & 0x80u) != 0 )
            {
              v53 = 2;
              v59[0] = 48;
              v59[1] = v21 + 81;
            }
            v15 = 16i64;
            goto LABEL_27;
          }
          if( (v5 & 0x830) == 0 )
            v5 |= 0x20u;
        }
        v7 = *(wchar_t **)a3;
        v22 = v6;
        if( v6 == -1 )
          v22 = 0x7FFFFFFF;
        a3 += 2;
        if( (v5 & 0x20) != 0 )
        {
          v23 = (const char *)v7;
          if( !v7 )
          {
            v7 = (wchar_t *)"(null)";
            v23 = "(null)";
          }
          LODWORD(v12) = v9;
          if( v22 > 0 )
          {
            do
            {
              if( *v23 == (_BYTE)v9 )
                break;
              ++v23;
              LODWORD(v12) = v12 + 1;
            }
            while( (int)v12 < v22 );
          }
        }
        else
        {
          v57 = 1;
          v24 = L"(null)";
          if( v7 )
            v24 = v7;
          v7 = (wchar_t *)v24;
          while( v22 )
          {
            --v22;
            if( *v24 == (_WORD)v9 )
              break;
            ++v24;
          }
          LODWORD(v12) = v24 - v7;
        }
        goto LABEL_107;
    }
LABEL_146:
    v10 = *a2;
  }
  while( *a2 );
  if( !v13 || v13 == 7 )
    return(unsigned int)v11;
LABEL_199:
  xHalTimerWatchdogStop(0i64, 0i64);
  return 0xFFFFFFFFi64;
}

Referenced by:

swoutput_s