RtlpMuiRegGetInstalledLanguageIndex

INT64 __fastcall RtlpMuiRegGetInstalledLanguageIndex(INT64 a1, INT64 a2, INT16 a3, _WORD *a4){
  unsigned int v4; 
  __int64 v5; 
  char v8; 
  __int64 v9; 
  int v10; 
  __int64 v11; 
  __int64 v12; 
  __int64 v13; 
  const WCHAR *v14; 
  struct _UNICODE_STRING DestinationString; 
  UINT64 Lcid; 
  v4 = 0;
  v5 = a3;
  LODWORD(Lcid) = 0;
  v8 = 1;
  DestinationString = 0i64;
  if( !a1 )
    return(unsigned int)-1073741811;
  v9 = *(_QWORD *)(a1 + 24);
  if( (_DWORD)a2 == 3 )
  {
    v10 = 0;
    if( *(_WORD *)(v9 + 6) )
    {
      v11 = *(_QWORD *)(v9 + 16);
      while( 1 )
      {
        v12 = 28i64 * v10;
        if( (*(_WORD *)(v12 + v11) & 0x1020) == 32 && *(_WORD *)(v12 + v11 + 6) == (_WORD)v5 && a4 )
          break;
        if( ++v10 >= *(unsigned __int16 *)(v9 + 6) )
          goto LABEL_10;
      }
      *a4 = v10;
      return v4;
    }
LABEL_10:
    v13 = *(_QWORD *)(a1 + 32);
    if( v13 && (v5 & 0x8000u) == 0i64 && (int)v5 < *(unsigned __int16 *)(v13 + 6) )
      v14 = (const WCHAR *)(*(_QWORD *)(v13 + 24) + 2i64 * *(__int16 *)(*(_QWORD *)(v13 + 16) + 2 * v5));
    else
      v14 = 0i64;
    if( !v14 )
      return(unsigned int)-1073741772;
    RtlInitUnicodeString(&DestinationString, v14, v13);
    if( !RtlCultureNameToLCID(&DestinationString, &Lcid) )
      return(unsigned int)-1073741772;
    LOWORD(v5) = Lcid;
    LODWORD(a2) = 1;
    v8 = 0;
  }
  if( (_DWORD)a2 == 1 )
    return(unsigned int)RtlpMuiRegGetInstalledLanguageIndexByLangId(a1, v5, v8, a4);
  if( (_DWORD)a2 != 2 )
    return(unsigned int)-1073741772;
  if( (__int16)v5 <= 0 || (__int16)v5 >= (int)*(unsigned __int16 *)(v9 + 6) )
    return(unsigned int)-1073741811;
  if( a4 )
    *a4 = v5;
  return v4;
}

Referenced by:

RtlpLoadPolicyLanguageSpec
RtlpMuiRegConfigMatchesInstalled
RtlpMuiRegValidateConfigNode