CmpDoParseKey

__int64 __fastcall CmpDoParseKey(
        __int64 a1,
        struct _SECURITY_SUBJECT_CONTEXT *a2,
        unsigned __int8 a3,
        __int16 a4,
        const UNICODE_STRING *a5,
        __int64 *a6,
        __int64 a7,
        int a8,
        PADAPTER_OBJECT *a9){
  ULONG_PTR v11; 
  __int16 v12; 
  __m128i v13; 
  __int16 v14; 
  INT64 v15; 
  ULONG_PTR v16; 
  _CM_TRANS_PTR v17; 
  ULONG_PTR v18; 
  int v19; 
  int v20; 
  unsigned int v21; 
  int v22; 
  int v23; 
  int v24; 
  char v25; 
  WCHAR v26; 
  INT64 v27; 
  _GUID *v28; 
  char v29; 
  int started; 
  int v31; 
  INT64 *v32; 
  INT64 *v33; 
  INT64 v34; 
  __int64 v35; 
  _CM_KEY_CONTROL_BLOCK *v36; 
  bool v37; 
  CHAR v38; 
  __int16 v39; 
  _DWORD *v40; 
  PCUNICODE_STRING v41; 
  unsigned int v42; 
  unsigned int v43; 
  _CM_TRANS *v44; 
  CHAR v45; 
  int KeyBody; 
  struct _ACCESS_STATE *v47; 
  _UNICODE_STRING *v48; 
  UINT64 v49; 
  UINT64 v50; 
  int v51; 
  __int64 v53; 
  int ComponentHashAtIndex; 
  __int64 v55; 
  bool v56; 
  int v57; 
  unsigned __int64 v58; 
  char v59; 
  __int16 v60; 
  __int16 v61; 
  wchar_t *v62; 
  __int16 v63; 
  wchar_t *v64; 
  __int16 v65; 
  int v66; 
  int v67; 
  int v68; 
  char v69; 
  int SymbolicLinkTarget; 
  __int64 v71; 
  ULONG_PTR v72; 
  INT64 *v73; 
  CHAR v74; 
  int v75; 
  __int64 v76; 
  unsigned int v77; 
  __m128i *v78; 
  __int64 v79; 
  ULONG_PTR v80; 
  unsigned int Logic; 
  int v82; 
  UNICODE_STRING *v83; 
  int Child; 
  __int64 v85; 
  unsigned int v86; 
  __int64 v87; 
  __int16 v88; 
  __int64 v89; 
  INT64 v90; 
  __int64 v91; 
  unsigned int v92; 
  _CM_COMPONENT_HASH v93; 
  __int64 v94; 
  UINT64 v95; 
  _DWORD *v96; 
  _CMHIVE *v97; 
  int HiveRootCell; 
  INT64 v99; 
  INT64 v100; 
  INT64 v101; 
  INT8 v102; 
  int v103; 
  UINT64 v104; 
  int v105; 
  _CM_KEY_NODE *KeyNodeForKcb; 
  __int64 v107; 
  INT64 v108; 
  INT64 v109; 
  __int64 CurrentThreadProcess; 
  _EJOB *ProcessServerSilo; 
  int ServerSiloServiceSessionId; 
  int SessionId; 
  INT64 v114; 
  INT64 v115; 
  INT64 v116; 
  INT64 v117; 
  INT64 v118; 
  _UNICODE_STRING *v119; 
  UINT64 v120; 
  UINT8 v121; 
  INT64 v122; 
  int v123; 
  UNICODE_STRING *v124; 
  int v125; 
  INT8 v126; 
  INT64 v127; 
  INT64 v128; 
  _UNICODE_STRING *v130; 
  UINT64 v131; 
  UINT8 v132; 
  _UNICODE_STRING *ComponentNameAtIndex; 
  UINT64 v134; 
  UINT8 v135; 
  unsigned int v136; 
  INT64 v137; 
  _UNICODE_STRING *v138; 
  UINT64 v139; 
  UINT8 v140; 
  INT64 v141; 
  _UNICODE_STRING *v142; 
  UINT64 v143; 
  UINT8 v144; 
  __int64 v145; 
  _EJOB *v146; 
  int v147; 
  int v148; 
  INT64 v149; 
  INT64 v150; 
  _CM_KEY_CONTROL_BLOCK *v151; 
  _UNICODE_STRING *v152; 
  int v153; 
  _CM_KEY_CONTROL_BLOCK *v154; 
  INT64 v155; 
  INT64 v156; 
  int v157; 
  PCUNICODE_STRING v158; 
  unsigned int v159; 
  WCHAR v160; 
  INT64 v161; 
  int v162; 
  PCUNICODE_STRING v163; 
  INT64 a6a; 
  INT64 ObjectCreatedc; 
  INT64 ObjectCreated; 
  INT64 ObjectCreateda; 
  INT64 ObjectCreatedb; 
  ULONG_PTR v169; 
  CHAR v170; 
  CHAR v171[8]; 
  _UNICODE_STRING *v172; 
  char v173; 
  INT64 a1a; 
  __int16 a8a; 
  int a8_2; 
  INT16 v177[2]; 
  char v178; 
  ULONG_PTR BugCheckParameter4; 
  BOOLEAN v180[8]; 
  struct _ACCESS_STATE *a4a; 
  __int16 v182; 
  __m128i *v183; 
  PCUNICODE_STRING String2; 
  PADAPTER_OBJECT DmaAdapter; 
  _GUID *KtmUow; 
  __m128i v187; 
  ULONG_PTR P4; 
  __int64 v189; 
  INT64 v190; 
  int v191[2]; 
  ULONG_PTR BugCheckParameter2; 
  INT64 v193[2]; 
  struct _UNICODE_STRING DestinationString; 
  PADAPTER_OBJECT *v195; 
  INT64 v196[2]; 
  __int128 v197; 
  INT64 a2a[2]; 
  __int128 v199; 
  INT64 v200[2]; 
  __int128 v201; 
  INT64 result[22]; 
  v189 = a1;
  v195 = a9;
  String2 = a5;
  a4a = (struct _ACCESS_STATE *)a2;
  v190 = 0i64;
  v11 = 0i64;
  v12 = 0;
  DestinationString = 0i64;
  v171[6] = 0;
  v13 = *(__m128i *)a6;
  v171[5] = a3;
  v14 = 0;
  v183 = (__m128i *)a6;
  v187 = v13;
  v182 = 0;
  *(_QWORD *)v180 = 0i64;
  *(_OWORD *)v193 = 0i64;
  DmaAdapter = 0i64;
  BugCheckParameter4 = 0i64;
  *(_QWORD *)v191 = 0i64;
  v170 = 0;
  v178 = 0;
  a8a = 0;
  v171[7] = 0;
  v177[0] = 0;
  BugCheckParameter2 = 0i64;
  LODWORD(v190) = -1;
  CmpInitializeDelayDerefContext(v193);
  a8_2 = (unsigned __int8)v15;
  v172 = (_UNICODE_STRING *)v15;
  memset((INT64)result, v15);
  *(_OWORD *)(a7 + 160) = 0i64;
  *(_OWORD *)(a7 + 176) = 0i64;
  *(_OWORD *)(a7 + 192) = 0i64;
  *(_OWORD *)a2a = 0i64;
  WORD1(a2a[0]) = -1;
  *(_OWORD *)v200 = 0i64;
  WORD1(v200[0]) = -1;
  *(_OWORD *)v196 = 0i64;
  WORD1(v196[0]) = -1;
  *(_QWORD *)(a7 + 208) = 0i64;
  *(_OWORD *)(a7 + 216) = 0i64;
  *(_OWORD *)(a7 + 232) = 0i64;
  *(_OWORD *)(a7 + 248) = 0i64;
  *(_OWORD *)(a7 + 264) = 0i64;
  *(_OWORD *)(a7 + 280) = 0i64;
  v199 = 0i64;
  v201 = 0i64;
  v197 = 0i64;
  if( a7 )
    *(_QWORD *)(a7 + 216) = *(_QWORD *)(a7 + 88);
  if( (a4 & 0x100) != 0 )
    *(_DWORD *)a7 |= 0x200u;
  v16 = *(_QWORD *)(a7 + 88);
  v17.0 = *($F21FB2B31E9B30A96ADF077329256E82 *)(a7 + 72);
  P4 = v16;
  *(_QWORD *)(a7 + 88) = 0i64;
  if( v17.0 )
  {
    v107 = *(_QWORD *)(a1 + 56);
    if( v107 && *(_QWORD *)&v17.0 != v107 )
    {
      *(_DWORD *)v171 = -1072103422;
      CmpRecordParseFailure(a7, 256i64, 3222863874i64);
      v48 = 0i64;
      goto LABEL_82;
    }
    KtmUow = 0i64;
  }
  else
  {
    v17.0 = *($F21FB2B31E9B30A96ADF077329256E82 *)(a1 + 56);
    KtmUow = *(_GUID **)(a1 + 64);
  }
  *(_DWORD *)(a7 + 20) = *(unsigned __int16 *)(a1 + 50);
  if( *(_QWORD *)(a1 + 8) != *((_QWORD *)CmpRegistryRootObject + 1) && v16 )
  {
    CmpLockRegistry();
    CmpDereferenceKeyControlBlock(v16);
    v16 = 0i64;
    P4 = 0i64;
    CmpUnlockRegistry();
  }
  v173 = 0;
  if( !v16 )
  {
LABEL_11:
    v171[4] = HIBYTE(a8a);
    if( !v16 )
    {
      v18 = *(_QWORD *)(a1 + 8);
      v19 = CmpComputeComponentHashes(&v187, v177, (INT64)result);
      *(_DWORD *)v171 = v19;
      if( v19 < 0 )
      {
        CmpRecordParseFailure(a7, 1280i64, (unsigned int)v19);
        v48 = v172;
      }
      else
      {
        v14 = v177[0];
        v20 = CmpValidateComponents((unsigned int)v177[0], (INT64)result);
        *(_DWORD *)v171 = v20;
        if( v20 >= 0 )
          goto LABEL_14;
        CmpRecordParseFailure(a7, 1536i64, (unsigned int)v20);
        v48 = v172;
      }
LABEL_79:
      if( HIBYTE(a8a) )
        CmpUnlockHashEntryByKcb(v16);
      goto LABEL_81;
    }
    v18 = v16;
LABEL_14:
    v21 = v14;
    *(_QWORD *)(a7 + 224) = v18;
    *(_QWORD *)(a7 + 248) = v18;
    v22 = ((*(_DWORD *)(v18 + 8) >> 21) & 0x3FF) - (unsigned __int16)v12;
    LODWORD(v183) = v14;
    if( (unsigned int)(v14 + v22) > 0x200 )
    {
      *(_DWORD *)v171 = -1073741811;
      CmpRecordParseFailure(a7, 1792i64, 3221225485i64);
      v48 = v172;
LABEL_78:
      v16 = P4;
      goto LABEL_79;
    }
    if( !v173 )
    {
      if( (*(_DWORD *)a7 & 0x400) != 0 )
        CmpLockRegistryExclusive();
      else
        CmpLockRegistry();
      v21 = (unsigned int)v183;
      v173 = 1;
    }
    v23 = *(_DWORD *)(v189 + 48);
    if( (v23 & 9) != 0 )
    {
      v118 = 3221225852i64;
      if( (v23 & 1) != 0 )
        v118 = 3221226533i64;
      *(_DWORD *)v171 = v118;
      CmpRecordParseFailure(a7, 2048i64, v118);
      v48 = v172;
      goto LABEL_78;
    }
    if( v12 == v14 )
    {
      CmpReferenceKeyControlBlockUnsafe((volatile INT64 *)v18);
      v11 = v18;
      BugCheckParameter4 = v18;
      if( v18 == P4 )
      {
        v74 = v171[4];
        HIBYTE(a8a) = 0;
      }
      else
      {
        CmpLockHashEntrySharedByKcb((_CM_KEY_CONTROL_BLOCK *)v18);
        v74 = 1;
      }
      v171[6] = v74;
    }
    else
    {
      v24 = CmpPerformCompleteKcbCacheLookup(
              v18,
              (unsigned __int16)v12,
              v21,
              (INT64)result,
              a7,
              (INT64 *)&BugCheckParameter4,
              &v171[6],
              &v182);
      *(_DWORD *)v171 = v24;
      if( v24 < 0 || v24 == 259 )
      {
        CmpRecordParseFailure(a7, 2432i64, (unsigned int)v24);
        v11 = BugCheckParameter4;
        goto LABEL_107;
      }
      v25 = v182;
      v11 = BugCheckParameter4;
      v12 += v182;
      *(_QWORD *)(a7 + 232) = BugCheckParameter4;
      *(_BYTE *)(a7 + 256) = v25;
      *(_QWORD *)(a7 + 248) = v11;
    }
    if( v12 == v14 && (*(_DWORD *)a7 & 1) == 0 )
    {
      CmpUnlockHashEntryByKcb(v11);
      v171[6] = 0;
    }
    CmpLockKcbShared((_CM_KEY_CONTROL_BLOCK *)v11);
    if( v12 < v14 )
    {
      DestinationString.Buffer = *(wchar_t **)(CmpGetComponentNameAtIndex((INT64)result, (unsigned int)v12) + 8);
      DestinationString.Length = v187.m128i_i16[0] - 2 * (((__int64)DestinationString.Buffer - v187.m128i_i64[1]) >> 1);
      DestinationString.MaximumLength = DestinationString.Length;
    }
    else
    {
      RtlInitUnicodeString(&DestinationString, 0i64, v26);
    }
    *(_DWORD *)v171 = CmpVEExecuteParseLogic(
                        v11,
                        (__m128i *)&DestinationString,
                        a7,
                        (__m128i *)String2,
                        v171[5],
                        (INT64)a4a + 32);
    CmpUnlockKcb(v11);
    if( *(_DWORD *)v171 == -1073741199 )
    {
      if( CmpOKToFollowLink(*(_QWORD **)(a7 + 64), *(_QWORD *)(v11 + 32)) )
      {
        v28 = KtmUow;
        if( *(_QWORD *)&v17.0 || KtmUow )
        {
          if( *(_QWORD *)(v11 + 32) == CmpMasterHive )
          {
            v27 = 0i64;
            BYTE2(a8_2) = 1;
            v17.0 = 0i64;
            v28 = 0i64;
          }
          else if( (*(_QWORD *)&v17.0 || KtmUow) && *(_WORD *)(v11 + 66) )
          {
            CmpLogUnsupportedOperation(8i64);
            if( !PsIsCurrentThreadInServerSilo() )
            {
              *(_DWORD *)v171 = -1072103419;
              CmpRecordParseFailure(a7, 2816i64, 3222863877i64);
              goto LABEL_107;
            }
            v17.0 = 0i64;
            v28 = 0i64;
          }
        }
        CmpTransSilentIgnore(v27);
        if( !v29 && (*(_QWORD *)&v17.0 || v28) )
        {
          *(_DWORD *)v171 = CmpTransSearchAddTransFromHive(*(_CMHIVE **)(v11 + 32), v17, v28, 0i64, (_CM_TRANS **)v180);
          if( *(int *)v171 < 0 )
          {
            if( v171[6] )
            {
              CmpUnlockHashEntryByKcb(v11);
              v171[6] = 0;
            }
            CmpUnlockRegistry();
            *(_DWORD *)v171 = CmpTransSearchAddTransFromHive(
                                *(_CMHIVE **)(v11 + 32),
                                v17,
                                v28,
                                1ui64,
                                (_CM_TRANS **)v180);
            CmpLockRegistry();
            v90 = *(unsigned int *)v171;
            v173 = 1;
            if( *(int *)v171 >= 0 )
            {
              v90 = 3221226029i64;
              *(_DWORD *)v171 = -1073741267;
            }
            CmpRecordParseFailure(a7, 3072i64, v90);
            v48 = v172;
            goto LABEL_76;
          }
        }
        started = CmpStartKcbStack((INT64)a2a, *(_WORD *)(v11 + 66));
        *(_DWORD *)v171 = started;
        if( started < 0 )
        {
          CmpRecordParseFailure(a7, 3328i64, (unsigned int)started);
        }
        else
        {
          v31 = CmpStartKcbStack((INT64)v200, *(_WORD *)(v11 + 66));
          *(_DWORD *)v171 = v31;
          if( v31 >= 0 )
          {
            v32 = a2a;
            v33 = v200;
            CmpPopulateKcbStack((INT64)a2a, v11);
            if( v12 < v14 )
            {
              while( 1 )
              {
                CmpLockKcbStackShared((INT64)v32);
                v53 = *(_QWORD *)v180;
                if( CmpIsKeyStackDeleted((__int64)v32, *(__int64 *)v180) )
                {
                  if( CmpLoadingSystemHivesActive
                    && (v11 = BugCheckParameter4, (struct _KTHREAD *)CmpMountThread != KeGetCurrentThread())
                    && *(_QWORD *)(BugCheckParameter4 + 32) == CmpMasterHive
                    && (*(_DWORD *)(BugCheckParameter4 + 8) & 0x7FE00000) == 6291456
                    && v12 > 0
                    && (ComponentNameAtIndex = (_UNICODE_STRING *)CmpGetComponentNameAtIndex(
                                                                    (INT64)result,
                                                                    (unsigned int)(v12 - 1)),
                        CmpWaitForHiveMount(ComponentNameAtIndex, v134, v135, (UINT64 *)(a7 + 136))) )
                  {
                    *(_DWORD *)a7 |= 0x100u;
                    v108 = 3840i64;
                    *(_DWORD *)v171 = 259;
                    v109 = 259i64;
                  }
                  else
                  {
                    v108 = 4096i64;
                    *(_DWORD *)v171 = -1073741772;
                    v109 = 3221225524i64;
                  }
                  CmpRecordParseFailure(a7, v108, v109);
                  v48 = v172;
                  v35 = v189;
                  v33 = (INT64 *)v172;
                  goto LABEL_68;
                }
                if( CmpIsKeyStackSymlink((INT64)v32) )
                  break;
                CmpUnlockKcbStack((__int64)v32);
                CmpGetComponentNameAtIndex((INT64)result, (unsigned int)v12);
                ComponentHashAtIndex = CmpGetComponentHashAtIndex((INT64)result, (unsigned int)v12);
                v56 = (*(_DWORD *)a7 & 1) != 0 && v12 == (_DWORD)v183 - 1;
                LODWORD(v169) = ComponentHashAtIndex + 37 * *(_DWORD *)(v11 + 16);
                v57 = CmpWalkOneLevel(
                        v11,
                        (__int64)v32,
                        (__int64 *)v191,
                        (__int64)v33,
                        (__int64)&a8_2 + 1,
                        v55,
                        ComponentHashAtIndex,
                        v169,
                        *(__int64 *)v180,
                        v56,
                        a7);
                *(_DWORD *)v171 = v57;
                if( v57 == -1073741772 )
                {
                  if( !CmpLoadingSystemHivesActive )
                    goto LABEL_106;
                  v11 = BugCheckParameter4;
                  if( (struct _KTHREAD *)CmpMountThread == KeGetCurrentThread()
                    || *(_QWORD *)(BugCheckParameter4 + 32) != CmpMasterHive )
                  {
                    v57 = *(_DWORD *)v171;
LABEL_106:
                    CmpRecordParseFailure(a7, 5504i64, (unsigned int)v57);
                    goto LABEL_107;
                  }
                  if( (*(_DWORD *)(BugCheckParameter4 + 8) & 0x7FE00000) == 6291456 && v12 > 0 )
                  {
                    v130 = (_UNICODE_STRING *)CmpGetComponentNameAtIndex((INT64)result, (unsigned int)(v12 - 1));
                    if( CmpWaitForHiveMount(v130, v131, v132, (UINT64 *)(a7 + 136)) )
                    {
                      *(_DWORD *)a7 |= 0x100u;
                      *(_DWORD *)v171 = 259;
                      CmpRecordParseFailure(a7, 5120i64, 259i64);
                      goto LABEL_107;
                    }
                  }
                  if( (*(_DWORD *)(v11 + 8) & 0x7FE00000) == 0x400000 )
                  {
                    v119 = (_UNICODE_STRING *)CmpGetComponentNameAtIndex((INT64)result, (unsigned int)v12);
                    if( CmpWaitForHiveMount(v119, v120, v121, (UINT64 *)(a7 + 136)) )
                    {
                      *(_DWORD *)a7 |= 0x100u;
                      *(_DWORD *)v171 = 259;
                      CmpRecordParseFailure(a7, 5376i64, 259i64);
                      v48 = v172;
                      goto LABEL_76;
                    }
                  }
                  v14 = v177[0];
                  v57 = *(_DWORD *)v171;
                }
                if( v57 < 0 )
                  goto LABEL_106;
                v72 = *(_QWORD *)v191;
                ++*(_BYTE *)(a7 + 257);
                *(_QWORD *)(a7 + 240) = v72;
                *(_QWORD *)(a7 + 248) = v72;
                CmpDereferenceKeyControlBlockUnsafe((volatile INT64 *)v11);
                v171[6] = BYTE1(a8_2);
                ++v12;
                BugCheckParameter4 = v72;
                v73 = v32;
                *(_QWORD *)v191 = 0i64;
                v32 = v33;
                BYTE1(a8_2) = 0;
                v33 = v73;
                v11 = v72;
                if( v12 >= v14 )
                  goto LABEL_39;
              }
              SymbolicLinkTarget = CmpGetSymbolicLinkTarget(
                                     (__int64)v32,
                                     (__int64)result,
                                     v12,
                                     v14,
                                     v53,
                                     a7,
                                     (__int64)v193,
                                     (struct _UNICODE_STRING *)String2,
                                     (ULONG_PTR *)(a7 + 88));
              *(_DWORD *)v171 = SymbolicLinkTarget;
              if( SymbolicLinkTarget < 0 )
              {
                CmpRecordParseFailure(a7, 4608i64, (unsigned int)SymbolicLinkTarget);
                goto LABEL_107;
              }
              *(_DWORD *)a7 &= ~8u;
              if( !*(_QWORD *)(a7 + 64) )
              {
                v71 = *(_QWORD *)(v11 + 32);
                if( (*(_DWORD *)(v71 + 4152) & 1) != 0 )
                  *(_QWORD *)(a7 + 64) = v71;
              }
              *(_DWORD *)v171 = 260;
              CmpRecordParseFailure(a7, 4864i64, 260i64);
              v48 = v172;
              goto LABEL_76;
            }
LABEL_39:
            v34 = *(_QWORD *)(v11 + 72);
            a1a = (INT64)v33;
            v183 = (__m128i *)(v11 + 72);
            if( v34 )
            {
              CmpPopulateKcbStack((INT64)v33, v34);
              v34 = *(_QWORD *)(v11 + 72);
            }
            else
            {
              v33 = 0i64;
              a1a = 0i64;
            }
            v35 = v189;
            v36 = *(_CM_KEY_CONTROL_BLOCK **)(v189 + 8);
            if( (_CM_KEY_CONTROL_BLOCK *)v34 != v36 && (_CM_KEY_CONTROL_BLOCK *)v11 != v36 )
            {
              CmpLockKcbShared(v36);
              v171[7] = 1;
            }
            v37 = v33 == 0i64;
            if( v33 )
            {
              CmpLockKcbStackShared((INT64)v33);
              v37 = v33 == 0i64;
            }
            v38 = !v37;
            v171[4] = !v37;
            v170 = !v37;
            CmpLockKcbStackShared((INT64)v32);
            if( CmpIsKeyDeletedForKeyBody(v35, 0i64) )
            {
              v136 = -1073740763;
              if( (*(_BYTE *)(v35 + 48) & 1) == 0 )
                v136 = -1073741444;
              *(_DWORD *)v171 = v136;
              CmpRecordParseFailure(a7, 5888i64, v136);
              v48 = v172;
              v170 = v38;
              goto LABEL_68;
            }
            v39 = v12 - 1;
            v40 = (_DWORD *)(v11 + 184);
            if( (*(_DWORD *)(v11 + 184) & 0x20000) != 0 )
            {
              *(_DWORD *)v171 = -1073741772;
              CmpRecordParseFailure(a7, 6144i64, 3221225524i64);
              v170 = v38;
              goto LABEL_276;
            }
            if( !CmRmIsKCBVisible(v11, *(INT64 *)v180) )
            {
              *(_DWORD *)v171 = -1073741772;
              CmpRecordParseFailure(a7, 6400i64, 3221225524i64);
              v48 = v172;
              v170 = v38;
              goto LABEL_67;
            }
            if( (*(_DWORD *)a7 & 2) == 0 )
            {
              if( (*(_DWORD *)a7 & 0x20) == 0 )
              {
                if( !CmpIsKeyStackDeleted((__int64)v32, *(__int64 *)v180) )
                {
                  if( CmpIsKeyStackSymlink((INT64)v32) && (*(_DWORD *)a7 & 0x200) == 0 )
                  {
                    if( (*(_DWORD *)(a7 + 24) & 2) == 0 )
                    {
                      v33 = (INT64 *)a1a;
                      v170 = v38;
                      if( a1a )
                      {
                        CmpUnlockKcbStack(a1a);
                        v170 = 0;
                      }
                      if( v171[7] )
                      {
                        CmpUnlockKcb(*(_QWORD *)(v35 + 8));
                        v171[7] = 0;
                      }
                      if( v171[6] )
                      {
                        CmpUnlockHashEntryByKcb(v11);
                        v171[6] = 0;
                      }
                      v75 = CmpGetSymbolicLinkTarget(
                              (__int64)v32,
                              (__int64)result,
                              0,
                              0,
                              *(__int64 *)v180,
                              a7,
                              (__int64)v193,
                              (struct _UNICODE_STRING *)String2,
                              (ULONG_PTR *)(a7 + 88));
                      *(_DWORD *)v171 = v75;
                      if( v75 < 0 )
                      {
                        CmpRecordParseFailure(a7, 14336i64, (unsigned int)v75);
                        v48 = v172;
                      }
                      else
                      {
                        *(_DWORD *)a7 &= ~8u;
                        if( !*(_QWORD *)(a7 + 64) )
                        {
                          v76 = *(_QWORD *)(v11 + 32);
                          if( (*(_DWORD *)(v76 + 4152) & 1) != 0 )
                            *(_QWORD *)(a7 + 64) = v76;
                        }
                        *(_DWORD *)v171 = 260;
                        CmpRecordParseFailure(a7, 14592i64, 260i64);
                        v48 = v172;
                      }
                      goto LABEL_69;
                    }
                    *(_DWORD *)v171 = -1073741771;
                    v116 = 14080i64;
                    v117 = 3221225525i64;
                    goto LABEL_255;
                  }
                  if( !BYTE2(a8_2) )
                  {
                    if( (*v40 & 0x20000) != 0 )
                    {
                      v116 = 15104i64;
                      *(_DWORD *)v171 = -1073741772;
                      v117 = 3221225524i64;
                      goto LABEL_255;
                    }
                    if( (*(_DWORD *)(a7 + 24) & 2) != 0 )
                    {
                      *(_DWORD *)v171 = -1073741771;
                      v116 = 15360i64;
                      v117 = 3221225525i64;
                      goto LABEL_255;
                    }
                    v41 = String2;
                    v33 = (INT64 *)a1a;
                    v42 = CmpDoWritethroughReparse(v11, (INT64)v32, a1a, 0, 0i64, a7, (UNICODE_STRING *)String2);
                    *(_DWORD *)v171 = v42;
                    if( v42 == -1073741199 )
                    {
                      v43 = CmpVEExecuteOpenLogic(v11, a7, 0, (INT64)v41, v171[5]);
                      *(_DWORD *)v171 = v43;
                      if( v43 == -1073741199 )
                      {
                        v44 = *(_CM_TRANS **)v180;
                        v45 = v171[5];
                        KeyBody = CmpCreateKeyBody(
                                    (volatile INT64 *)v11,
                                    v171[5],
                                    a7,
                                    *(INT64 *)v180,
                                    0,
                                    (INT64)v32,
                                    (INT64)&DmaAdapter,
                                    (INT64)&a8a);
                        *(_DWORD *)v171 = KeyBody;
                        v170 = v38;
                        if( KeyBody >= 0 )
                        {
LABEL_59:
                          v47 = a4a;
LABEL_60:
                          if( *(_DWORD *)(a7 + 32) == 1
                            || (unsigned __int8)CmpCheckOpenAccessOnKeyBody(
                                                  DmaAdapter,
                                                  (INT64)v32,
                                                  (_DWORD *)a7,
                                                  v47,
                                                  v45,
                                                  (*(_DWORD *)(a7 + 24) & 4) != 0,
                                                  v44,
                                                  (INT64)&a8_2,
                                                  (INT64)v171) )
                          {
                            *v195 = DmaAdapter;
                            DmaAdapter = 0i64;
                            if( !*(_DWORD *)(a7 + 32) )
                              *(_DWORD *)(a7 + 32) = 2;
                            v48 = 0i64;
                            if( (_BYTE)a8a )
                              *(_DWORD *)v171 = 1073741846;
                            else
                              *(_DWORD *)v171 = 0;
                          }
                          else
                          {
                            if( (_BYTE)a8_2 )
                            {
                              if( (*(_DWORD *)(a7 + 160) & 1) == 0 )
                              {
                                CmpAttachToRegistryProcess((KAPC_STATE *)(a7 + 168));
                                *(_DWORD *)(a7 + 160) |= 1u;
                              }
                              v48 = CmpConstructName((_CM_KEY_CONTROL_BLOCK *)v11);
                            }
                            else
                            {
                              v48 = v172;
                            }
                            CmpRecordParseFailure(a7, 15584i64, *(unsigned int *)v171);
                          }
                          HIBYTE(a8_2) = 0;
                          if( !v178 )
                            goto LABEL_67;
                          goto LABEL_227;
                        }
                        v116 = 15552i64;
                        if( KeyBody == -1073741444 )
                          KeyBody = -1073741772;
                        *(_DWORD *)v171 = KeyBody;
                        v117 = (unsigned int)KeyBody;
LABEL_255:
                        CmpRecordParseFailure(a7, v116, v117);
                        v48 = v172;
                        v170 = v38;
                        goto LABEL_67;
                      }
                      CmpRecordParseFailure(a7, 15488i64, v43);
                      v170 = v38;
                    }
                    else
                    {
                      CmpRecordParseFailure(a7, 15424i64, v42);
                      v170 = v38;
                    }
LABEL_241:
                    v48 = v172;
                    goto LABEL_68;
                  }
                  v116 = 14848i64;
LABEL_254:
                  *(_DWORD *)v171 = -1073741811;
                  v117 = 3221225485i64;
                  goto LABEL_255;
                }
                if( BYTE2(a8_2) )
                {
                  v116 = 9728i64;
                  goto LABEL_254;
                }
                if( CmpIsKeyStackDeleted(a1a, *(__int64 *)v180)
                  || !CmRmIsKCBVisible(v183->m128i_i64[0], *(INT64 *)v180) )
                {
                  v116 = 9984i64;
                  *(_DWORD *)v171 = -1073741772;
                  v117 = 3221225524i64;
                  goto LABEL_255;
                }
                if( (*(_DWORD *)(v183->m128i_i64[0] + 184) & 0x20000) != 0 )
                {
                  *(_DWORD *)v171 = -1073741772;
                  CmpRecordParseFailure(a7, 10240i64, 3221225524i64);
                  v170 = v38;
                }
                else
                {
                  if( (*(_DWORD *)a7 & 1) != 0 )
                  {
                    KtmUow = (_GUID *)(v11 + 32);
                    if( *(_QWORD *)(v11 + 32) == CmpMasterHive )
                    {
                      if( CmpNoMasterCreates )
                      {
                        v11 = BugCheckParameter4;
                        if( (struct _KTHREAD *)CmpMountThread != KeGetCurrentThread() )
                        {
                          if( !CmpLoadingSystemHivesActive
                            || (*(_DWORD *)(BugCheckParameter4 + 8) & 0x7FE00000) != 6291456
                            || (v142 = (_UNICODE_STRING *)CmpGetComponentNameAtIndex((INT64)result, (unsigned int)v39),
                                !CmpWaitForHiveMount(v142, v143, v144, (UINT64 *)(a7 + 136))) )
                          {
                            v116 = 11264i64;
                            goto LABEL_254;
                          }
                          v141 = 11008i64;
                          goto LABEL_343;
                        }
                      }
                    }
                    BugCheckParameter2 = CmpGetComponentNameAtIndex((INT64)result, (unsigned int)v39);
                    v77 = CmpDoWritethroughReparse(
                            v11,
                            (INT64)v32,
                            a1a,
                            1,
                            (UNICODE_STRING *)BugCheckParameter2,
                            a7,
                            (UNICODE_STRING *)String2);
                    *(_DWORD *)v171 = v77;
                    if( v77 != -1073741199 )
                    {
                      v117 = v77;
                      v116 = 11392i64;
                      goto LABEL_255;
                    }
                    if( (*(_DWORD *)(a7 + 160) & 1) == 0 )
                    {
                      CmpAttachToRegistryProcess((KAPC_STATE *)(a7 + 168));
                      *(_DWORD *)(a7 + 160) |= 1u;
                    }
                    v78 = v183;
                    if( *(_DWORD *)(v183->m128i_i64[0] + 40) != -1 )
                    {
                      CmpUnlockKcbStack((__int64)v32);
                      CmpUnlockKcbStack(a1a);
                      CmpLockKcbStackTopExclusiveRestShared(a1a);
                      goto LABEL_173;
                    }
                    if( CmpCheckCreateAccessOnKcbStack(
                           16 * (*(_DWORD *)(a7 + 24) & 2u),
                           a1a,
                           a7,
                           (__int64)a4a,
                           v171[5],
                           16 * (*(_DWORD *)(a7 + 24) & 2),
                           (*(_DWORD *)(a7 + 24) & 4) != 0,
                           *(__int64 *)v180,
                           (int *)v171) )
                    {
                      CmpUnlockKcbStack((__int64)v32);
                      CmpUnlockKcbStack(a1a);
                      if( v171[7] )
                      {
                        CmpUnlockKcb(*(_QWORD *)(v35 + 8));
                        v171[7] = 0;
                      }
                      v153 = CmpPromoteKey(a1a, 0, 1);
                      *(_DWORD *)v171 = v153;
                      if( v153 < 0 )
                      {
                        if( v153 == -1073741444 )
                          v153 = -1073741772;
                        *(_DWORD *)v171 = v153;
                        CmpRecordParseFailure(a7, 11776i64, (unsigned int)v153);
                        v48 = v172;
                        v33 = (INT64 *)a1a;
                        goto LABEL_70;
                      }
LABEL_173:
                      CmpLockKcbStackTopExclusiveRestShared((__int64)v32);
                      v79 = *(_QWORD *)v180;
                      if( !CmRmIsKCBVisible(v11, *(INT64 *)v180) )
                      {
                        *(_DWORD *)v171 = -1073741772;
                        CmpRecordParseFailure(a7, 12032i64, 3221225524i64);
                        v170 = 1;
                        goto LABEL_192;
                      }
                      if( CmpIsKeyStackDeleted((__int64)v32, v79) )
                      {
                        v44 = (_CM_TRANS *)v79;
                        if( CmpIsKeyStackDeleted(a1a, v79) || !CmRmIsKCBVisible(v78->m128i_i64[0], v79) )
                        {
                          *(_DWORD *)v171 = -1073741772;
                          CmpRecordParseFailure(a7, 12288i64, 3221225524i64);
                          v170 = 1;
                          goto LABEL_192;
                        }
                        if( (*(_DWORD *)(v78->m128i_i64[0] + 184) & 0x20000) != 0 )
                        {
                          *(_DWORD *)v171 = -1073741772;
                          CmpRecordParseFailure(a7, 12544i64, 3221225524i64);
                          v170 = 1;
                          goto LABEL_192;
                        }
                        ObjectCreatedc = v79;
                        v80 = BugCheckParameter2;
                        LODWORD(a6a) = 16 * (*(_DWORD *)(a7 + 24) & 2);
                        Logic = CmpVEExecuteCreateLogic(
                                  v78->m128i_i64[0],
                                  v11,
                                  (__m128i *)BugCheckParameter2,
                                  (INT64)a4a,
                                  v171[5],
                                  a6a,
                                  ObjectCreatedc,
                                  a7,
                                  (INT64)String2);
                        *(_DWORD *)v171 = Logic;
                        if( Logic == -1073741739 )
                        {
                          *(_DWORD *)a7 |= 0x400u;
                          *(_DWORD *)v171 = -1073741267;
                          CmpRecordParseFailure(a7, 12672i64, 3221226029i64);
                          v170 = 1;
                          goto LABEL_192;
                        }
                        if( Logic != -1073741199 )
                        {
                          CmpRecordParseFailure(a7, 12736i64, Logic);
                          v170 = 1;
                          goto LABEL_192;
                        }
                        if( CmpCheckCreateAccessOnKcbStack(
                               16 * (*(_DWORD *)(a7 + 24) & 2u),
                               a1a,
                               a7,
                               (__int64)a4a,
                               v171[5],
                               16 * (*(_DWORD *)(a7 + 24) & 2),
                               (*(_DWORD *)(a7 + 24) & 4) != 0,
                               (__int64)v44,
                               (int *)v171) )
                        {
                          v45 = v171[5];
                          v82 = CmpCreateKeyBody(
                                  (volatile INT64 *)v11,
                                  v171[5],
                                  a7,
                                  (INT64)v44,
                                  1,
                                  (INT64)v32,
                                  (INT64)&DmaAdapter,
                                  (INT64)&a8a);
                          *(_DWORD *)v171 = v82;
                          if( v82 < 0 )
                          {
                            CmpRecordParseFailure(a7, 12928i64, (unsigned int)v82);
                            v170 = 1;
                            goto LABEL_192;
                          }
                          v83 = (UNICODE_STRING *)v80;
                          v47 = a4a;
                          LODWORD(ObjectCreated) = 0;
                          Child = CmpCreateChild(
                                    a1a,
                                    (INT64)v32,
                                    (INT64)a4a,
                                    v83,
                                    a7,
                                    8 * (*(_WORD *)(a7 + 24) & 2u),
                                    ObjectCreated,
                                    0,
                                    (INT64)v44);
                          *(_DWORD *)v171 = Child;
                          if( Child < 0 )
                          {
                            CmpRecordParseFailure(a7, 12992i64, (unsigned int)Child);
                            v48 = v172;
                            v170 = 1;
                            goto LABEL_67;
                          }
                          *(_DWORD *)(a7 + 32) = 1;
LABEL_184:
                          v170 = 1;
                          goto LABEL_60;
                        }
                        if( *((_BYTE *)KeGetCurrentThread() + 562) == 1 )
                        {
                          CurrentThreadProcess = PsGetCurrentThreadProcess();
                          ProcessServerSilo = (_EJOB *)PsGetProcessServerSilo(CurrentThreadProcess);
                          ServerSiloServiceSessionId = PsGetServerSiloServiceSessionId(ProcessServerSilo);
                          SessionId = MmGetSessionIdEx(CurrentThreadProcess);
                          v33 = (INT64 *)a1a;
                          if( SessionId != ServerSiloServiceSessionId && CmpCheckKeyOwnerForPca(a1a, v114, v115) )
                          {
                            v154 = (_CM_KEY_CONTROL_BLOCK *)v78->m128i_i64[0];
                            LOBYTE(a8_2) = 1;
                            v48 = CmpConstructName(v154);
                            goto LABEL_239;
                          }
                        }
                        else
                        {
                          v33 = (INT64 *)a1a;
                        }
                        v48 = v172;
LABEL_239:
                        CmpRecordParseFailure(a7, 12800i64, *(unsigned int *)v171);
                        v11 = BugCheckParameter4;
                        v170 = 1;
                        goto LABEL_68;
                      }
                      if( !CmpIsKeyStackSymlink((INT64)v32) || (*(_DWORD *)a7 & 0x200) != 0 )
                      {
                        if( (*v40 & 0x20000) != 0 )
                        {
                          *(_DWORD *)v171 = -1073741772;
                          CmpRecordParseFailure(a7, 13568i64, 3221225524i64);
                          v170 = 1;
                          goto LABEL_192;
                        }
                        if( (*(_DWORD *)(a7 + 24) & 2) == 0 )
                        {
                          v158 = String2;
                          v33 = (INT64 *)a1a;
                          v159 = CmpDoWritethroughReparse(v11, (INT64)v32, a1a, 0, 0i64, a7, (UNICODE_STRING *)String2);
                          *(_DWORD *)v171 = v159;
                          if( v159 == -1073741199 )
                          {
                            v45 = v171[5];
                            LOBYTE(v160) = 1;
                            v159 = CmpVEExecuteOpenLogic(v11, a7, v160, (INT64)v158, v171[5]);
                            *(_DWORD *)v171 = v159;
                            if( v159 == -1073741199 )
                            {
                              v44 = *(_CM_TRANS **)v180;
                              v162 = CmpCreateKeyBody(
                                       (volatile INT64 *)v11,
                                       v45,
                                       a7,
                                       *(INT64 *)v180,
                                       1,
                                       (INT64)v32,
                                       (INT64)&DmaAdapter,
                                       (INT64)&a8a);
                              *(_DWORD *)v171 = v162;
                              if( v162 >= 0 )
                              {
                                v47 = a4a;
                                goto LABEL_184;
                              }
                              v156 = (unsigned int)v162;
                              v155 = 14016i64;
LABEL_378:
                              CmpRecordParseFailure(a7, v155, v156);
                              v170 = 1;
                              goto LABEL_192;
                            }
                            v161 = 13952i64;
                          }
                          else
                          {
                            v161 = 13888i64;
                          }
                          CmpRecordParseFailure(a7, v161, v159);
                          v170 = 1;
                          goto LABEL_241;
                        }
                        v155 = 13824i64;
                      }
                      else
                      {
                        if( (*(_DWORD *)(a7 + 24) & 2) == 0 )
                        {
                          CmpUnlockKcbStack(a1a);
                          if( v171[7] )
                          {
                            CmpUnlockKcb(*(_QWORD *)(v35 + 8));
                            v171[7] = 0;
                          }
                          if( v171[6] )
                          {
                            CmpUnlockHashEntryByKcb(v11);
                            v171[6] = 0;
                          }
                          v157 = CmpGetSymbolicLinkTarget(
                                   (__int64)v32,
                                   (__int64)result,
                                   0,
                                   0,
                                   v79,
                                   a7,
                                   (__int64)v193,
                                   (struct _UNICODE_STRING *)String2,
                                   (ULONG_PTR *)(a7 + 88));
                          *(_DWORD *)v171 = v157;
                          if( v157 >= 0 )
                          {
                            *(_DWORD *)a7 &= ~8u;
                            if( !*(_QWORD *)(a7 + 64) && (*(_DWORD *)(*(_QWORD *)&KtmUow->Data1 + 4152i64) & 1) != 0 )
                              *(_QWORD *)(a7 + 64) = *(_QWORD *)&KtmUow->Data1;
                            *(_DWORD *)v171 = 260;
                            CmpRecordParseFailure(a7, 13440i64, 260i64);
                            v48 = v172;
                          }
                          else
                          {
                            CmpRecordParseFailure(a7, 13312i64, (unsigned int)v157);
                            v48 = v172;
                          }
                          goto LABEL_72;
                        }
                        v155 = 13056i64;
                      }
                      *(_DWORD *)v171 = -1073741771;
                      v156 = 3221225525i64;
                      goto LABEL_378;
                    }
                    if( *((_BYTE *)KeGetCurrentThread() + 562) == 1 )
                    {
                      v145 = PsGetCurrentThreadProcess();
                      v146 = (_EJOB *)PsGetProcessServerSilo(v145);
                      v147 = PsGetServerSiloServiceSessionId(v146);
                      v148 = MmGetSessionIdEx(v145);
                      v33 = (INT64 *)a1a;
                      if( v148 != v147 && CmpCheckKeyOwnerForPca(a1a, v149, v150) )
                      {
                        v151 = (_CM_KEY_CONTROL_BLOCK *)v78->m128i_i64[0];
                        LOBYTE(a8_2) = 1;
                        v152 = CmpConstructName(v151);
                        v38 = v171[4];
                        v48 = v152;
LABEL_356:
                        CmpRecordParseFailure(a7, 11520i64, *(unsigned int *)v171);
                        v11 = BugCheckParameter4;
                        v170 = v38;
                        goto LABEL_68;
                      }
                      v38 = v171[4];
                    }
                    else
                    {
                      v33 = (INT64 *)a1a;
                    }
                    v48 = v172;
                    goto LABEL_356;
                  }
                  if( CmpLoadingSystemHivesActive )
                  {
                    v11 = BugCheckParameter4;
                    if( (struct _KTHREAD *)CmpMountThread != KeGetCurrentThread()
                      && *(_QWORD *)(BugCheckParameter4 + 32) == CmpMasterHive
                      && (*(_DWORD *)(BugCheckParameter4 + 8) & 0x7FE00000) == 6291456 )
                    {
                      v138 = (_UNICODE_STRING *)CmpGetComponentNameAtIndex((INT64)result, (unsigned int)v39);
                      if( CmpWaitForHiveMount(v138, v139, v140, (UINT64 *)(a7 + 136)) )
                      {
                        v141 = 10496i64;
LABEL_343:
                        *(_DWORD *)a7 |= 0x100u;
                        *(_DWORD *)v171 = 259;
                        CmpRecordParseFailure(a7, v141, 259i64);
                        v170 = v38;
                        goto LABEL_192;
                      }
                    }
                  }
                  *(_DWORD *)v171 = -1073741772;
                  CmpRecordParseFailure(a7, 10752i64, 3221225524i64);
                  v170 = v38;
                }
LABEL_192:
                v48 = v172;
LABEL_67:
                v33 = (INT64 *)a1a;
LABEL_68:
                CmpUnlockKcbStack((__int64)v32);
LABEL_69:
                v38 = v170;
LABEL_70:
                if( v38 )
                  CmpUnlockKcbStack((__int64)v33);
LABEL_72:
                if( v171[7] )
                  CmpUnlockKcb(*(_QWORD *)(v35 + 8));
                if( HIBYTE(a8_2) )
                  CmpUnlockHashEntry(*(_CMHIVE **)(a7 + 48), 0);
                goto LABEL_76;
              }
              CmpUnlockKcbStack((__int64)v32);
              CmpUnlockKcbStack(a1a);
              CmpLockKcbStackTopExclusiveRestShared(a1a);
              CmpLockKcbStackTopExclusiveRestShared((__int64)v32);
              v44 = *(_CM_TRANS **)v180;
              if( CmpIsKeyStackDeleted(a1a, *(__int64 *)v180) )
              {
                *(_DWORD *)v171 = -1073741772;
                CmpRecordParseFailure(a7, 8960i64, 3221225524i64);
                v170 = v38;
                goto LABEL_192;
              }
              if( (*(_DWORD *)(v183->m128i_i64[0] + 184) & 0x20000) != 0 )
              {
                *(_DWORD *)v171 = -1073741772;
                CmpRecordParseFailure(a7, 9216i64, 3221225524i64);
                v170 = v38;
                goto LABEL_192;
              }
              v122 = CmpGetComponentNameAtIndex((INT64)result, (unsigned int)v39);
              v123 = *(_DWORD *)(a7 + 24);
              v124 = (UNICODE_STRING *)v122;
              if( (v123 & 2) != 0 )
                v125 = 32;
              else
                v125 = 0;
              if( !CmpCheckCreateAccessOnKcbStack(
                      (__int64)v171,
                      a1a,
                      a7,
                      (__int64)a4a,
                      v171[5],
                      v125,
                      (v123 & 4) != 0,
                      (__int64)v44,
                      (int *)v171) )
              {
                CmpRecordParseFailure(a7, 9472i64, *(unsigned int *)v171);
                v170 = v38;
                goto LABEL_192;
              }
              CmpCleanUpKcbCachedSymlink(v11, (INT64)v193);
              *(_WORD *)(v11 + 186) |= 0x40u;
              v126 = v171[5];
              *(_DWORD *)(v11 + 100) = -1;
              *(_DWORD *)(v11 + 96) = *(_DWORD *)(a7 + 56);
              *(_DWORD *)v171 = CmpCreateKeyBody(
                                  (volatile INT64 *)v11,
                                  v126,
                                  a7,
                                  (INT64)v44,
                                  1,
                                  (INT64)v32,
                                  (INT64)&DmaAdapter,
                                  (INT64)&a8a);
              v170 = v38;
              if( *(int *)v171 >= 0 )
              {
                if( !CmpIsKeyStackDeleted((__int64)v32, (__int64)v44) )
                {
LABEL_274:
                  v45 = v171[5];
                  v170 = v38;
                  goto LABEL_59;
                }
                LODWORD(ObjectCreatedb) = 0;
                *(_DWORD *)v171 = CmpCreateChild(
                                    a1a,
                                    (INT64)v32,
                                    (INT64)a4a,
                                    v124,
                                    a7,
                                    64,
                                    ObjectCreatedb,
                                    0,
                                    (INT64)v44);
                v170 = v38;
                if( *(int *)v171 >= 0 )
                {
                  *(_DWORD *)(a7 + 32) = 1;
                  goto LABEL_274;
                }
              }
LABEL_276:
              v48 = v172;
              goto LABEL_67;
            }
            CmpUnlockKcbStack((__int64)v32);
            v91 = a1a;
            CmpUnlockKcbStack(a1a);
            if( v171[7] )
              CmpUnlockKcb(*(_QWORD *)(v35 + 8));
            HIBYTE(a8_2) = CmpTryToLockHashEntryExclusive(*(_CMHIVE **)(a7 + 48), 0);
            if( v171[7] )
              CmpLockKcbShared(*(_CM_KEY_CONTROL_BLOCK **)(v35 + 8));
            CmpLockKcbStackTopExclusiveRestShared(v91);
            CmpLockKcbStackTopExclusiveRestShared((__int64)v32);
            KtmUow = (_GUID *)CmpGetComponentNameAtIndex((INT64)result, (unsigned int)v39);
            v93.Hash = CmpGetComponentHashAtIndex((INT64)result, v92);
            if( CmpIsKeyDeletedForKeyBody(v35, 0i64) )
            {
              HiveRootCell = -1073740763;
              v137 = 6656i64;
              if( (*(_BYTE *)(v35 + 48) & 1) == 0 )
                HiveRootCell = -1073741444;
            }
            else
            {
              v94 = *(_QWORD *)v180;
              if( CmpIsKeyStackDeleted(a1a, *(__int64 *)v180) )
              {
                HiveRootCell = -1073741772;
                v137 = 6912i64;
              }
              else
              {
                if( !CmpIsKeyStackDeleted((__int64)v32, v94) )
                {
                  *(_DWORD *)v171 = -1073741790;
                  v137 = 7168i64;
                  v99 = 3221225506i64;
                  goto LABEL_324;
                }
                if( *(_QWORD *)(v183->m128i_i64[0] + 32) != CmpMasterHive )
                {
                  *(_DWORD *)v171 = -1073741790;
                  v137 = 7424i64;
                  v99 = 3221225506i64;
                  goto LABEL_324;
                }
                if( (*(_DWORD *)(v183->m128i_i64[0] + 184) & 0x20000) == 0 )
                {
                  if( (*(_DWORD *)(a7 + 160) & 1) == 0 )
                  {
                    CmpAttachToRegistryProcess((KAPC_STATE *)(a7 + 168));
                    *(_DWORD *)(a7 + 160) |= 1u;
                  }
                  v95 = *(unsigned int *)(a7 + 40);
                  v96 = (_DWORD *)(a7 + 40);
                  v97 = *(_CMHIVE **)(a7 + 48);
                  if( (_DWORD)v95 == -1 )
                  {
                    HiveRootCell = CmpCreateHiveRootCell(
                                     (ULONG_PTR)v97,
                                     (__int64)a4a,
                                     (unsigned __int16 *)KtmUow,
                                     a7,
                                     a7 + 40);
                    *(_DWORD *)v171 = HiveRootCell;
                    if( HiveRootCell < 0 )
                    {
                      v137 = 7808i64;
                      goto LABEL_322;
                    }
                  }
                  else
                  {
                    CmpUpdateHiveRootCellFlags(v97, v95);
                    *(_DWORD *)v171 = HiveRootCell;
                    if( HiveRootCell < 0 )
                    {
                      v137 = 7936i64;
                      goto LABEL_322;
                    }
                  }
                  *(_WORD *)(v11 + 186) |= 2u;
                  LODWORD(v163) = 1;
                  *(_DWORD *)v171 = CmpCreateKeyControlBlock(
                                      *(_CMHIVE **)(a7 + 48),
                                      0xFFFFFFFFui64,
                                      (_CM_KEY_CONTROL_BLOCK *)v11,
                                      *(_CM_KEY_CONTROL_BLOCK **)(a7 + 80),
                                      (UINT64)v163,
                                      (_UNICODE_STRING *)KtmUow,
                                      v93,
                                      0,
                                      (_CM_KEY_CONTROL_BLOCK **)&BugCheckParameter2);
                  *(_WORD *)(v11 + 186) &= ~2u;
                  v99 = *(unsigned int *)v171;
                  if( *(int *)v171 < 0 )
                  {
                    v137 = 0x2000i64;
                    goto LABEL_324;
                  }
                  v100 = v11;
                  v11 = BugCheckParameter2;
                  CmpDereferenceKeyControlBlockUnsafe((volatile INT64 *)v100);
                  CmpUnlockHashEntryByKcb(v100);
                  v171[6] = 0;
                  HiveRootCell = CmpStartKcbStackForTopLayerKcb((INT64)v196, v11);
                  *(_DWORD *)v171 = HiveRootCell;
                  if( HiveRootCell >= 0 )
                  {
                    *(_WORD *)(v100 + 186) |= 2u;
                    CmpLockKcbStackTopExclusiveRestShared((__int64)v196);
                    v101 = *(_QWORD *)v180;
                    v102 = v171[5];
                    *(_WORD *)(v100 + 186) &= ~2u;
                    v178 = 1;
                    v103 = CmpCreateKeyBody(
                             (volatile INT64 *)v11,
                             v102,
                             a7,
                             v101,
                             1,
                             (INT64)v196,
                             (INT64)&DmaAdapter,
                             (INT64)&a8a);
                    *(_DWORD *)v171 = v103;
                    if( v103 < 0 )
                    {
                      CmpRecordParseFailure(a7, 8576i64, (unsigned int)v103);
                      v48 = v172;
                      v170 = v171[4];
                    }
                    else
                    {
                      HvLockHiveFlusherShared(*(_QWORD *)(v100 + 32));
                      HvLockHiveFlusherExclusive(*(_QWORD *)(v11 + 32));
                      v104 = *(_QWORD *)(v11 + 32);
                      v105 = *(_DWORD *)(v104 + 104);
                      if( HvMarkCellDirty(v104, (unsigned int)*v96, 0) )
                      {
                        LODWORD(ObjectCreateda) = 0;
                        *(_DWORD *)v171 = CmpCreateChild(
                                            a1a,
                                            (INT64)v32,
                                            (INT64)a4a,
                                            (UNICODE_STRING *)KtmUow,
                                            a7,
                                            10,
                                            ObjectCreateda,
                                            1,
                                            *(INT64 *)v180);
                        if( *(int *)v171 >= 0 )
                        {
                          *(_DWORD *)(v11 + 40) = *v96;
                          KeyNodeForKcb = (_CM_KEY_NODE *)CmpGetKeyNodeForKcb(v11, (INT64)&v190, 1);
                          KeyNodeForKcb->Parent = *(_DWORD *)(v100 + 40);
                          ++*(_QWORD *)(v11 + 304);
                          CmpRebuildKcbCacheFromNode((_CM_KEY_CONTROL_BLOCK *)v11, KeyNodeForKcb);
                          CmpReleaseKeyNodeForKcb((_CM_KEY_CONTROL_BLOCK *)v11, (_HV_GET_CELL_CONTEXT *)&v190);
                          if( !v105 )
                            HvResetDirtyData(*(_HHIVE **)(v11 + 32));
                          HvUnlockHiveFlusherExclusive(*(_QWORD *)(v11 + 32));
                          HvUnlockHiveFlusherShared(*(_QWORD *)(v100 + 32));
                          *(_WORD *)(v100 + 8) |= 8u;
                          CmpReferenceKeyControlBlockUnsafe((volatile INT64 *)v11);
                          *(_QWORD *)(v100 + 104) = v11;
                          CmpUnlockHashEntry(*(_CMHIVE **)(a7 + 48), 0);
                          v44 = *(_CM_TRANS **)v180;
                          v45 = v171[5];
                          v170 = v171[4];
                          *(_DWORD *)(a7 + 32) = 1;
                          goto LABEL_59;
                        }
                      }
                      else
                      {
                        *(_DWORD *)v171 = -1073741443;
                        CmpRecordParseFailure(a7, 8704i64, 3221225853i64);
                      }
                      HvUnlockHiveFlusherExclusive(*(_QWORD *)(v11 + 32));
                      HvUnlockHiveFlusherShared(*(_QWORD *)(v100 + 32));
                      v48 = v172;
                    }
LABEL_227:
                    CmpUnlockKcbStack((__int64)v196);
                    goto LABEL_67;
                  }
                  v137 = 8448i64;
LABEL_322:
                  v99 = (unsigned int)HiveRootCell;
LABEL_324:
                  CmpRecordParseFailure(a7, v137, v99);
                  v170 = v171[4];
                  goto LABEL_192;
                }
                HiveRootCell = -1073741772;
                v137 = 7680i64;
              }
            }
            *(_DWORD *)v171 = HiveRootCell;
            goto LABEL_322;
          }
          CmpRecordParseFailure(a7, 3584i64, (unsigned int)v31);
        }
      }
      else
      {
        *(_DWORD *)v171 = -1073741790;
        CmpRecordParseFailure(a7, 2560i64, 3221225506i64);
      }
    }
    else
    {
      CmpRecordParseFailure(a7, 2496i64, *(unsigned int *)v171);
    }
LABEL_107:
    v48 = v172;
LABEL_76:
    if( v171[6] )
      CmpUnlockHashEntryByKcb(v11);
    goto LABEL_78;
  }
  if( (*(_DWORD *)a7 & 0x400) != 0 )
    CmpLockRegistryExclusive();
  else
    CmpLockRegistry();
  v58 = *(_QWORD *)(v16 + 296);
  LOBYTE(v14) = 1;
  v59 = 0;
  v173 = 1;
  if( (v58 & 1) != 0 )
  {
    v59 = 1;
    v58 &= ~1ui64;
  }
  if( !v58 || v59 || !(unsigned __int8)RtlPrefixUnicodeString((PVOID)v58, (INT64 *)String2) )
  {
    CmpDereferenceKeyControlBlock(v16);
    v16 = 0i64;
    P4 = 0i64;
    CmpUnlockRegistry();
    v14 = v177[0];
    v173 = 0;
LABEL_127:
    v11 = BugCheckParameter4;
    goto LABEL_11;
  }
  v60 = String2->Length - *(_WORD *)v58;
  v61 = String2->MaximumLength - *(_WORD *)v58;
  v62 = &String2->Buffer[(unsigned __int64)*(unsigned __int16 *)v58 >> 1];
  v63 = v60;
  v187.m128i_i16[0] = v60;
  v64 = v62;
  v187.m128i_i64[1] = (__int64)v62;
  v65 = v61;
  v187.m128i_i16[1] = v61;
  if( v60 )
  {
    do
    {
      if( *v64 != 92 )
        break;
      ++v64;
      v65 -= 2;
      v63 -= 2;
    }
    while( v63 );
    v187.m128i_i64[1] = (__int64)v64;
    v187.m128i_i16[0] = v63;
    v187.m128i_i16[1] = v65;
  }
  v66 = ((*(_DWORD *)(v16 + 8) >> 21) & 0x3FF) - 1;
  if( (*(_DWORD *)a7 & 1) != 0 && !v63 )
  {
    v85 = *(_QWORD *)(v16 + 80);
    v86 = *(unsigned __int16 *)(v85 + 24);
    v37 = (*(_DWORD *)v85 & 1) == 0;
    v87 = *(unsigned __int16 *)(v85 + 24);
    if( v37 )
    {
      v187.m128i_i16[0] = v86 + v60;
      v89 = (__int64)&v62[-((unsigned __int64)v86 >> 1)];
      v187.m128i_i16[1] = v86 + v61;
    }
    else
    {
      v88 = 2 * v86;
      v89 = (__int64)&v62[-v87];
      v187.m128i_i16[1] = v61 + v88;
      v187.m128i_i16[0] = v60 + v88;
    }
    v187.m128i_i64[1] = v89;
    v12 = 1;
    --v66;
  }
  v67 = CmpComputeComponentHashes(&v187, v177, (INT64)result);
  *(_DWORD *)v171 = v67;
  if( v67 >= 0 )
  {
    v14 = v177[0];
    if( (unsigned int)(v177[0] + v66) > 0x20 )
    {
      *(_DWORD *)v171 = -1073741811;
      v127 = 768i64;
      v128 = 3221225485i64;
    }
    else
    {
      v68 = CmpValidateComponents((unsigned int)v177[0], (INT64)result);
      *(_DWORD *)v171 = v68;
      if( v68 >= 0 )
      {
        if( v12 == v14 )
        {
          CmpLockHashEntrySharedByKcb((_CM_KEY_CONTROL_BLOCK *)v16);
          v69 = 1;
          HIBYTE(a8a) = 1;
        }
        else
        {
          v69 = 0;
        }
        CmpLockKcbShared((_CM_KEY_CONTROL_BLOCK *)v16);
        if( CmpIsKeyDeleted(v16, 0i64) || (*(_DWORD *)(v16 + 8) & 0x40000) != 0 )
        {
          CmpUnlockKcb(v16);
          if( v69 )
            CmpUnlockHashEntryByKcb(v16);
          CmpDereferenceKeyControlBlock(v16);
          v16 = 0i64;
          P4 = 0i64;
          v12 = 0;
          v187 = *v183;
          CmpCleanupPathInfo((__int64)result);
          memset((INT64)result, 0i64);
          HIBYTE(a8a) = 0;
        }
        else
        {
          CmpUnlockKcb(v16);
        }
        goto LABEL_127;
      }
      v128 = (unsigned int)v68;
      v127 = 1024i64;
    }
    CmpRecordParseFailure(a7, v127, v128);
    v11 = BugCheckParameter4;
    v48 = v172;
LABEL_81:
    LOBYTE(v14) = v173;
    goto LABEL_82;
  }
  CmpRecordParseFailure(a7, 512i64, (unsigned int)v67);
  v11 = BugCheckParameter4;
  v48 = v172;
LABEL_82:
  CmpCleanupKcbStack((INT64)a2a);
  CmpCleanupKcbStack((INT64)v200);
  CmpCleanupKcbStack((INT64)v196);
  v49 = *(_QWORD *)v191;
  if( *(_QWORD *)v191 )
  {
    CmpDereferenceKeyControlBlockUnsafe((volatile INT64 *)v11);
    v50 = v49;
  }
  else
  {
    if( !v11 )
      goto LABEL_86;
    v50 = v11;
  }
  CmpDereferenceKeyControlBlock(v50);
LABEL_86:
  if( v16 )
    CmpDereferenceKeyControlBlock(v16);
  v51 = *(_DWORD *)(a7 + 100);
  if( v51 && (v51 & 2) != 0 )
  {
    CmpSearchKeyControlBlockTreeEx(
      (__int64(__fastcall *)(ULONG_PTR, ULONG_PTR, __int64, __int64))CmpSyncKcbCacheForHive,
      *(_QWORD *)(a7 + 112),
      (__int64)v193,
      0i64,
      1);
    *(_DWORD *)(a7 + 100) &= ~2u;
  }
  CmpDrainDelayDerefContext((UINT64 **)v193);
  if( (_BYTE)v14 )
    CmpUnlockRegistry();
  if( (_BYTE)a8_2 )
  {
    if( !v48 )
      goto LABEL_94;
    if( CmpCheckExeOwnerForPca() )
      CmpPublishEventForPcaResolver((_CM_KEY_CONTROL_BLOCK *)a7);
  }
  if( v48 )
    CmpFreeTransientPoolWithTag(v48, 0x624E4D43ui64);
LABEL_94:
  if( (*(_DWORD *)(a7 + 160) & 1) != 0 )
    CmpDetachFromRegistryProcess((KAPC_STATE *)(a7 + 168));
  if( DmaAdapter )
    HalPutDmaAdapter(DmaAdapter);
  CmpCleanupPathInfo((__int64)result);
  return *(unsigned int *)v171;
}

Referenced by:

CmpParseKey