HalpIommuCreateIncreaseAliasTrack

NTSTATUS __stdcall HalpIommuCreateIncreaseAliasTrack(PVOID Src){
  UINT8 **v1; 
  __int64 v2; 
  UINT8 **v3; 
  __int64 *v5; 
  UINT8 *v6; 
  UINT8 *v7; 
  _HALP_ALLOC_CONTEXT *v9; 
  int v10; 
  UINT8 **v11; 
  VOID *v12; 

  v2 = qword_140C49C00;
  v3 = v1;
  while( 1 )
  {
    if( (_QWORD *)v2 == &qword_140C49C00 )
    {
      v6 = HalpMmAllocCtxAlloc((_HALP_ALLOC_CONTEXT *)Src, 0x20ui64);
      v7 = v6;
      if( !v6 )
        return -1073741670;
      *(_OWORD *)v6 = 0i64;
      *((_OWORD *)v6 + 1) = 0i64;
      v10 = HalpIommuCloneDeviceId(Src);
      if( v10 < 0 )
      {
        v12 = (VOID *)*((_QWORD *)v7 + 2);
        if( v12 )
          HalpMmAllocCtxFree(v9, v12);
        HalpMmAllocCtxFree(v9, v7);
      }
      else
      {
        *((_QWORD *)v7 + 3) = 1i64;
        v11 = (UINT8 **)qword_140C49C08;
        if( (_QWORD *)*qword_140C49C08 != &qword_140C49C00 )
          __fastfail(3u);
        *(_QWORD *)v7 = &qword_140C49C00;
        *((_QWORD *)v7 + 1) = v11;
        *v11 = v7;
        qword_140C49C08 = v7;
        *v3 = v7;
      }
      return v10;
    }
    if( IidAreIdsStrictlyEqual(*(INT64 **)(v2 + 16), (INT64)Src) )
      break;
    v2 = *v5;
  }
  if( _InterlockedIncrement64(v5 + 3) <= 1 )
    __fastfail(0xEu);
  *v3 = (UINT8 *)v5;
  return 0;
}

Referenced by:

HalpIommuUnblockDevice