RtlpMuiRegValidateLIPLanguage

__int64 __fastcall RtlpMuiRegValidateLIPLanguage(__int64 a1, int a2){
  __int64 v3; 
  int v4; 
  int v5; 
  _WORD *v6; 
  int v7; 
  unsigned __int16 v8; 
  unsigned __int8 v9; 
  INT64 v10; 
  __int64 v11; 
  _WORD *v12; 
  __int16 v13; 
  __int16 v14; 
  __int64 v15; 
  INT16 v16; 
  __int16 v17; 
  __int16 v18; 
  INT16 ResultIndexRtrn; 

  v3 = a1;
  v4 = 0;
  v5 = 0;
  v6 = (_WORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 24) + 16i64) + 28i64 * a2);
  v7 = 0;
  while( 1 )
  {
    v8 = v6[4];
    v9 = (v8 >> (2 * v5)) & 3;
    if( !v9 )
      goto LABEL_28;
    v10 = (__int16)v6[v5 + 6];
    if( v9 == 2 )
      break;
    v15 = *(_QWORD *)(v3 + 24);
    ResultIndexRtrn = -1;
    if( RtlpMuiRegGetInstalledLangInfoIndex((_MUILANGUAGES *)v15, v9, v10, &ResultIndexRtrn) < 0
      || (v16 = ResultIndexRtrn, ResultIndexRtrn < 0)
      || ResultIndexRtrn >= (int)*(unsigned __int16 *)(v15 + 6)
      || ResultIndexRtrn == a2 )
    {
      v6[4] = v8 & ~(3 << v7);
      goto LABEL_27;
    }
    v17 = *(_WORD *)(28i64 * ResultIndexRtrn + *(_QWORD *)(v15 + 16));
    v18 = v8 & ~(3 << v7);
    if( (v17 & 4) != 0 )
    {
      v6[4] = v18;
LABEL_27:
      v3 = a1;
      goto LABEL_28;
    }
    v3 = a1;
    if( (v17 & 0x1820) == 2080 )
    {
      v6[4] = v18 | (2 << v7);
      v6[v5 + 6] = v16;
LABEL_25:
      ++v4;
      goto LABEL_28;
    }
    v6[4] = v18;
LABEL_28:
    ++v5;
    v7 += 2;
    if( v7 >= 8 )
      goto LABEL_31;
  }
  if( (v10 & 0x8000u) != 0i64
    || (v11 = *(_QWORD *)(v3 + 24), (int)v10 >= *(unsigned __int16 *)(v11 + 6))
    || (_DWORD)v10 == a2 )
  {
    v6[4] = v8 & ~(3 << v7);
    v6[v5 + 6] = 0;
    goto LABEL_28;
  }
  v12 = (_WORD *)(*(_QWORD *)(v11 + 16) + 28 * v10);
  if( (*v12 & 4) == 0 )
  {
    if( (*v12 & 0x1820) != 2080 )
    {
      if( v12[2] )
      {
        v6[4] = v8 & ~(3 << v7) | (1 << v7);
        v13 = v12[2];
      }
      else
      {
        v14 = v8 & ~(3 << v7);
        if( (__int16)v12[3] <= 0 )
        {
          v6[4] = v14;
          v13 = 0;
        }
        else
        {
          v6[4] = (3 << v7) | v14;
          v13 = v12[3];
        }
      }
      v6[v5 + 6] = v13;
      goto LABEL_28;
    }
    goto LABEL_25;
  }
  *v6 |= 0x1000u;
LABEL_31:
  if( v4 >= 1 )
    return 0i64;
  *v6 |= 0x1000u;
  return 3221225473i64;
}

Referenced by:

RtlpMuiRegValidateInstalled