CompareUnicodeStrings

__int64 __fastcall CompareUnicodeStrings(unsigned __int16 *a1, unsigned __int16 *a2, unsigned int a3){
  __int64 v4; 
  unsigned int v6; 
  unsigned int v7; 
  UINT16 v8; 
  UINT16 v9; 
  unsigned int v10; 
  UINT16 *v11; 
  UINT16 *v12; 
  UINT16 v13; 
  __int64 v15; 
  v4 = *a1 >> 1;
  v6 = *a2 >> 1;
  if( (_DWORD)v4 == 1 && **((_WORD **)a1 + 1) == 92 && v6 > 1 && **((_WORD **)a2 + 1) == 92 )
    return 1i64;
  v7 = *a1 >> 1;
  if( (unsigned int)v4 >= v6 )
    v7 = *a2 >> 1;
  if( a3 > v7 )
    a3 = v7;
  v8 = 0;
  v9 = 0;
  v10 = 0;
  if( a3 )
  {
    v15 = *((_QWORD *)a1 + 1);
    do
    {
      v8 = *(_WORD *)(v15 + 2i64 * v10);
      v9 = *(_WORD *)(*((_QWORD *)a2 + 1) + 2i64 * v10);
      if( v8 != v9 )
        break;
      ++v10;
    }
    while( v10 < a3 );
  }
  if( v10 == a3 )
  {
    v11 = (UINT16 *)(*((_QWORD *)a1 + 1) + 2i64 * v10);
    v12 = (UINT16 *)(*((_QWORD *)a2 + 1) + 2i64 * v10);
    if( v10 >= v7 )
      goto LABEL_19;
    do
    {
      v8 = *v11++;
      v9 = *v12++;
      if( v8 != v9 )
      {
        NLS_UPCASE(v8);
        v9 = NLS_UPCASE(v13);
        if( v8 != v9 )
          break;
      }
      ++v10;
    }
    while( v10 < v7 );
  }
  if( v10 < v7 )
  {
    if( v8 == 92 )
      return 0i64;
    if( v9 == 92 )
      return 3i64;
    if( v8 < v9 )
      return 0i64;
    if( v8 > v9 )
      return 3i64;
  }
LABEL_19:
  if( (unsigned int)v4 < v6 )
    return *(_WORD *)(*((_QWORD *)a2 + 1) + 2 * v4) == 92;
  if( (unsigned int)v4 > v6 )
    return 3i64;
  return 2i64;
}

Referenced by:

RtlFindUnicodePrefix
RtlInsertUnicodePrefix