Normalization__IsNormalized

__int64 __fastcall Normalization__IsNormalized(__int64 a1, unsigned __int16 *a2, int a3, _BYTE *a4){
  int v4; 
  unsigned __int16 *v5; 
  int v8; 
  unsigned int v9; 
  __int64 v10; 
  int v11; 
  __int64 v12; 
  int v13; 
  int v14; 
  int v15; 
  int v16; 
  int v17; 
  unsigned __int8 v18; 
  unsigned __int8 v19; 
  unsigned __int8 v20; 
  unsigned __int8 v21; 
  unsigned __int8 v22; 
  unsigned __int8 v23; 
  unsigned int v24; 
  int CanCombineWithStartFirstPair; 
  unsigned int v26; 
  int CanCombineWithStartBase; 
  INT64 v28; 
  unsigned __int8 v29; 
  unsigned __int8 v30; 
  unsigned __int8 v31; 
  INT64 v32; 
  unsigned int v33; 
  int v34; 
  char v35[12]; 
  unsigned __int8 v36; 
  int v37; 
  _BYTE *v38; 
  v38 = a4;
  v37 = a3;
  v4 = a3;
  v5 = a2;
  if( !a2 )
    return 3221225485i64;
  v32 = 0i64;
  v29 = 0;
  *(_DWORD *)v35 = 0;
  v36 = 0;
  *(_QWORD *)&v35[4] = a2 - 1;
  v33 = 0;
  v31 = 0;
  v30 = 0;
  if( a3 <= 0 )
    goto LABEL_95;
  v8 = *(_DWORD *)(a1 + 28);
  v34 = v8;
  do
  {
    v9 = *v5;
    if( (int)v9 < v8 )
      goto LABEL_94;
    v10 = *(_QWORD *)(a1 + 32);
    LOBYTE(v11) = *(_BYTE *)(((unsigned __int64)*v5 >> 7) + v10);
    if( !(_BYTE)v11 || (_BYTE)v11 == 0xFB && *(_BYTE *)(a1 + 113) )
      goto LABEL_93;
    while( 1 )
    {
      while( 1 )
      {
        while( 1 )
        {
          v12 = (unsigned __int8)v11;
          v11 = (unsigned __int8)v11;
          if( !(_BYTE)v11 )
            goto LABEL_91;
          v13 = v11 - 251;
          if( !v13 )
            goto LABEL_90;
          v14 = v13 - 1;
          if( !v14 )
            return 3221227287i64;
          v15 = v14 - 1;
          if( !v15 )
            goto LABEL_31;
          v16 = v15 - 1;
          if( v16 )
            break;
          if( v4 <= 1 )
            return 3221227287i64;
          ++v5;
          v37 = --v4;
          v11 = *v5;
          if( (unsigned __int16)(v11 + 9216) > 0x3FFu )
            return 3221227287i64;
          v9 = v11 + ((v9 - 55287) << 10);
          LOBYTE(v11) = *(_BYTE *)(((__int64)(int)v9 >> 7) + v10);
        }
        if( v16 != 1 )
        {
          v17 = *(unsigned __int8 *)((v9 & 0x7F) + (v12 << 7) + *(_QWORD *)(a1 + 40) - 128);
          if( !(_BYTE)v17 )
            goto LABEL_91;
          v18 = v17 & 0xC0;
          v19 = v17 & 0x3F;
          if( (v17 & 0x3F) == 0 || v19 == 63 )
          {
            switch( v17 )
            {
              case 64:
                goto LABEL_89;
              case 127:
LABEL_90:
                if( *(_BYTE *)(a1 + 113) )
                  goto LABEL_91;
                break;
              case 128:
                goto LABEL_89;
              case 191:
                goto LABEL_31;
              case 192:
                Normalization__GetLastChar(a1, (__int64)v5, &v35[4], (unsigned int *)&v32, &v29, &v36);
                if( (v29 | v36) == 0x80
                  && (unsigned int)Normalization__CanCombinableCharactersCombine(a1, (unsigned int)v32, v9) )
                {
                  goto LABEL_31;
                }
                goto LABEL_89;
              case 255:
                if( !v9 && v4 <= 1 )
                  goto LABEL_95;
                break;
              default:
                goto LABEL_41;
            }
            return 3221227287i64;
          }
LABEL_41:
          if( (v17 & 0x80) != 0 )
          {
            Normalization__GetLastChar(a1, (__int64)v5, &v35[4], (unsigned int *)&v32, &v29, &v36);
            v20 = v29;
            if( !v29 || v29 == 63 )
            {
              v33 = v32;
              v31 = v29;
              v30 = v36;
              if( ((v36 - 64) & 0xBF) == 0
                && v18 == 0xC0
                && (unsigned int)Normalization__CanCombinableCharactersCombine(a1, (unsigned int)v32, v9) )
              {
                goto LABEL_31;
              }
              goto LABEL_64;
            }
            v21 = v36;
            if( (v36 & 0xBF) != 0 )
            {
              if( v29 > v19 )
                goto LABEL_31;
              if( v18 != 0xC0 || v29 == v19 )
                goto LABEL_63;
              v22 = v30;
              v23 = v31;
              if( (((v31 | v30) - 64) & 0xBF) != 0 && (v30 != 64 || v31 && v31 != 63) )
              {
                v24 = v33;
              }
              else
              {
                v24 = v33;
                if( (unsigned int)Normalization__CanCombinableCharactersCombine(a1, v33, v9) )
                  goto LABEL_31;
                v22 = v30;
              }
              if( v19 >= v23 || (v22 & 0xBF) != 0 || (unsigned __int8)(v23 - 1) > 0x3Du )
                goto LABEL_63;
              if( v23 == *(_BYTE *)(a1 + 116) )
              {
                if( v19 >= *(_BYTE *)(a1 + 114) )
                {
                  if( v19 != *(_BYTE *)(a1 + 115) )
                  {
LABEL_63:
                    v4 = v37;
LABEL_64:
                    v29 = v19;
                    v36 = v18;
                    goto LABEL_92;
                  }
                  goto LABEL_61;
                }
              }
              else if( v23 == *(_BYTE *)(a1 + 118) && v19 == *(_BYTE *)(a1 + 117) )
              {
LABEL_61:
                LODWORD(v28) = v9;
                CanCombineWithStartFirstPair = Normalization__CanCombineWithStartFirstPair(
                                                 a1,
                                                 (INT64 *)v35,
                                                 (INT64 *)((char *)&v32 + 4),
                                                 v24,
                                                 v28);
                goto LABEL_62;
              }
              CanCombineWithStartFirstPair = Normalization__CanCombineWithStartBase(
                                               a1,
                                               (INT64 *)((char *)&v32 + 4),
                                               v24,
                                               v9);
LABEL_62:
              if( !CanCombineWithStartFirstPair )
                goto LABEL_63;
LABEL_31:
              *v38 = 0;
              return 0i64;
            }
            HIDWORD(v32) = 0;
            *(_DWORD *)v35 = 0;
            v26 = v32;
            v33 = v32;
            if( v18 != 0xC0 )
              goto LABEL_81;
            if( v36 == 64 )
            {
              if( (unsigned int)Normalization__CanCombinableCharactersCombine(a1, (unsigned int)v32, v9) )
                goto LABEL_31;
              v26 = v33;
            }
            if( v20 <= v19 )
            {
LABEL_81:
              v31 = v20;
              v30 = v21;
              goto LABEL_63;
            }
            if( v20 == *(_BYTE *)(a1 + 116) )
            {
              if( v19 >= *(_BYTE *)(a1 + 114) )
              {
                if( v19 != *(_BYTE *)(a1 + 115) )
                  goto LABEL_81;
                goto LABEL_76;
              }
            }
            else if( v20 == *(_BYTE *)(a1 + 118) && v19 == *(_BYTE *)(a1 + 117) )
            {
LABEL_76:
              LODWORD(v28) = v9;
              CanCombineWithStartBase = Normalization__CanCombineWithStartFirstPair(
                                          a1,
                                          (INT64 *)v35,
                                          (INT64 *)((char *)&v32 + 4),
                                          v26,
                                          v28);
              goto LABEL_80;
            }
            CanCombineWithStartBase = Normalization__CanCombineWithStartBase(a1, (INT64 *)((char *)&v32 + 4), v26, v9);
LABEL_80:
            if( CanCombineWithStartBase )
              goto LABEL_31;
            goto LABEL_81;
          }
          HIDWORD(v32) = 0;
LABEL_89:
          v33 = v9;
          v31 = v19;
          v30 = v18;
          goto LABEL_64;
        }
        if( (int)v9 >= 44032 )
          break;
        if( v4 > 1 && CanComposeHangul(v9, v5[1]) )
          goto LABEL_31;
        if( ((*(_DWORD *)a1 - 13) & 0xFFFFFEFF) != 0 || v9 - 4447 > 1 )
          goto LABEL_24;
LABEL_19:
        LOBYTE(v11) = -5;
      }
      if( (int)v9 < 55204 )
        break;
      if( v9 - 55216 > 0x16 && v9 - 55243 > 0x30 )
        goto LABEL_19;
LABEL_24:
      LOBYTE(v11) = 0;
    }
    if( *(_BYTE *)(a1 + 112) == 1 || v4 > 1 && CanComposeHangul(v9, v5[1]) )
      goto LABEL_31;
LABEL_91:
    v29 = 0;
    v36 = 0;
LABEL_92:
    LODWORD(v32) = v9;
    *(_QWORD *)&v35[4] = v5;
LABEL_93:
    v8 = v34;
LABEL_94:
    --v4;
    ++v5;
    v37 = v4;
  }
  while( v4 > 0 );
LABEL_95:
  *v38 = 1;
  return 0i64;
}

Referenced by:

RtlIsNormalizedString