CmpCheckLeaf

INT64 __fastcall CmpCheckLeaf(UINT64 a1, INT64 a2, _WORD *a3, UINT64 a4, INT64 a5){
  int v6; 
  int v7; 
  __int16 v8; 
  char v9; 
  int v11; 
  unsigned int v12; 
  __int64 v13; 
  _WORD *v14; 
  bool v15; 
  __int64 v16; 
  unsigned __int64 v17; 
  __int64 v18; 
  int *v19; 
  int v20; 
  int v21; 
  unsigned int v22; 
  unsigned int v23; 
  __int64 v24; 
  bool v25; 
  _WORD *v26; 
  unsigned int v27; 
  unsigned int v28; 
  UINT8 *v29; 
  __int16 v30; 
  UINT16 v31; 
  int FastLeafHintForUnicodeString; 
  int v34; 
  INT64 v35; 
  __int64 v36; 
  UNICODE_STRING Component; 
  __int64 dst; 
  ULONG_PTR BugCheckParameter3; 
  LODWORD(BugCheckParameter3) = a4;
  v6 = 0;
  v36 = 0i64;
  v7 = a2;
  v8 = *a3 - 26220;
  LODWORD(v36) = -1;
  v9 = 0;
  Component = 0i64;
  if( (v8 & 0xFDFF) != 0 )
    return 0i64;
  v11 = 0;
  if( !a3[1] )
    return 0i64;
  v12 = -1073741492;
  while( 1 )
  {
    v13 = *(unsigned int *)&a3[4 * v11 + 2];
    v14 = &a3[4 * v11];
    dst = 0i64;
    v15 = (*(_BYTE *)(a1 + 140) & 1) == 0;
    LODWORD(dst) = -1;
    if( !v15 )
      goto LABEL_20;
    if( ((unsigned int)v13 & 0x7FFFFFFF) < *(_DWORD *)(632 * ((unsigned __int64)(unsigned int)v13 >> 31) + a1 + 272)
      && (v13 & 7) == 0 )
    {
      v16 = (unsigned int)v13 >> 31;
      if( (unsigned int)(v13 + ((_DWORD)v16 << 31)) < *(_DWORD *)(632 * v16 + a1 + 272) )
      {
        v17 = *(_QWORD *)(*(_QWORD *)(632 * v16 + a1 + 280) + 8i64 * (((unsigned int)v13 >> 21) & 0x3FF))
            + 24 * (((unsigned __int64)(unsigned int)v13 >> 12) & 0x1FF);
        if( v17 )
        {
          if( (*(_BYTE *)(v17 + 8) & 2) == 0 )
          {
            v18 = (*(__int64(__fastcall **)(UINT64, _QWORD, __int64 *))(a1 + 8))(a1, (unsigned int)v13, &dst);
            if( !v18 )
              goto LABEL_19;
            v19 = (int *)(v18 - 4);
            if( !v19 )
              goto LABEL_19;
            v20 = (int)v19;
            v21 = *v19;
            v22 = v20 - (*(_DWORD *)(v17 + 8) & 0xFFFFFFF0);
            v23 = -v21;
            v25 = 0;
            if( v21 < 0 && v23 - 8 <= 0xFFFF8 )
            {
              v24 = *(unsigned int *)((*(_QWORD *)(v17 + 8) & 0xFFFFFFFFFFFFFFF0ui64) + 8);
              if( v23 <= (unsigned __int64)(v24 - 32) && v22 - v21 <= (unsigned int)v24 && v22 >= 0x20 )
                v25 = 1;
            }
            (*(void(__fastcall **)(UINT64, __int64 *))(a1 + 16))(a1, &dst);
            if( v25 )
            {
LABEL_19:
              v6 = 0;
LABEL_20:
              v26 = (_WORD *)(*(__int64(__fastcall **)(UINT64, _QWORD, __int64 *, __int64))(a1 + 8))(
                               a1,
                               *((unsigned int *)v14 + 1),
                               &v36,
                               v13);
              if( !v26 )
              {
                LODWORD(v35) = 0;
                SetFailureLocation(a5, 0i64, 23i64, 3221225626i64, v35);
                return 3221225626i64;
              }
              v27 = -4 - *((_DWORD *)v26 - 1);
              if( v27 < 0x4C || (v28 = (unsigned __int16)v26[36], v28 > v27 - 76) )
              {
LABEL_29:
                (*(void(__fastcall **)(UINT64, __int64 *))(a1 + 16))(a1, &v36);
                goto LABEL_30;
              }
              v29 = (UINT8 *)(v26 + 38);
              v30 = v26[1] & 0x20;
              Component.MaximumLength = v26[36];
              Component.Length = v28;
              Component.Buffer = v26 + 38;
              if( *a3 == 26732 )
              {
                if( v30 )
                {
                  for( ; v28; --v28 )
                  {
                    v31 = *v29;
                    if( (unsigned __int8)v31 >= 0x61u )
                    {
                      if( (unsigned __int8)v31 > 0x7Au )
                        v31 = NLS_UPCASE(*v29);
                      else
                        v31 -= 32;
                    }
                    ++v29;
                    v6 = v31 + 37 * v6;
                  }
LABEL_28:
                  if( *((_DWORD *)v14 + 2) != v6 )
                  {
                    v9 = 1;
                    if( (v7 & 0x20000) != 0 || !BYTE3(NlsMbCodePageTag) && (CmpBootType & 6) == 0 )
                    {
                      v34 = 16;
                      goto LABEL_56;
                    }
                    LODWORD(v35) = 32;
                    SetFailureLocation(a5, 1i64, 23i64, 3221225804i64, v35);
                    if( !HvpMarkCellDirty(a1, (unsigned int)BugCheckParameter3, 0) )
                    {
                      v34 = 48;
                      v12 = -1073741443;
LABEL_56:
                      LODWORD(v35) = v34;
                      SetFailureLocation(a5, 0i64, 23i64, v12, v35);
                      (*(void(__fastcall **)(UINT64, __int64 *))(a1 + 16))(a1, &v36);
                      return v12;
                    }
                    *((_DWORD *)v14 + 2) = v6;
                    *(_DWORD *)(*(_QWORD *)(a1 + 64) + 4088i64) |= 4u;
                  }
                  goto LABEL_29;
                }
                FastLeafHintForUnicodeString = CmpHashUnicodeComponent(&Component);
              }
              else
              {
                if( v30 )
                {
                  LODWORD(dst) = 0;
                  if( v28 < 4 )
                  {
                    if( !v28 )
                      goto LABEL_28;
                  }
                  else
                  {
                    v28 = 4;
                  }
                  memmove((UINT8 *)&dst, v29, v28);
                  v6 = dst;
                  goto LABEL_28;
                }
                FastLeafHintForUnicodeString = CmpGenerateFastLeafHintForUnicodeString(&Component.Length);
              }
              v6 = FastLeafHintForUnicodeString;
              goto LABEL_28;
            }
          }
        }
      }
    }
LABEL_30:
    if( ++v11 >= (unsigned int)(unsigned __int16)a3[1] )
      break;
    v6 = 0;
  }
  if( !v9 )
    return 0i64;
  return 2147483690i64;
}

Referenced by:

CmpCheckKey